James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | import os |
| 4 | import shutil |
| 5 | |
| 6 | from upstream_utils import ( |
| 7 | get_repo_root, |
| 8 | clone_repo, |
| 9 | comment_out_invalid_includes, |
| 10 | walk_cwd_and_copy_if, |
| 11 | git_am, |
| 12 | ) |
| 13 | |
| 14 | |
| 15 | def main(): |
| 16 | upstream_root = clone_repo("https://github.com/kthohr/gcem.git", "v1.16.0") |
| 17 | wpilib_root = get_repo_root() |
| 18 | wpimath = os.path.join(wpilib_root, "wpimath") |
| 19 | |
| 20 | # Apply patches to upstream Git repo |
| 21 | os.chdir(upstream_root) |
| 22 | for f in []: |
| 23 | git_am(os.path.join(wpilib_root, "upstream_utils/gcem_patches", f)) |
| 24 | |
| 25 | # Delete old install |
| 26 | for d in [ |
| 27 | "src/main/native/thirdparty/gcem/include", |
| 28 | ]: |
| 29 | shutil.rmtree(os.path.join(wpimath, d), ignore_errors=True) |
| 30 | |
| 31 | # Copy gcem include files into allwpilib |
| 32 | include_files = walk_cwd_and_copy_if( |
| 33 | lambda dp, f: dp.endswith("include") |
| 34 | or dp.endswith("gcem_incl") |
| 35 | or dp.endswith("quadrature"), |
| 36 | os.path.join(wpimath, "src/main/native/thirdparty/gcem"), |
| 37 | ) |
| 38 | |
| 39 | for f in include_files: |
| 40 | comment_out_invalid_includes( |
| 41 | f, [os.path.join(wpimath, "src/main/native/thirdparty/gcem/include")] |
| 42 | ) |
| 43 | |
| 44 | |
| 45 | if __name__ == "__main__": |
| 46 | main() |