blob: faddbae80359b3d3de546e5901fb0fdc07d3d9ff [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001#!/usr/bin/env python3
2
3import os
4import shutil
5
6from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if
7
8
9def main():
10 root, repo = setup_upstream_repo("https://github.com/fmtlib/fmt", "8.0.1")
11 wpiutil = os.path.join(root, "wpiutil")
12
13 # Delete old install
14 for d in ["src/main/native/fmtlib/src", "src/main/native/fmtlib/include"]:
15 shutil.rmtree(os.path.join(wpiutil, d), ignore_errors=True)
16
17 # Copy fmt source files into allwpilib
18 src_files = walk_cwd_and_copy_if(
19 lambda dp, f: dp.endswith("src") and f.endswith(".cc") and f !=
20 "fmt.cc", os.path.join(wpiutil, "src/main/native/fmtlib"))
21
22 # Copy fmt header files into allwpilib
23 include_files = walk_cwd_and_copy_if(
24 lambda dp, f: dp.endswith("include/fmt"),
25 os.path.join(wpiutil, "src/main/native/fmtlib"))
26
27 for f in src_files:
28 comment_out_invalid_includes(
29 f, [os.path.join(wpiutil, "src/main/native/fmtlib/include")])
30 for f in include_files:
31 comment_out_invalid_includes(
32 f, [os.path.join(wpiutil, "src/main/native/fmtlib/include")])
33
34
35if __name__ == "__main__":
36 main()