James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | import os |
| 4 | import shutil |
| 5 | |
| 6 | from 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 | |
| 15 | def main(): |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 16 | upstream_root = clone_repo("https://github.com/libuv/libuv", "v1.46.0") |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 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 [ |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 23 | "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 Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 28 | "0006-Style-comments-cleanup.patch", |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 29 | "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 Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 33 | ]: |
| 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 Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 48 | lambda dp, f: dp.startswith("./include") and f not in include_ignorelist, |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 49 | 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 Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 69 | lambda dp, f: dp.startswith("./src") and f not in src_ignorelist, |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 70 | os.path.join(wpinet, "src/main/native/thirdparty/libuv"), |
| 71 | ) |
| 72 | |
| 73 | |
| 74 | if __name__ == "__main__": |
| 75 | main() |