mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Our patches for the DARE and [[noreturn]] attributes were merged upstream. We missed their monthly release window by a day, so we'll use a commit hash for now.
138 lines
3.8 KiB
Python
Executable File
138 lines
3.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import re
|
|
import subprocess
|
|
|
|
from upstream_utils import clone_repo, comment_out_invalid_includes, copy_to, walk_if
|
|
|
|
|
|
def drake_main_cpp_inclusions(dp, f):
|
|
"""Returns true if the given source file in the drake git repo should be
|
|
copied into allwpilib
|
|
|
|
Keyword arguments:
|
|
dp -- directory path
|
|
f -- filename
|
|
"""
|
|
return f in [
|
|
"drake_assert_and_throw.cc", "discrete_algebraic_riccati_equation.cc"
|
|
]
|
|
|
|
|
|
def drake_main_h_inclusions(dp, f):
|
|
"""Returns true if the given header file in the drake git repo should be
|
|
copied into allwpilib
|
|
|
|
Keyword arguments:
|
|
dp -- directory path
|
|
f -- filename
|
|
"""
|
|
return 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"
|
|
]
|
|
|
|
|
|
def drake_test_cpp_inclusions(dp, f):
|
|
"""Returns true if the given source file in the drake git repo should be
|
|
copied into allwpilib
|
|
|
|
Keyword arguments:
|
|
dp -- directory path
|
|
f -- filename
|
|
"""
|
|
return f == "discrete_algebraic_riccati_equation_test.cc"
|
|
|
|
|
|
def drake_test_h_inclusions(dp, f):
|
|
"""Returns true if the given header file in the drake git repo should be
|
|
copied into allwpilib
|
|
|
|
Keyword arguments:
|
|
dp -- directory path
|
|
f -- filename
|
|
"""
|
|
return f == "eigen_matrix_compare.h"
|
|
|
|
|
|
def main():
|
|
wpimath = os.getcwd()
|
|
clone_repo("https://github.com/RobotLocomotion/drake",
|
|
"8b72428dce6959d077e17c3c3a7a5ef4a17107ee")
|
|
repo = os.getcwd()
|
|
|
|
# Copy drake source files into allwpilib
|
|
files = walk_if(".", drake_main_cpp_inclusions)
|
|
dest = os.path.join(wpimath, "src/main/native/cpp/drake")
|
|
copy_to(files, dest)
|
|
|
|
for i in range(len(files)):
|
|
# Files moved to dest
|
|
files[i] = os.path.join(dest, files[i])
|
|
|
|
# copy_to() renames .cc files to .cpp
|
|
if files[i].endswith(".cc"):
|
|
files[i] = os.path.splitext(files[i])[0] + ".cpp"
|
|
|
|
for f in files:
|
|
comment_out_invalid_includes(
|
|
f, [os.path.join(wpimath, "src/main/native/include")])
|
|
|
|
# Copy drake test source files into allwpilib
|
|
os.chdir(os.path.join(repo, "math/test"))
|
|
files = walk_if(".", drake_test_cpp_inclusions)
|
|
dest = os.path.join(wpimath, "src/test/native/cpp/drake")
|
|
copy_to(files, dest)
|
|
os.chdir(repo)
|
|
|
|
for i in range(len(files)):
|
|
# Files moved to dest
|
|
files[i] = os.path.join(dest, files[i])
|
|
|
|
# copy_to() renames .cc files to .cpp
|
|
if files[i].endswith(".cc"):
|
|
files[i] = os.path.splitext(files[i])[0] + ".cpp"
|
|
|
|
for f in files:
|
|
comment_out_invalid_includes(f, [
|
|
os.path.join(wpimath, "src/main/native/include"),
|
|
os.path.join(wpimath, "src/test/native/include")
|
|
])
|
|
|
|
# Copy drake header files into allwpilib
|
|
files = walk_if(".", drake_main_h_inclusions)
|
|
dest = os.path.join(wpimath, "src/main/native/include/drake")
|
|
copy_to(files, dest)
|
|
|
|
# Files moved to dest
|
|
for i in range(len(files)):
|
|
files[i] = os.path.join(dest, files[i])
|
|
|
|
for f in files:
|
|
comment_out_invalid_includes(
|
|
f, [os.path.join(wpimath, "src/main/native/include")])
|
|
|
|
# Copy drake test header files into allwpilib
|
|
files = walk_if(".", drake_test_h_inclusions)
|
|
dest = os.path.join(wpimath, "src/test/native/include/drake")
|
|
copy_to(files, dest)
|
|
|
|
# Files moved to dest
|
|
for i in range(len(files)):
|
|
files[i] = os.path.join(dest, files[i])
|
|
|
|
for f in files:
|
|
comment_out_invalid_includes(
|
|
f, [os.path.join(wpimath, "src/main/native/include")])
|
|
|
|
# Apply patches
|
|
os.chdir(wpimath)
|
|
subprocess.check_output(
|
|
["git", "apply", "drake-replace-dense-with-core.patch"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|