blob: f752b3d371b92798fe5547bb9503013909c18198 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001#!/usr/bin/env python3
2
3import os
4import shutil
5
Austin Schuh75263e32022-02-22 18:05:32 -08006from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if, apply_patches
Austin Schuh812d0d12021-11-04 20:16:48 -07007
8
9def main():
Austin Schuh75263e32022-02-22 18:05:32 -080010 root, repo = setup_upstream_repo("https://github.com/fmtlib/fmt", "8.1.1")
Austin Schuh812d0d12021-11-04 20:16:48 -070011 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
Austin Schuh75263e32022-02-22 18:05:32 -080034 apply_patches(root,
35 ["upstream_utils/fmt-dont-throw-on-write-failure.patch"])
36
Austin Schuh812d0d12021-11-04 20:16:48 -070037
38if __name__ == "__main__":
39 main()