2021-05-19 20:42:05 -07:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import re
|
2021-07-23 09:01:44 -07:00
|
|
|
import shutil
|
2021-05-19 20:42:05 -07:00
|
|
|
|
2024-11-02 17:56:55 -07:00
|
|
|
from upstream_utils import Lib, comment_out_invalid_includes, walk_cwd_and_copy_if
|
2021-05-19 20:42:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def eigen_inclusions(dp, f):
|
|
|
|
|
"""Returns true if the given file in the "Eigen" include directory of the
|
|
|
|
|
Eigen git repo should be copied into allwpilib
|
|
|
|
|
|
|
|
|
|
Keyword arguments:
|
|
|
|
|
dp -- directory path
|
|
|
|
|
f -- filename
|
|
|
|
|
"""
|
2024-08-24 09:52:52 -04:00
|
|
|
if not dp.startswith(os.path.join(".", "Eigen")):
|
2021-07-23 09:01:44 -07:00
|
|
|
return False
|
|
|
|
|
|
2021-05-19 20:42:05 -07:00
|
|
|
abspath = os.path.join(dp, f)
|
|
|
|
|
|
2021-05-21 21:39:33 -07:00
|
|
|
# Exclude NonMPL2.h since all non-MPL2 code will be excluded anyway
|
2021-05-19 20:42:05 -07:00
|
|
|
if f == "NonMPL2.h":
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Exclude BLAS support
|
|
|
|
|
if f.endswith("_BLAS.h") or "blas" in f:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Exclude LAPACK support
|
|
|
|
|
if f.endswith("_LAPACKE.h") or "lapack" in f:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Exclude MKL support
|
|
|
|
|
if "MKL" in f:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Include architectures we care about
|
|
|
|
|
if "Core/arch/" in abspath:
|
2022-07-01 06:41:44 -07:00
|
|
|
return (
|
|
|
|
|
"arch/AVX/" in abspath
|
|
|
|
|
or "arch/Default" in abspath
|
|
|
|
|
or "arch/NEON" in abspath
|
|
|
|
|
or "arch/SSE" in abspath
|
|
|
|
|
)
|
2021-05-19 20:42:05 -07:00
|
|
|
|
|
|
|
|
# Include the following modules
|
|
|
|
|
modules = [
|
|
|
|
|
"Cholesky",
|
|
|
|
|
"Core",
|
|
|
|
|
"Eigenvalues",
|
2024-10-21 22:29:35 -07:00
|
|
|
"Geometry",
|
2021-05-19 20:42:05 -07:00
|
|
|
"Householder",
|
2022-08-13 18:32:02 -07:00
|
|
|
"IterativeLinearSolvers",
|
2021-05-19 20:42:05 -07:00
|
|
|
"Jacobi",
|
|
|
|
|
"LU",
|
2022-08-13 18:32:02 -07:00
|
|
|
"OrderingMethods",
|
2021-05-19 20:42:05 -07:00
|
|
|
"QR",
|
|
|
|
|
"SVD",
|
2022-08-13 18:32:02 -07:00
|
|
|
"SparseCholesky",
|
|
|
|
|
"SparseCore",
|
|
|
|
|
"SparseLU",
|
|
|
|
|
"SparseQR",
|
2021-05-19 20:42:05 -07:00
|
|
|
"misc",
|
|
|
|
|
"plugins",
|
|
|
|
|
]
|
2023-05-12 21:32:58 -07:00
|
|
|
return bool(re.search(r"|".join("/" + m for m in modules), abspath))
|
2021-05-19 20:42:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def unsupported_inclusions(dp, f):
|
|
|
|
|
"""Returns true if the given file in the "unsupported" include directory of
|
|
|
|
|
the Eigen git repo should be copied into allwpilib
|
|
|
|
|
|
|
|
|
|
Keyword arguments:
|
|
|
|
|
dp -- directory path
|
|
|
|
|
f -- filename
|
|
|
|
|
"""
|
2024-08-24 09:52:52 -04:00
|
|
|
if not dp.startswith(os.path.join(".", "unsupported")):
|
2021-07-23 09:01:44 -07:00
|
|
|
return False
|
|
|
|
|
|
2021-05-19 20:42:05 -07:00
|
|
|
abspath = os.path.join(dp, f)
|
|
|
|
|
|
|
|
|
|
# Exclude build system and READMEs
|
|
|
|
|
if f == "CMakeLists.txt" or "README" in f:
|
|
|
|
|
return False
|
|
|
|
|
|
2022-05-26 09:01:45 -07:00
|
|
|
# Include the MatrixFunctions module
|
|
|
|
|
return "MatrixFunctions" in abspath
|
2021-05-19 20:42:05 -07:00
|
|
|
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
def copy_upstream_src(wpilib_root):
|
2022-08-20 07:26:34 -07:00
|
|
|
wpimath = os.path.join(wpilib_root, "wpimath")
|
|
|
|
|
|
2021-07-23 09:01:44 -07:00
|
|
|
# Delete old install
|
2023-12-03 16:18:19 -08:00
|
|
|
for d in ["src/main/native/thirdparty/eigen/include"]:
|
2021-07-23 09:01:44 -07:00
|
|
|
shutil.rmtree(os.path.join(wpimath, d), ignore_errors=True)
|
2021-05-19 20:42:05 -07:00
|
|
|
|
2021-07-23 09:01:44 -07:00
|
|
|
# Copy Eigen headers into allwpilib
|
|
|
|
|
eigen_files = walk_cwd_and_copy_if(
|
2022-06-11 21:07:15 -07:00
|
|
|
eigen_inclusions,
|
2022-07-01 06:41:44 -07:00
|
|
|
os.path.join(wpimath, "src/main/native/thirdparty/eigen/include"),
|
|
|
|
|
)
|
2021-05-19 20:42:05 -07:00
|
|
|
|
2021-07-08 23:36:01 -04:00
|
|
|
# Copy unsupported headers into allwpilib
|
2021-07-23 09:01:44 -07:00
|
|
|
unsupported_files = walk_cwd_and_copy_if(
|
|
|
|
|
unsupported_inclusions,
|
2022-07-01 06:41:44 -07:00
|
|
|
os.path.join(wpimath, "src/main/native/thirdparty/eigen/include"),
|
|
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
|
|
|
|
|
for f in eigen_files:
|
|
|
|
|
comment_out_invalid_includes(
|
2022-07-01 06:41:44 -07:00
|
|
|
f, [os.path.join(wpimath, "src/main/native/thirdparty/eigen/include")]
|
|
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
for f in unsupported_files:
|
|
|
|
|
comment_out_invalid_includes(
|
2022-07-01 06:41:44 -07:00
|
|
|
f, [os.path.join(wpimath, "src/main/native/thirdparty/eigen/include")]
|
|
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
|
2023-12-03 16:18:19 -08:00
|
|
|
shutil.copyfile(
|
2024-07-16 17:20:07 -07:00
|
|
|
".clang-format",
|
2023-12-03 16:18:19 -08:00
|
|
|
os.path.join(wpimath, "src/main/native/thirdparty/eigen/include/.clang-format"),
|
|
|
|
|
)
|
|
|
|
|
|
2021-05-19 20:42:05 -07:00
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
def main():
|
|
|
|
|
name = "eigen"
|
|
|
|
|
url = "https://gitlab.com/libeigen/eigen.git"
|
2024-11-16 07:44:20 -08:00
|
|
|
# master on 2024-11-14
|
|
|
|
|
tag = "0fb2ed140d4fc0108553ecfb25f2d7fc1a9319a1"
|
2024-07-20 07:01:06 -07:00
|
|
|
|
2024-07-23 15:58:15 -07:00
|
|
|
eigen = Lib(name, url, tag, copy_upstream_src)
|
2024-07-16 17:20:07 -07:00
|
|
|
eigen.main()
|
|
|
|
|
|
|
|
|
|
|
2021-05-19 20:42:05 -07:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|