Skip to content

Commit f9b93bf

Browse files
perfiniongunan
authored andcommitted
eigen: Add install_eigen_headers target for installing to system (tensorflow#20281)
Eigen provides files that are both GPL and MPL. Tensorflow uses only the MPL headers. This target collects all the headers into genfiles so they can be easily installed to /usr/include/ later. Thanks to [email protected] for all the help testing and figuring out what was missing. And to [email protected] for pointers to the solution. Signed-off-by: Jason Zaman <[email protected]>
1 parent 45b0917 commit f9b93bf

File tree

2 files changed

+53
-13
lines changed

2 files changed

+53
-13
lines changed

third_party/eigen.BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ cc_library(
6969
includes = ["."],
7070
visibility = ["//visibility:public"],
7171
)
72+
73+
filegroup(
74+
name = "eigen_header_files",
75+
srcs = EIGEN_MPL2_HEADER_FILES,
76+
visibility = ["//visibility:public"],
77+
)

third_party/eigen3/BUILD

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ load("//tensorflow:tensorflow.bzl", "if_mkl")
1717
# INTEL_MKL end
1818
load("//tensorflow:tensorflow.bzl", "if_mkl")
1919

20+
EIGEN3_THIRD_PARTY_HEADERS = [
21+
"Eigen/Core",
22+
"Eigen/LU",
23+
"Eigen/Cholesky",
24+
"Eigen/Eigenvalues",
25+
"Eigen/QR",
26+
"Eigen/SVD",
27+
"unsupported/Eigen/MatrixFunctions",
28+
"unsupported/Eigen/SpecialFunctions",
29+
"unsupported/Eigen/CXX11/ThreadPool",
30+
"unsupported/Eigen/CXX11/Tensor",
31+
"unsupported/Eigen/CXX11/FixedPoint",
32+
] + glob(["unsupported/Eigen/CXX11/src/FixedPoint/*.h"])
33+
2034
cc_library(
2135
name = "eigen3",
22-
hdrs = glob(["unsupported/Eigen/CXX11/src/FixedPoint/*.h"]) + [
23-
"Eigen/Core",
24-
"Eigen/LU",
25-
"Eigen/Cholesky",
26-
"Eigen/Eigenvalues",
27-
"Eigen/QR",
28-
"Eigen/SVD",
29-
"unsupported/Eigen/MatrixFunctions",
30-
"unsupported/Eigen/SpecialFunctions",
31-
"unsupported/Eigen/CXX11/ThreadPool",
32-
"unsupported/Eigen/CXX11/Tensor",
33-
"unsupported/Eigen/CXX11/FixedPoint",
34-
],
36+
hdrs = EIGEN3_THIRD_PARTY_HEADERS,
3537
includes = if_mkl(["./mkl_include"]),
3638
visibility = ["//visibility:public"],
3739
deps = [
@@ -48,3 +50,35 @@ filegroup(
4850
),
4951
visibility = ["//tensorflow:__subpackages__"],
5052
)
53+
54+
filegroup(
55+
name = "eigen_third_party_header_files",
56+
srcs = EIGEN3_THIRD_PARTY_HEADERS,
57+
visibility = ["//visibility:public"],
58+
)
59+
60+
genrule(
61+
name = "install_eigen_headers",
62+
srcs = [
63+
"@eigen_archive//:eigen_header_files",
64+
":eigen_third_party_header_files",
65+
],
66+
outs = ["include"],
67+
cmd = """
68+
mkdir $@
69+
for f in $(locations @eigen_archive//:eigen_header_files) ; do
70+
d="$${f%/*}"
71+
d="$${d#*external/eigen_archive/}"
72+
73+
mkdir -p "$@/$${d}"
74+
cp "$${f}" "$@/$${d}/"
75+
done
76+
77+
for f in $(locations :eigen_third_party_header_files) ; do
78+
d="$${f%/*}"
79+
80+
mkdir -p "$@/$${d}"
81+
cp "$${f}" "$@/$${d}/"
82+
done
83+
"""
84+
)

0 commit comments

Comments
 (0)