blob: a90a6d74f681e424d65b6fe79366e6def8367070 [file] [log] [blame]
James Kuszmaulcf324122023-01-14 14:07:17 -08001#!/usr/bin/env python3
2
3import os
4import shutil
5
6from 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
15def main():
16 upstream_root = clone_repo("https://github.com/libuv/libuv", "v1.44.2")
17 wpilib_root = get_repo_root()
18 wpinet = os.path.join(wpilib_root, "wpinet")
19
20 # Apply patches to upstream Git repo
21 os.chdir(upstream_root)
22 for f in [
23 "0001-Fix-missing-casts.patch",
24 "0002-Fix-warnings.patch",
25 "0003-Preprocessor-cleanup.patch",
26 "0004-Cleanup-problematic-language.patch",
27 "0005-Use-roborio-time.patch",
28 "0006-Style-comments-cleanup.patch",
29 "0007-Squelch-GCC-12.1-warnings.patch",
30 "0008-Fix-Win32-warning-suppression-pragma.patch",
31 "0009-Avoid-unused-variable-warning-on-Mac.patch",
32 ]:
33 git_am(os.path.join(wpilib_root, "upstream_utils/libuv_patches", f))
34
35 # Delete old install
36 for d in ["src/main/native/thirdparty/libuv"]:
37 shutil.rmtree(os.path.join(wpinet, d), ignore_errors=True)
38
39 include_ignorelist = [
40 "aix.h",
41 "os390.h",
42 "stdint-msvc2008.h",
43 "sunos.h",
44 ]
45
46 include_files = walk_cwd_and_copy_if(
47 lambda dp, f: "include" in dp and f not in include_ignorelist,
48 os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
49 )
50
51 src_ignorelist = [
52 "aix-common.c",
53 "aix.c",
54 "bsd-proctitle.c",
55 "darwin-stub.c",
56 "haiku.c",
57 "hurd.c",
58 "os390-proctitle.c",
59 "os390-syscalls.c",
60 "os390-syscalls.h",
61 "os390.c",
62 "qnx.c",
63 "sunos.c",
64 "sysinfo-loadavg.c",
65 "sysinfo-memory.c",
66 ]
67 src_files = walk_cwd_and_copy_if(
68 lambda dp, f: "src" in dp and "docs" not in dp and f not in src_ignorelist,
69 os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
70 )
71
72
73if __name__ == "__main__":
74 main()