2021-07-23 09:01:44 -07:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
|
2022-07-01 06:41:44 -07:00
|
|
|
from upstream_utils import (
|
2022-08-20 07:26:34 -07:00
|
|
|
get_repo_root,
|
|
|
|
|
clone_repo,
|
2022-07-01 06:41:44 -07:00
|
|
|
comment_out_invalid_includes,
|
|
|
|
|
walk_cwd_and_copy_if,
|
2022-08-20 07:26:34 -07:00
|
|
|
git_am,
|
2022-07-01 06:41:44 -07:00
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2024-07-07 06:40:15 -07:00
|
|
|
upstream_root = clone_repo("https://github.com/fmtlib/fmt", "11.0.1")
|
2022-08-20 07:26:34 -07:00
|
|
|
wpilib_root = get_repo_root()
|
|
|
|
|
wpiutil = os.path.join(wpilib_root, "wpiutil")
|
2021-07-23 09:01:44 -07:00
|
|
|
|
2022-08-20 07:26:34 -07:00
|
|
|
# Apply patches to upstream Git repo
|
|
|
|
|
os.chdir(upstream_root)
|
2024-07-02 13:34:59 -07:00
|
|
|
for f in ["0001-Suppress-warnings-we-can-t-fix.patch"]:
|
2022-08-20 07:26:34 -07:00
|
|
|
git_am(os.path.join(wpilib_root, "upstream_utils/fmt_patches", f))
|
2022-05-18 12:23:15 -07:00
|
|
|
|
2021-07-23 09:01:44 -07:00
|
|
|
# Delete old install
|
2022-07-22 18:08:36 -07:00
|
|
|
for d in [
|
|
|
|
|
"src/main/native/thirdparty/fmtlib/src",
|
|
|
|
|
"src/main/native/thirdparty/fmtlib/include",
|
|
|
|
|
]:
|
2021-07-23 09:01:44 -07:00
|
|
|
shutil.rmtree(os.path.join(wpiutil, d), ignore_errors=True)
|
|
|
|
|
|
|
|
|
|
# Copy fmt source files into allwpilib
|
|
|
|
|
src_files = walk_cwd_and_copy_if(
|
2023-08-28 15:07:13 -07:00
|
|
|
lambda dp, f: dp.startswith("./src") and f.endswith(".cc") and f != "fmt.cc",
|
2022-07-22 18:08:36 -07:00
|
|
|
os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib"),
|
2022-07-01 06:41:44 -07:00
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
|
|
|
|
|
# Copy fmt header files into allwpilib
|
|
|
|
|
include_files = walk_cwd_and_copy_if(
|
2023-08-28 15:07:13 -07:00
|
|
|
lambda dp, f: dp.startswith("./include/fmt"),
|
2022-07-22 18:08:36 -07:00
|
|
|
os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib"),
|
2022-07-01 06:41:44 -07:00
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
|
|
|
|
|
for f in src_files:
|
|
|
|
|
comment_out_invalid_includes(
|
2022-07-22 18:08:36 -07:00
|
|
|
f, [os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib/include")]
|
2022-07-01 06:41:44 -07:00
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
for f in include_files:
|
|
|
|
|
comment_out_invalid_includes(
|
2022-07-22 18:08:36 -07:00
|
|
|
f, [os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib/include")]
|
2022-07-01 06:41:44 -07:00
|
|
|
)
|
2021-07-23 09:01:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|