blob: 179632f0aed89e9bfe627555b6cf9ad961d6af74 [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():
James Kuszmaulb13e13f2023-11-22 20:44:04 -080016 upstream_root = clone_repo("https://github.com/libuv/libuv", "v1.46.0")
James Kuszmaulcf324122023-01-14 14:07:17 -080017 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 [
James Kuszmaulb13e13f2023-11-22 20:44:04 -080023 "0001-Revert-win-process-write-minidumps-when-sending-SIGQ.patch",
24 "0002-Fix-missing-casts.patch",
25 "0003-Fix-warnings.patch",
26 "0004-Preprocessor-cleanup.patch",
27 "0005-Cleanup-problematic-language.patch",
James Kuszmaulcf324122023-01-14 14:07:17 -080028 "0006-Style-comments-cleanup.patch",
James Kuszmaulb13e13f2023-11-22 20:44:04 -080029 "0007-Fix-Win32-warning-suppression-pragma.patch",
30 "0008-Use-C-atomics.patch",
31 "0009-Remove-static-from-array-indices.patch",
32 "0010-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch",
James Kuszmaulcf324122023-01-14 14:07:17 -080033 ]:
34 git_am(os.path.join(wpilib_root, "upstream_utils/libuv_patches", f))
35
36 # Delete old install
37 for d in ["src/main/native/thirdparty/libuv"]:
38 shutil.rmtree(os.path.join(wpinet, d), ignore_errors=True)
39
40 include_ignorelist = [
41 "aix.h",
42 "os390.h",
43 "stdint-msvc2008.h",
44 "sunos.h",
45 ]
46
47 include_files = walk_cwd_and_copy_if(
James Kuszmaulb13e13f2023-11-22 20:44:04 -080048 lambda dp, f: dp.startswith("./include") and f not in include_ignorelist,
James Kuszmaulcf324122023-01-14 14:07:17 -080049 os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
50 )
51
52 src_ignorelist = [
53 "aix-common.c",
54 "aix.c",
55 "bsd-proctitle.c",
56 "darwin-stub.c",
57 "haiku.c",
58 "hurd.c",
59 "os390-proctitle.c",
60 "os390-syscalls.c",
61 "os390-syscalls.h",
62 "os390.c",
63 "qnx.c",
64 "sunos.c",
65 "sysinfo-loadavg.c",
66 "sysinfo-memory.c",
67 ]
68 src_files = walk_cwd_and_copy_if(
James Kuszmaulb13e13f2023-11-22 20:44:04 -080069 lambda dp, f: dp.startswith("./src") and f not in src_ignorelist,
James Kuszmaulcf324122023-01-14 14:07:17 -080070 os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
71 )
72
73
74if __name__ == "__main__":
75 main()