1# Description:
2#   Eigen is a C++ template library for linear algebra: vectors,
3#   matrices, and related algorithms.
4
5load("//third_party/mkl:build_defs.bzl", "if_mkl")
6
7licenses([
8    # Note: Eigen is an MPL2 library that includes GPL v3 and LGPL v2.1+ code.
9    #       We've taken special care to not reference any restricted code.
10    "reciprocal",  # MPL2
11    "notice",  # Portions BSD
12])
13
14exports_files(["LICENSE"])
15
16EIGEN3_THIRD_PARTY_HEADERS = [
17    "Eigen/Core",
18    "Eigen/LU",
19    "Eigen/Cholesky",
20    "Eigen/Eigenvalues",
21    "Eigen/OrderingMethods",
22    "Eigen/QR",
23    "Eigen/SparseCholesky",
24    "Eigen/SparseCore",
25    "Eigen/SVD",
26    "unsupported/Eigen/MatrixFunctions",
27    "unsupported/Eigen/SpecialFunctions",
28    "unsupported/Eigen/CXX11/ThreadPool",
29    "unsupported/Eigen/CXX11/Tensor",
30    "unsupported/Eigen/CXX11/FixedPoint",
31] + glob(["unsupported/Eigen/CXX11/src/FixedPoint/*.h"])
32
33cc_library(
34    name = "eigen3",
35    hdrs = EIGEN3_THIRD_PARTY_HEADERS,
36    includes = if_mkl(["./mkl_include"]),
37    visibility = ["//visibility:public"],
38    deps = [
39        "@eigen_archive//:eigen",
40    ],
41)
42
43filegroup(
44    name = "all_files",
45    srcs = glob(
46        ["**/*"],
47        exclude = ["**/OWNERS"],
48    ),
49    visibility = ["//tensorflow:__subpackages__"],
50)
51
52filegroup(
53    name = "eigen_third_party_header_files",
54    srcs = EIGEN3_THIRD_PARTY_HEADERS,
55    visibility = ["//visibility:public"],
56)
57
58genrule(
59    name = "install_eigen_headers",
60    srcs = [
61        "@eigen_archive//:eigen_header_files",
62        ":eigen_third_party_header_files",
63    ],
64    outs = ["include"],
65    cmd = """
66    mkdir $@
67    for f in $(SRCS); do
68      d="$${f%/*}"
69      d="$${d#*external/eigen_archive/}"
70
71      mkdir -p "$@/$${d}"
72      cp "$${f}" "$@/$${d}/"
73    done
74    """,
75    tags = ["manual"],
76)
77