1# Description:
2#   Eigen is a C++ template library for linear algebra: vectors,
3#   matrices, and related algorithms.
4
5licenses([
6    # Note: Although Eigen also includes GPL V3 and LGPL v2.1+ code, TensorFlow
7    #       has taken special care to not reference any restricted code.
8    "reciprocal",  # MPL2
9    "notice",  # Portions BSD
10])
11
12exports_files(["COPYING.MPL2"])
13
14EIGEN_FILES = [
15    "Eigen/**",
16    "unsupported/Eigen/CXX11/**",
17    "unsupported/Eigen/FFT",
18    "unsupported/Eigen/KroneckerProduct",
19    "unsupported/Eigen/src/FFT/**",
20    "unsupported/Eigen/src/KroneckerProduct/**",
21    "unsupported/Eigen/MatrixFunctions",
22    "unsupported/Eigen/SpecialFunctions",
23    "unsupported/Eigen/src/MatrixFunctions/**",
24    "unsupported/Eigen/src/SpecialFunctions/**",
25]
26
27# Files known to be under MPL2 license.
28EIGEN_MPL2_HEADER_FILES = glob(
29    EIGEN_FILES,
30    exclude = [
31        # Guarantees that any non-MPL2 file added to the list above will fail to
32        # compile.
33        "Eigen/src/Core/util/NonMPL2.h",
34        "Eigen/**/CMakeLists.txt",
35    ],
36)
37
38cc_library(
39    name = "eigen",
40    hdrs = EIGEN_MPL2_HEADER_FILES,
41    defines = [
42        # This define (mostly) guarantees we don't link any problematic
43        # code. We use it, but we do not rely on it, as evidenced above.
44        "EIGEN_MPL2_ONLY",
45        "EIGEN_MAX_ALIGN_BYTES=64",
46        "EIGEN_HAS_TYPE_TRAITS=0",
47    ],
48    includes = ["."],
49    visibility = ["//visibility:public"],
50)
51
52filegroup(
53    name = "eigen_header_files",
54    srcs = EIGEN_MPL2_HEADER_FILES,
55    visibility = ["//visibility:public"],
56)
57