|
1 | | -package(default_visibility = ["//visibility:public"]) |
| 1 | +# Description: |
| 2 | +# Eigen is a C++ template library for linear algebra: vectors, |
| 3 | +# matrices, and related algorithms. |
| 4 | + |
| 5 | +licenses([ |
| 6 | + # Note: Eigen is an MPL2 library that includes GPL v3 and LGPL v2.1+ code. |
| 7 | + # We've taken special care to not reference any restricted code. |
| 8 | + "reciprocal", # MPL2 |
| 9 | + "notice", # Portions BSD |
| 10 | +]) |
| 11 | + |
| 12 | +# License-restricted (i.e. not reciprocal or notice) files inside Eigen/... |
| 13 | +EIGEN_RESTRICTED_FILES = [ |
| 14 | + "Eigen/src/OrderingMethods/Amd.h", |
| 15 | + "Eigen/src/SparseCholesky/**", |
| 16 | +] |
| 17 | + |
| 18 | +# Notable transitive dependencies of restricted files inside Eigen/... |
| 19 | +EIGEN_RESTRICTED_DEPS = [ |
| 20 | + "Eigen/Eigen", |
| 21 | + "Eigen/IterativeLinearSolvers", |
| 22 | + "Eigen/MetisSupport", |
| 23 | + "Eigen/Sparse", |
| 24 | + "Eigen/SparseCholesky", |
| 25 | + "Eigen/SparseLU", |
| 26 | +] |
| 27 | + |
| 28 | +# Note: unsupported/Eigen is unsupported and might go away at any time. |
| 29 | +EIGEN_FILES = [ |
| 30 | + "Eigen/**", |
| 31 | + "unsupported/Eigen/CXX11/**", |
| 32 | + "unsupported/Eigen/FFT", |
| 33 | + "unsupported/Eigen/KroneckerProduct", |
| 34 | + "unsupported/Eigen/src/FFT/**", |
| 35 | + "unsupported/Eigen/src/KroneckerProduct/**", |
| 36 | + "unsupported/Eigen/MatrixFunctions", |
| 37 | + "unsupported/Eigen/SpecialFunctions", |
| 38 | + "unsupported/Eigen/src/SpecialFunctions/**", |
| 39 | +] |
| 40 | + |
| 41 | +# List of files picked up by glob but actually part of another target. |
| 42 | +EIGEN_EXCLUDE_FILES = [ |
| 43 | + "Eigen/src/Core/arch/AVX/PacketMathGoogleTest.cc", |
| 44 | +] |
| 45 | + |
| 46 | +# Files known to be under MPL2 license. |
| 47 | +EIGEN_MPL2_HEADER_FILES = glob( |
| 48 | + EIGEN_FILES, |
| 49 | + exclude = EIGEN_EXCLUDE_FILES + |
| 50 | + EIGEN_RESTRICTED_FILES + |
| 51 | + EIGEN_RESTRICTED_DEPS + [ |
| 52 | + # Guarantees any file missed by excludes above will not compile. |
| 53 | + "Eigen/src/Core/util/NonMPL2.h", |
| 54 | + "Eigen/**/CMakeLists.txt", |
| 55 | + ], |
| 56 | +) |
2 | 57 |
|
3 | 58 | cc_library( |
4 | 59 | name = "eigen", |
5 | | - hdrs = glob(["**/*.h", "unsupported/Eigen/*", "unsupported/Eigen/CXX11/*", "Eigen/*"]), |
6 | | - includes = [ '.' ], |
| 60 | + hdrs = EIGEN_MPL2_HEADER_FILES, |
| 61 | + defines = [ |
| 62 | + # This define (mostly) guarantees we don't link any problematic |
| 63 | + # code. We use it, but we do not rely on it, as evidenced above. |
| 64 | + "EIGEN_MPL2_ONLY", |
| 65 | + # TODO(jart): Use EIGEN_USE_NONBLOCKING_THREAD_POOL but first add an |
| 66 | + # eigen_initialize.cc file and alwayslink=1. |
| 67 | + ], |
| 68 | + includes = ["."], |
7 | 69 | visibility = ["//visibility:public"], |
8 | 70 | ) |
0 commit comments