[wpiutil, wpinet] Vendor libuv, stack walker (#4219)

This commit is contained in:
PJ Reiniger
2022-05-09 01:21:54 -04:00
committed by GitHub
parent f0c821282a
commit 18db343cdc
9 changed files with 2207 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,251 @@
From c2390ddd8fa648c87adf279ed5b3489a42c07e67 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:09:43 -0400
Subject: [PATCH 2/6] Fix warnings
---
include/uv/win.h | 5 +++++
src/idna.c | 2 +-
src/inet.c | 4 ++++
src/threadpool.c | 4 ++++
src/unix/core.c | 12 ++++++++++--
src/unix/internal.h | 4 ++--
src/unix/thread.c | 6 ------
src/uv-common.c | 8 ++++++++
src/win/fs-event.c | 2 ++
src/win/fs.c | 3 ++-
src/win/pipe.c | 2 ++
src/win/process.c | 2 ++
src/win/tty.c | 2 ++
13 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/include/uv/win.h b/include/uv/win.h
index acbd958b..354e0989 100644
--- a/include/uv/win.h
+++ b/include/uv/win.h
@@ -194,11 +194,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM)
LPWSAOVERLAPPED overlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
+#pragma warning(push)
+#pragma warning(disable : 28251)
+
#ifndef _NTDEF_
typedef LONG NTSTATUS;
typedef NTSTATUS *PNTSTATUS;
#endif
+#pragma warning(pop)
+
#ifndef RTL_CONDITION_VARIABLE_INIT
typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
#endif
diff --git a/src/idna.c b/src/idna.c
index 13ffac6b..6b2406ca 100644
--- a/src/idna.c
+++ b/src/idna.c
@@ -103,7 +103,7 @@ static int uv__idna_toascii_label(const char* s, const char* se,
char** d, char* de) {
static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789";
const char* ss;
- unsigned c;
+ unsigned c = 0;
unsigned h;
unsigned k;
unsigned n;
diff --git a/src/inet.c b/src/inet.c
index 7e208b53..167ec118 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -27,6 +27,10 @@
#include "uv.h"
#include "uv-common.h"
+#ifdef _WIN32
+#pragma warning(disable : 6001)
+#endif
+
#define UV__INET_ADDRSTRLEN 16
#define UV__INET6_ADDRSTRLEN 46
diff --git a/src/threadpool.c b/src/threadpool.c
index 9cb863e7..515bf407 100644
--- a/src/threadpool.c
+++ b/src/threadpool.c
@@ -27,6 +27,10 @@
#include <stdlib.h>
+#ifdef _WIN32
+#pragma warning(disable: 6001 6011)
+#endif
+
#define MAX_THREADPOOL_SIZE 1024
static uv_once_t once = UV_ONCE_INIT;
diff --git a/src/unix/core.c b/src/unix/core.c
index ef98b6ce..adb278bc 100644
--- a/src/unix/core.c
+++ b/src/unix/core.c
@@ -513,6 +513,16 @@ skip:
}
}
+#if defined(__APPLE__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
+#if defined(__LP64__)
+ extern "C" int close$NOCANCEL(int);
+#else
+ extern "C" int close$NOCANCEL$UNIX2003(int);
+#endif
+#pragma GCC diagnostic pop
+#endif
/* close() on macos has the "interesting" quirk that it fails with EINTR
* without closing the file descriptor when a thread is in the cancel state.
@@ -527,10 +537,8 @@ int uv__close_nocancel(int fd) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
#if defined(__LP64__)
- extern int close$NOCANCEL(int);
return close$NOCANCEL(fd);
#else
- extern int close$NOCANCEL$UNIX2003(int);
return close$NOCANCEL$UNIX2003(fd);
#endif
#pragma GCC diagnostic pop
diff --git a/src/unix/internal.h b/src/unix/internal.h
index 26061647..2db30350 100644
--- a/src/unix/internal.h
+++ b/src/unix/internal.h
@@ -301,8 +301,8 @@ UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) {
loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000;
}
-UV_UNUSED(static char* uv__basename_r(const char* path)) {
- char* s;
+UV_UNUSED(static const char* uv__basename_r(const char* path)) {
+ const char* s;
s = strrchr(path, '/');
if (s == NULL)
diff --git a/src/unix/thread.c b/src/unix/thread.c
index c702d418..c753be9b 100644
--- a/src/unix/thread.c
+++ b/src/unix/thread.c
@@ -222,12 +222,6 @@ int uv_thread_create_ex(uv_thread_t* tid,
size_t pagesize;
size_t stack_size;
- /* Used to squelch a -Wcast-function-type warning. */
- union {
- void (*in)(void*);
- void* (*out)(void*);
- } f;
-
stack_size =
params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
diff --git a/src/uv-common.c b/src/uv-common.c
index 47473346..b61a703d 100644
--- a/src/uv-common.c
+++ b/src/uv-common.c
@@ -698,6 +698,10 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
}
}
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wvarargs"
+#endif
int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
va_list ap;
@@ -711,6 +715,10 @@ int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) {
return err;
}
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
+
static uv_loop_t default_loop_struct;
static uv_loop_t* default_loop_ptr;
diff --git a/src/win/fs-event.c b/src/win/fs-event.c
index 78741bfe..b9ec0256 100644
--- a/src/win/fs-event.c
+++ b/src/win/fs-event.c
@@ -19,6 +19,8 @@
* IN THE SOFTWARE.
*/
+#define _CRT_NONSTDC_NO_WARNINGS
+
#include <assert.h>
#include <errno.h>
#include <stdio.h>
diff --git a/src/win/fs.c b/src/win/fs.c
index dc0b8984..5434698b 100644
--- a/src/win/fs.c
+++ b/src/win/fs.c
@@ -19,6 +19,8 @@
* IN THE SOFTWARE.
*/
+#define _CRT_NONSTDC_NO_WARNINGS
+
#include <assert.h>
#include <stdlib.h>
#include <direct.h>
@@ -1563,7 +1565,6 @@ static void fs__ftruncate(uv_fs_t* req) {
static void fs__copyfile(uv_fs_t* req) {
int flags;
int overwrite;
- DWORD error;
uv_stat_t statbuf;
uv_stat_t new_statbuf;
diff --git a/src/win/pipe.c b/src/win/pipe.c
index 138f9ed6..0c03a065 100644
--- a/src/win/pipe.c
+++ b/src/win/pipe.c
@@ -19,6 +19,8 @@
* IN THE SOFTWARE.
*/
+#define _CRT_NONSTDC_NO_WARNINGS
+
#include <assert.h>
#include <io.h>
#include <stdio.h>
diff --git a/src/win/process.c b/src/win/process.c
index f3c9a43e..15f3b65e 100644
--- a/src/win/process.c
+++ b/src/win/process.c
@@ -19,6 +19,8 @@
* IN THE SOFTWARE.
*/
+#define _CRT_NONSTDC_NO_WARNINGS
+
#include <assert.h>
#include <io.h>
#include <stdio.h>
diff --git a/src/win/tty.c b/src/win/tty.c
index a5d58bf7..deec66fe 100644
--- a/src/win/tty.c
+++ b/src/win/tty.c
@@ -19,6 +19,8 @@
* IN THE SOFTWARE.
*/
+#define _CRT_NONSTDC_NO_WARNINGS
+
#include <assert.h>
#include <io.h>
#include <string.h>
--
2.20.1.windows.1

View File

@@ -0,0 +1,202 @@
From 80055296378f0a8ad0eec823fd2d0209a447fd22 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:19:14 -0400
Subject: [PATCH 3/6] Preprocessor cleanup
---
include/uv.h | 18 +-----------------
include/uv/unix.h | 6 ------
include/uv/win.h | 6 +-----
src/unix/internal.h | 4 ++++
src/unix/poll.c | 5 +++--
src/win/fs.c | 1 +
src/win/tty.c | 2 ++
src/win/util.c | 6 ++++++
src/win/winsock.c | 1 +
9 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/include/uv.h b/include/uv.h
index f97801ce..ccf62c8f 100644
--- a/include/uv.h
+++ b/include/uv.h
@@ -23,9 +23,6 @@
#ifndef UV_H
#define UV_H
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifdef _WIN32
/* Windows - set up dll import/export decorators. */
@@ -50,11 +47,7 @@ extern "C" {
#include <stddef.h>
#include <stdio.h>
-#if defined(_MSC_VER) && _MSC_VER < 1600
-# include "uv/stdint-msvc2008.h"
-#else
-# include <stdint.h>
-#endif
+#include <stdint.h>
#if defined(_WIN32)
# include "uv/win.h"
@@ -692,16 +685,10 @@ UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode);
UV_EXTERN int uv_tty_reset_mode(void);
UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
-#ifdef __cplusplus
-extern "C++" {
-
inline int uv_tty_set_mode(uv_tty_t* handle, int mode) {
return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode));
}
-}
-#endif
-
UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
/*
@@ -1693,7 +1680,4 @@ UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data);
#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS
#undef UV__ERR
-#ifdef __cplusplus
-}
-#endif
#endif /* UV_H */
diff --git a/include/uv/unix.h b/include/uv/unix.h
index a647593a..504bab7c 100644
--- a/include/uv/unix.h
+++ b/include/uv/unix.h
@@ -47,12 +47,6 @@
#if defined(__linux__)
# include "uv/linux.h"
-#elif defined (__MVS__)
-# include "uv/os390.h"
-#elif defined(_AIX)
-# include "uv/aix.h"
-#elif defined(__sun)
-# include "uv/sunos.h"
#elif defined(__APPLE__)
# include "uv/darwin.h"
#elif defined(__DragonFly__) || \
diff --git a/include/uv/win.h b/include/uv/win.h
index 354e0989..ca5242f7 100644
--- a/include/uv/win.h
+++ b/include/uv/win.h
@@ -53,11 +53,7 @@ typedef struct pollfd {
#include <fcntl.h>
#include <sys/stat.h>
-#if defined(_MSC_VER) && _MSC_VER < 1600
-# include "uv/stdint-msvc2008.h"
-#else
-# include <stdint.h>
-#endif
+#include <stdint.h>
#include "uv/tree.h"
#include "uv/threadpool.h"
diff --git a/src/unix/internal.h b/src/unix/internal.h
index 2db30350..13ca2e63 100644
--- a/src/unix/internal.h
+++ b/src/unix/internal.h
@@ -168,9 +168,11 @@ struct uv__stream_queued_fds_s {
defined(__NetBSD__)
#define uv__cloexec uv__cloexec_ioctl
#define uv__nonblock uv__nonblock_ioctl
+#define UV__NONBLOCK_IS_IOCTL
#else
#define uv__cloexec uv__cloexec_fcntl
#define uv__nonblock uv__nonblock_fcntl
+#define UV__NONBLOCK_IS_FCNTL
#endif
/* On Linux, uv__nonblock_fcntl() and uv__nonblock_ioctl() do not commute
@@ -183,6 +185,8 @@ struct uv__stream_queued_fds_s {
#if defined(__linux__) && O_NDELAY != O_NONBLOCK
#undef uv__nonblock
#define uv__nonblock uv__nonblock_fcntl
+#undef UV__NONBLOCK_IS_IOCTL
+#define UV__NONBLOCK_IS_FCNTL
#endif
/* core */
diff --git a/src/unix/poll.c b/src/unix/poll.c
index 3d5022b2..d578611e 100644
--- a/src/unix/poll.c
+++ b/src/unix/poll.c
@@ -79,9 +79,10 @@ int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) {
* Workaround for e.g. kqueue fds not supporting ioctls.
*/
err = uv__nonblock(fd, 1);
+#ifdef UV__NONBLOCK_IS_IOCTL
if (err == UV_ENOTTY)
- if (uv__nonblock == uv__nonblock_ioctl)
- err = uv__nonblock_fcntl(fd, 1);
+ err = uv__nonblock_fcntl(fd, 1);
+#endif
if (err)
return err;
diff --git a/src/win/fs.c b/src/win/fs.c
index 5434698b..6b9e37b0 100644
--- a/src/win/fs.c
+++ b/src/win/fs.c
@@ -39,6 +39,7 @@
#include <wincrypt.h>
+#pragma comment(lib, "Advapi32.lib")
#define UV_FS_FREE_PATHS 0x0002
#define UV_FS_FREE_PTR 0x0008
diff --git a/src/win/tty.c b/src/win/tty.c
index deec66fe..e4d7ac96 100644
--- a/src/win/tty.c
+++ b/src/win/tty.c
@@ -42,6 +42,8 @@
#include "stream-inl.h"
#include "req-inl.h"
+#pragma comment(lib, "User32.lib")
+
#ifndef InterlockedOr
# define InterlockedOr _InterlockedOr
#endif
diff --git a/src/win/util.c b/src/win/util.c
index d1cd19ba..b5afb1d8 100644
--- a/src/win/util.c
+++ b/src/win/util.c
@@ -67,6 +67,12 @@
static char *process_title;
static CRITICAL_SECTION process_title_lock;
+#pragma comment(lib, "Advapi32.lib")
+#pragma comment(lib, "IPHLPAPI.lib")
+#pragma comment(lib, "Psapi.lib")
+#pragma comment(lib, "Userenv.lib")
+#pragma comment(lib, "kernel32.lib")
+
/* Interval (in seconds) of the high-resolution clock. */
static double hrtime_interval_ = 0;
diff --git a/src/win/winsock.c b/src/win/winsock.c
index 5820ba9c..918acaf5 100644
--- a/src/win/winsock.c
+++ b/src/win/winsock.c
@@ -25,6 +25,7 @@
#include "uv.h"
#include "internal.h"
+#pragma comment(lib, "Ws2_32.lib")
/* Whether there are any non-IFS LSPs stacked on TCP */
int uv_tcp_non_ifs_lsp_ipv4;
--
2.20.1.windows.1

View File

@@ -0,0 +1,64 @@
From 5649a07d496fecd1812265b86b329186af78c3fc Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:24:47 -0400
Subject: [PATCH 4/6] Cleanup problematic language
---
src/unix/tty.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/unix/tty.c b/src/unix/tty.c
index 74d3d75d..5f681406 100644
--- a/src/unix/tty.c
+++ b/src/unix/tty.c
@@ -38,7 +38,7 @@ static int orig_termios_fd = -1;
static struct termios orig_termios;
static uv_spinlock_t termios_spinlock = UV_SPINLOCK_INITIALIZER;
-static int uv__tty_is_slave(const int fd) {
+static int uv__tty_is_peripheral(const int fd) {
int result;
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
int dummy;
@@ -50,15 +50,16 @@ static int uv__tty_is_slave(const int fd) {
result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0;
#elif defined(__NetBSD__)
/*
- * NetBSD as an extension returns with ptsname(3) and ptsname_r(3) the slave
- * device name for both descriptors, the master one and slave one.
+ * NetBSD as an extension returns with ptsname(3) and ptsname_r(3) the
+ * peripheral device name for both descriptors, the controller one and
+ * peripheral one.
*
* Implement function to compare major device number with pts devices.
*
* The major numbers are machine-dependent, on NetBSD/amd64 they are
* respectively:
- * - master tty: ptc - major 6
- * - slave tty: pts - major 5
+ * - controller tty: ptc - major 6
+ * - peripheral tty: pts - major 5
*/
struct stat sb;
@@ -133,12 +134,12 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int unused) {
* other processes.
*/
if (type == UV_TTY) {
- /* Reopening a pty in master mode won't work either because the reopened
- * pty will be in slave mode (*BSD) or reopening will allocate a new
- * master/slave pair (Linux). Therefore check if the fd points to a
- * slave device.
+ /* Reopening a pty in controller mode won't work either because the reopened
+ * pty will be in peripheral mode (*BSD) or reopening will allocate a new
+ * controller/peripheral pair (Linux). Therefore check if the fd points to a
+ * peripheral device.
*/
- if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0)
+ if (uv__tty_is_peripheral(fd) && ttyname_r(fd, path, sizeof(path)) == 0)
r = uv__open_cloexec(path, mode);
else
r = -1;
--
2.20.1.windows.1

View File

@@ -0,0 +1,45 @@
From bb5cdf6360308dce34546f55d02f8073b88dd748 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:26:03 -0400
Subject: [PATCH 5/6] Use roborio time
---
src/unix/linux-core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
index a66bb535..8a267823 100644
--- a/src/unix/linux-core.c
+++ b/src/unix/linux-core.c
@@ -67,6 +67,10 @@
# define CLOCK_MONOTONIC_COARSE 6
#endif
+#ifdef __FRC_ROBORIO__
+#include "wpi/timestamp.h"
+#endif
+
/* This is rather annoying: CLOCK_BOOTTIME lives in <linux/time.h> but we can't
* include that file because it conflicts with <time.h>. We'll just have to
* define it ourselves.
@@ -424,6 +428,9 @@ update_timeout:
uint64_t uv__hrtime(uv_clocktype_t type) {
+#ifdef __FRC_ROBORIO__
+ return wpi::Now() * 1000u;
+#else
static clock_t fast_clock_id = -1;
struct timespec t;
clock_t clock_id;
@@ -453,6 +460,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
return 0; /* Not really possible. */
return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec;
+#endif
}
--
2.20.1.windows.1

View File

@@ -0,0 +1,105 @@
From a9ec38882aa39841109dd001b1122c2ff60454e6 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:28:52 -0400
Subject: [PATCH 6/6] Style / comments cleanup
---
src/fs-poll.c | 1 +
src/unix/core.c | 1 +
src/unix/thread.c | 3 +--
src/uv-common.c | 1 +
src/win/process.c | 1 -
src/win/winsock.c | 1 +
6 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/fs-poll.c b/src/fs-poll.c
index f605bcea..14d64de8 100644
--- a/src/fs-poll.c
+++ b/src/fs-poll.c
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
+
struct poll_ctx {
uv_fs_poll_t* parent_handle;
int busy_polling;
diff --git a/src/unix/core.c b/src/unix/core.c
index adb278bc..77bb337c 100644
--- a/src/unix/core.c
+++ b/src/unix/core.c
@@ -513,6 +513,7 @@ skip:
}
}
+
#if defined(__APPLE__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
diff --git a/src/unix/thread.c b/src/unix/thread.c
index c753be9b..012cd6a1 100644
--- a/src/unix/thread.c
+++ b/src/unix/thread.c
@@ -85,7 +85,6 @@ error2:
return rc;
}
-
int uv_barrier_wait(uv_barrier_t* barrier) {
struct _uv_barrier* b;
int last;
@@ -94,6 +93,7 @@ int uv_barrier_wait(uv_barrier_t* barrier) {
return UV_EINVAL;
b = barrier->b;
+ /* Lock the mutex*/
uv_mutex_lock(&b->mutex);
if (++b->in == b->threshold) {
@@ -114,7 +114,6 @@ int uv_barrier_wait(uv_barrier_t* barrier) {
return last;
}
-
void uv_barrier_destroy(uv_barrier_t* barrier) {
struct _uv_barrier* b;
diff --git a/src/uv-common.c b/src/uv-common.c
index b61a703d..3c65476a 100644
--- a/src/uv-common.c
+++ b/src/uv-common.c
@@ -698,6 +698,7 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) {
}
}
+
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wvarargs"
diff --git a/src/win/process.c b/src/win/process.c
index 15f3b65e..3b8675a6 100644
--- a/src/win/process.c
+++ b/src/win/process.c
@@ -35,7 +35,6 @@
#include "handle-inl.h"
#include "req-inl.h"
-
#define SIGKILL 9
diff --git a/src/win/winsock.c b/src/win/winsock.c
index 918acaf5..668e3b64 100644
--- a/src/win/winsock.c
+++ b/src/win/winsock.c
@@ -25,6 +25,7 @@
#include "uv.h"
#include "internal.h"
+
#pragma comment(lib, "Ws2_32.lib")
/* Whether there are any non-IFS LSPs stacked on TCP */
--
2.20.1.windows.1

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env python3
import os
import shutil
import re
from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if, am_patches, walk_if, copy_to
def main():
root, repo = setup_upstream_repo("http://github.com/libuv/libuv", "v1.30.1")
wpinet = os.path.join(root, "wpinet")
# yapf: disable
# Apply patches to original git repo
am_patches(repo, [
os.path.join(root, "upstream_utils/libuv_patches/0001-Fix-missing-casts.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0002-Fix-warnings.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0005-Use-roborio-time.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch"),
])
# yapf: enable
# Delete old install
for d in ["src/main/native/thirdparty/libuv"]:
shutil.rmtree(os.path.join(wpinet, d), ignore_errors=True)
include_ignorelist = [
"aix.h",
"os390.h",
"stdint-msvc2008.h",
"sunos.h",
]
include_files = walk_cwd_and_copy_if(
lambda dp, f: "include" in dp and f not in include_ignorelist,
os.path.join(wpinet, "src/main/native/thirdparty/libuv"))
src_ignorelist = [
"aix-common.c",
"aix.c",
"bsd-proctitle.c",
"haiku.c",
"os390-syscalls.c",
"os390-syscalls.h",
"os390.c",
"sunos.c",
"sysinfo-memory.c",
]
src_files = walk_cwd_and_copy_if(
lambda dp, f: "src" in dp and "docs" not in dp and f
not in src_ignorelist,
os.path.join(wpinet, "src/main/native/thirdparty/libuv"))
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python3
import os
import shutil
import re
import requests
import tempfile
import urllib
import subprocess
from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if, am_patches, walk_if, copy_to
def main():
root, repo = setup_upstream_repo(
"https://github.com/JochenKalmbach/StackWalker",
"42e7a6e056a9e7aca911a7e9e54e2e4f90bc2652")
wpiutil = os.path.join(root, "wpiutil")
pr35_url = "http://patch-diff.githubusercontent.com/raw/JochenKalmbach/StackWalker/pull/35.patch"
pr35_patch_download_path = os.path.join(tempfile.gettempdir(),
"stackwalker.patch")
response = urllib.request.urlopen(pr35_url)
with open(pr35_patch_download_path, 'wb') as f:
f.write(response.read())
am_patches(repo, [pr35_patch_download_path])
shutil.copy(os.path.join("Main", "StackWalker", "StackWalker.h"),
os.path.join(wpiutil, "src/main/native/windows/StackWalker.h"))
shutil.copy(
os.path.join("Main", "StackWalker", "StackWalker.cpp"),
os.path.join(wpiutil, "src/main/native/windows/StackWalker.cpp"))
if __name__ == "__main__":
main()

View File

@@ -118,6 +118,8 @@ def copy_to(files, root):
# Rename .cc file to .cpp
if dest_file.endswith(".cc"):
dest_file = os.path.splitext(dest_file)[0] + ".cpp"
if dest_file.endswith(".c"):
dest_file = os.path.splitext(dest_file)[0] + ".cpp"
# Make leading directory
dest_dir = os.path.dirname(dest_file)
@@ -199,3 +201,24 @@ def apply_patches(root, patches):
os.chdir(root)
for patch in patches:
subprocess.check_output(["git", "apply", patch])
def am_patches(root, patches, use_threeway=False):
"""Apply list of patches to the destination Git repository.
Keyword arguments:
root -- the root directory of the destination Git repository
patches -- list of patch files relative to the root
"""
if len(patches) == 0:
raise Exception("Must provide at least one patch")
os.chdir(root)
args = ["git", "am"]
if use_threeway:
args.append("-3")
for patch in patches:
args.append(patch)
subprocess.check_output(args)