eigen: Add install_eigen_headers target for installing to system (#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 dennisjenkins@google.com for all the help testing and figuring
out what was missing. And to pcloudy@google.com for pointers to the solution.

Signed-off-by: Jason Zaman <jason@perfinion.com>
This commit is contained in:
Jason Zaman 2018-06-29 05:09:02 +08:00 committed by Gunhan Gulsoy
parent 45b09176cc
commit f9b93bf580
2 changed files with 53 additions and 13 deletions

View File

@ -69,3 +69,9 @@ cc_library(
includes = ["."],
visibility = ["//visibility:public"],
)
filegroup(
name = "eigen_header_files",
srcs = EIGEN_MPL2_HEADER_FILES,
visibility = ["//visibility:public"],
)

View File

@ -17,21 +17,23 @@ load("//tensorflow:tensorflow.bzl", "if_mkl")
# INTEL_MKL end
load("//tensorflow:tensorflow.bzl", "if_mkl")
EIGEN3_THIRD_PARTY_HEADERS = [
"Eigen/Core",
"Eigen/LU",
"Eigen/Cholesky",
"Eigen/Eigenvalues",
"Eigen/QR",
"Eigen/SVD",
"unsupported/Eigen/MatrixFunctions",
"unsupported/Eigen/SpecialFunctions",
"unsupported/Eigen/CXX11/ThreadPool",
"unsupported/Eigen/CXX11/Tensor",
"unsupported/Eigen/CXX11/FixedPoint",
] + glob(["unsupported/Eigen/CXX11/src/FixedPoint/*.h"])
cc_library(
name = "eigen3",
hdrs = glob(["unsupported/Eigen/CXX11/src/FixedPoint/*.h"]) + [
"Eigen/Core",
"Eigen/LU",
"Eigen/Cholesky",
"Eigen/Eigenvalues",
"Eigen/QR",
"Eigen/SVD",
"unsupported/Eigen/MatrixFunctions",
"unsupported/Eigen/SpecialFunctions",
"unsupported/Eigen/CXX11/ThreadPool",
"unsupported/Eigen/CXX11/Tensor",
"unsupported/Eigen/CXX11/FixedPoint",
],
hdrs = EIGEN3_THIRD_PARTY_HEADERS,
includes = if_mkl(["./mkl_include"]),
visibility = ["//visibility:public"],
deps = [
@ -48,3 +50,35 @@ filegroup(
),
visibility = ["//tensorflow:__subpackages__"],
)
filegroup(
name = "eigen_third_party_header_files",
srcs = EIGEN3_THIRD_PARTY_HEADERS,
visibility = ["//visibility:public"],
)
genrule(
name = "install_eigen_headers",
srcs = [
"@eigen_archive//:eigen_header_files",
":eigen_third_party_header_files",
],
outs = ["include"],
cmd = """
mkdir $@
for f in $(locations @eigen_archive//:eigen_header_files) ; do
d="$${f%/*}"
d="$${d#*external/eigen_archive/}"
mkdir -p "$@/$${d}"
cp "$${f}" "$@/$${d}/"
done
for f in $(locations :eigen_third_party_header_files) ; do
d="$${f%/*}"
mkdir -p "$@/$${d}"
cp "$${f}" "$@/$${d}/"
done
"""
)