mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
* Root folder variable names are now more descriptive * clone_repo() now restores the current working directory * Removed setup_upstream_repo() since it's now identical to clone_repo() * Moved am_patches()'s for loop into user scripts so the filename prefix doesn't need to be included in every patch filename * Renamed am_patches() to git_am() since its only job now is to run "git am" * Removed unused apply_patches() function * Fixed typo in git_am()'s ignore_whitespace arg name
101 lines
3.1 KiB
Python
Executable File
101 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import shutil
|
|
|
|
from upstream_utils import (
|
|
get_repo_root,
|
|
clone_repo,
|
|
comment_out_invalid_includes,
|
|
walk_cwd_and_copy_if,
|
|
git_am,
|
|
)
|
|
|
|
|
|
def main():
|
|
upstream_root = clone_repo("https://github.com/RobotLocomotion/drake", "v1.6.0")
|
|
wpilib_root = get_repo_root()
|
|
wpimath = os.path.join(wpilib_root, "wpimath")
|
|
|
|
# Apply patches to upstream Git repo
|
|
os.chdir(upstream_root)
|
|
for f in [
|
|
"0001-Replace-Eigen-Dense-with-Eigen-Core.patch",
|
|
"0002-Add-WPILIB_DLLEXPORT-to-DARE-function-declarations.patch",
|
|
]:
|
|
git_am(os.path.join(wpilib_root, "upstream_utils/drake_patches", f))
|
|
|
|
# Delete old install
|
|
for d in [
|
|
"src/main/native/thirdparty/drake/src",
|
|
"src/main/native/thirdparty/drake/include",
|
|
"src/test/native/cpp/drake",
|
|
"src/test/native/include/drake",
|
|
]:
|
|
shutil.rmtree(os.path.join(wpimath, d), ignore_errors=True)
|
|
|
|
# Copy drake source files into allwpilib
|
|
src_files = walk_cwd_and_copy_if(
|
|
lambda dp, f: f
|
|
in ["drake_assert_and_throw.cc", "discrete_algebraic_riccati_equation.cc"],
|
|
os.path.join(wpimath, "src/main/native/thirdparty/drake/src"),
|
|
)
|
|
|
|
# Copy drake header files into allwpilib
|
|
include_files = walk_cwd_and_copy_if(
|
|
lambda dp, f: f
|
|
in [
|
|
"drake_assert.h",
|
|
"drake_assertion_error.h",
|
|
"is_approx_equal_abstol.h",
|
|
"never_destroyed.h",
|
|
"drake_copyable.h",
|
|
"drake_throw.h",
|
|
"discrete_algebraic_riccati_equation.h",
|
|
],
|
|
os.path.join(wpimath, "src/main/native/thirdparty/drake/include/drake"),
|
|
)
|
|
|
|
# Copy drake test source files into allwpilib
|
|
os.chdir(os.path.join(upstream_root, "math/test"))
|
|
test_src_files = walk_cwd_and_copy_if(
|
|
lambda dp, f: f == "discrete_algebraic_riccati_equation_test.cc",
|
|
os.path.join(wpimath, "src/test/native/cpp/drake"),
|
|
)
|
|
os.chdir(upstream_root)
|
|
|
|
# Copy drake test header files into allwpilib
|
|
test_include_files = walk_cwd_and_copy_if(
|
|
lambda dp, f: f == "eigen_matrix_compare.h",
|
|
os.path.join(wpimath, "src/test/native/include/drake"),
|
|
)
|
|
|
|
for f in src_files:
|
|
comment_out_invalid_includes(
|
|
f, [os.path.join(wpimath, "src/main/native/thirdparty/drake/include")]
|
|
)
|
|
for f in include_files:
|
|
comment_out_invalid_includes(
|
|
f, [os.path.join(wpimath, "src/main/native/thirdparty/drake/include")]
|
|
)
|
|
for f in test_src_files:
|
|
comment_out_invalid_includes(
|
|
f,
|
|
[
|
|
os.path.join(wpimath, "src/main/native/thirdparty/drake/include"),
|
|
os.path.join(wpimath, "src/test/native/include"),
|
|
],
|
|
)
|
|
for f in test_include_files:
|
|
comment_out_invalid_includes(
|
|
f,
|
|
[
|
|
os.path.join(wpimath, "src/main/native/thirdparty/drake/include"),
|
|
os.path.join(wpimath, "src/test/native/include"),
|
|
],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|