blob: f7d13b4db9b0c97c027be8b97ab505f54844c7b8 [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():
Maxwell Henderson80bec322024-01-09 15:48:44 -080016 upstream_root = clone_repo("https://github.com/libuv/libuv", "v1.47.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",
Maxwell Henderson80bec322024-01-09 15:48:44 -080028 "0006-Fix-Win32-warning-suppression-pragma.patch",
29 "0007-Use-C-atomics.patch",
30 "0008-Remove-static-from-array-indices.patch",
31 "0009-Add-pragmas-for-missing-libraries-and-set-_WIN32_WIN.patch",
James Kuszmaulcf324122023-01-14 14:07:17 -080032 ]:
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(
James Kuszmaulb13e13f2023-11-22 20:44:04 -080047 lambda dp, f: dp.startswith("./include") and f not in include_ignorelist,
James Kuszmaulcf324122023-01-14 14:07:17 -080048 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(
James Kuszmaulb13e13f2023-11-22 20:44:04 -080068 lambda dp, f: dp.startswith("./src") and f not in src_ignorelist,
James Kuszmaulcf324122023-01-14 14:07:17 -080069 os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
70 )
71
72
73if __name__ == "__main__":
74 main()