From 462b2466b34724ce194b4249a3e241083eb753d3 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 6 Jul 2017 19:12:45 -0400 Subject: [PATCH] deps: upgrade libuv to 1.13.1 PR-URL: https://github.com/nodejs/node/pull/14117 Reviewed-By: Refael Ackermann Reviewed-By: Daniel Bevenius Reviewed-By: James M Snell --- deps/uv/.mailmap | 1 + deps/uv/AUTHORS | 7 + deps/uv/ChangeLog | 56 +++++++ deps/uv/README.md | 163 ++++++++++++++------ deps/uv/appveyor.yml | 2 +- deps/uv/common.gypi | 12 +- deps/uv/configure.ac | 6 +- deps/uv/include/uv-version.h | 4 +- deps/uv/src/unix/aix.c | 1 + deps/uv/src/unix/atomic-ops.h | 5 +- deps/uv/src/unix/core.c | 5 +- deps/uv/src/unix/freebsd.c | 35 ++--- deps/uv/src/unix/os390.c | 8 +- deps/uv/src/unix/process.c | 28 ++++ deps/uv/src/unix/proctitle.c | 4 +- deps/uv/src/unix/stream.c | 32 ++-- deps/uv/src/unix/sunos.c | 3 +- deps/uv/src/win/fs.c | 24 +++ deps/uv/src/win/pipe.c | 47 +++--- deps/uv/src/win/udp.c | 46 +++++- deps/uv/test/run-tests.c | 5 + deps/uv/test/runner-unix.c | 6 +- deps/uv/test/test-async-null-cb.c | 9 ++ deps/uv/test/test-fs.c | 40 +++++ deps/uv/test/test-ipc.c | 96 ++++++++++++ deps/uv/test/test-list.h | 8 + deps/uv/test/test-spawn.c | 21 +++ deps/uv/test/test-udp-try-send.c | 12 -- deps/uv/tools/vswhere_usability_wrapper.cmd | 33 ++++ deps/uv/uv.gyp | 8 +- deps/uv/vcbuild.bat | 30 +++- 31 files changed, 618 insertions(+), 139 deletions(-) create mode 100644 deps/uv/tools/vswhere_usability_wrapper.cmd diff --git a/deps/uv/.mailmap b/deps/uv/.mailmap index 618274c0d2e242..896d4065bc486e 100644 --- a/deps/uv/.mailmap +++ b/deps/uv/.mailmap @@ -41,3 +41,4 @@ Yasuhiro Matsumoto Yazhong Liu Yuki Okumura jBarz +jBarz diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index ab4e099f167379..4ef241092701d2 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -292,3 +292,10 @@ Keane James McCoy Bernardo Ramos Juan Cruz Viotti +Gemini Wen +Sebastian Wiedenroth +Sai Ke WANG +Barnabas Gema +Romain Caire +Robert Ayrapetyan +Refael Ackermann diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index 71b210f44bddf1..67c99df82eaee7 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,59 @@ +2017.07.07, Version 1.13.1 (Stable), 2bb4b68758f07cd8617838e68c44c125bc567ba6 + +Changes since version 1.13.0: + +* Now working on version 1.13.1 (cjihrig) + +* build: workaround AppVeyor quirk (Refael Ackermann) + + +2017.07.06, Version 1.13.0 (Stable), 8342fcaab815f33b988c1910ea988f28dfe27edb + +Changes since version 1.12.0: + +* Now working on version 1.12.1 (cjihrig) + +* unix: avoid segfault in uv_get_process_title (Michele Caini) + +* build: add a comma to uv.gyp (Gemini Wen) + +* win: restore file pos after positional read/write (Bartosz Sosnowski) + +* unix,stream: return error on closed handle passing (Santiago Gimeno) + +* unix,benchmark: use fd instead of FILE* after fork (jBarz) + +* zos: avoid compiler warnings (jBarz) + +* win,pipe: race condition canceling readfile thread (Jameson Nash) + +* sunos: filter out non-IPv4/IPv6 interfaces (Sebastian Wiedenroth) + +* sunos: fix cmpxchgi and cmpxchgl type error (Sai Ke WANG) + +* unix: reset signal disposition before execve() (Ben Noordhuis) + +* unix: reset signal mask before execve() (Ben Noordhuis) + +* unix: fix POLLIN assertion on server read (jBarz) + +* zos: use stckf builtin for high-res timer (jBarz) + +* win,udp: implements uv_udp_try_send (Barnabas Gema) + +* win,udp: return UV_EINVAL instead of aborting (Romain Caire) + +* freebsd: replace kvm with sysctl (Robert Ayrapetyan) + +* aix: fix un-initialized pointer field in fs handle (Gireesh Punathil) + +* win,build: support building with VS2017 (Refael Ackermann) + +* doc: add instructions for building on Windows (Refael Ackermann) + +* doc: format README (Refael Ackermann) + + 2017.05.31, Version 1.12.0 (Stable), d6ac141ac674657049598c36604f26e031fae917 Changes since version 1.11.0: diff --git a/deps/uv/README.md b/deps/uv/README.md index e5d94faf0fa38e..372d514e049c39 100644 --- a/deps/uv/README.md +++ b/deps/uv/README.md @@ -3,7 +3,7 @@ ## Overview libuv is a multi-platform support library with a focus on asynchronous I/O. It -was primarily developed for use by [Node.js](http://nodejs.org), but it's also +was primarily developed for use by [Node.js][], but it's also used by [Luvit](http://luvit.io/), [Julia](http://julialang.org/), [pyuv](https://github.com/saghul/pyuv), and [others](https://github.com/libuv/libuv/wiki/Projects-that-use-libuv). @@ -62,24 +62,34 @@ formats. Show different supported building options: - $ make help +```bash +$ make help +``` Build documentation as HTML: - $ make html +```bash +$ make html +``` Build documentation as HTML and live reload it when it changes (this requires sphinx-autobuild to be installed and is only supported on Unix): - $ make livehtml +```bash +$ make livehtml +``` Build documentation as man pages: - $ make man +```bash +$ make man +``` Build documentation as ePub: - $ make epub +```bash +$ make epub +``` NOTE: Windows users need to use make.bat instead of plain 'make'. @@ -116,25 +126,32 @@ file, but are also available as git blob objects for easier use. Importing a key the usual way: - $ gpg --keyserver pool.sks-keyservers.net \ - --recv-keys AE9BC059 +```bash +$ gpg --keyserver pool.sks-keyservers.net --recv-keys AE9BC059 +``` Importing a key from a git blob object: - $ git show pubkey-saghul | gpg --import +```bash +$ git show pubkey-saghul | gpg --import +``` ### Verifying releases Git tags are signed with the developer's key, they can be verified as follows: - $ git verify-tag v1.6.1 +```bash +$ git verify-tag v1.6.1 +``` Starting with libuv 1.7.0, the tarballs stored in the [downloads site](http://dist.libuv.org/dist/) are signed and an accompanying signature file sit alongside each. Once both the release tarball and the signature file are downloaded, the file can be verified as follows: - $ gpg --verify libuv-1.7.0.tar.gz.sign +```bash +$ gpg --verify libuv-1.7.0.tar.gz.sign +``` ## Build Instructions @@ -144,38 +161,82 @@ backends. It is best used for integration into other projects. To build with autotools: - $ sh autogen.sh - $ ./configure - $ make - $ make check - $ make install +```bash +$ sh autogen.sh +$ ./configure +$ make +$ make check +$ make install +``` ### Windows -First, [Python][] 2.6 or 2.7 must be installed as it is required by [GYP][]. -If python is not in your path, set the environment variable `PYTHON` to its -location. For example: `set PYTHON=C:\Python27\python.exe` +Prerequisites: + +* [Python 2.6 or 2.7][] as it is required + by [GYP][]. + If python is not in your path, set the environment variable `PYTHON` to its + location. For example: `set PYTHON=C:\Python27\python.exe` +* One of: + * [Visual C++ Build Tools][] + * [Visual Studio 2015 Update 3][], all editions + including the Community edition (remember to select + "Common Tools for Visual C++ 2015" feature during installation). + * [Visual Studio 2017][], any edition (including the Build Tools SKU). + **Required Components:** "MSbuild", "VC++ 2017 v141 toolset" and one of the + Windows SDKs (10 or 8.1). +* Basic Unix tools required for some tests, + [Git for Windows][] includes Git Bash + and tools which can be included in the global `PATH`. + +To build, launch a git shell (e.g. Cmd or PowerShell), run `vcbuild.bat` +(to build with VS2017 you need to explicitly add a `vs2017` argument), +which will checkout the GYP code into `build/gyp`, generate `uv.sln` +as well as the necesery related project files, and start building. + +```console +> vcbuild +``` + +Or: + +```console +> vcbuild vs2017 +``` + +To run the tests: + +```console +> vcbuild test +``` + +To see all the options that could passed to `vcbuild`: + +```console +> vcbuild help +vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared] +Examples: + vcbuild.bat : builds debug build + vcbuild.bat test : builds debug build and runs tests + vcbuild.bat release bench: builds release build and runs benchmarks +``` -To build with Visual Studio, launch a git shell (e.g. Cmd or PowerShell) -and run vcbuild.bat which will checkout the GYP code into build/gyp and -generate uv.sln as well as related project files. - -To have GYP generate build script for another system, checkout GYP into the -project tree manually: - - $ git clone https://chromium.googlesource.com/external/gyp.git build/gyp ### Unix For Debug builds (recommended) run: - $ ./gyp_uv.py -f make - $ make -C out +```bash +$ ./gyp_uv.py -f make +$ make -C out +``` For Release builds run: - $ ./gyp_uv.py -f make - $ BUILDTYPE=Release make -C out +```bash +$ ./gyp_uv.py -f make +$ BUILDTYPE=Release make -C out +``` Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries. @@ -183,13 +244,17 @@ Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries. Run: - $ ./gyp_uv.py -f xcode - $ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \ - -configuration Release -target All +```bash +$ ./gyp_uv.py -f xcode +$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \ + -configuration Release -target All +``` Using Homebrew: - $ brew install --HEAD libuv +```bash +$ brew install --HEAD libuv +``` Note to OS X users: @@ -201,8 +266,10 @@ Make sure that you specify the architecture you wish to build for in the Run: - $ source ./android-configure NDK_PATH gyp - $ make -C out +```bash +$ source ./android-configure NDK_PATH gyp +$ make -C out +``` Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and `-D_FILE_OFFSET_BITS=64`. GYP builds take care of that automatically. @@ -211,18 +278,22 @@ Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and To use ninja for build on ninja supported platforms, run: - $ ./gyp_uv.py -f ninja - $ ninja -C out/Debug #for debug build OR - $ ninja -C out/Release +```bash +$ ./gyp_uv.py -f ninja +$ ninja -C out/Debug #for debug build OR +$ ninja -C out/Release +``` ### Running tests Run: - $ ./gyp_uv.py -f make - $ make -C out - $ ./out/Debug/run-tests +```bash +$ ./gyp_uv.py -f make +$ make -C out +$ ./out/Debug/run-tests +``` ## Supported Platforms @@ -244,7 +315,11 @@ See the [guidelines for contributing][]. [node.js]: http://nodejs.org/ [GYP]: http://code.google.com/p/gyp/ -[Python]: https://www.python.org/downloads/ [guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md [libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png [x32]: https://en.wikipedia.org/wiki/X32_ABI +[Python 2.6 or 2.7]: https://www.python.org/downloads/ +[Visual C++ Build Tools]: http://landinghub.visualstudio.com/visual-cpp-build-tools +[Visual Studio 2015 Update 3]: https://www.visualstudio.com/vs/older-downloads/ +[Visual Studio 2017]: https://www.visualstudio.com/downloads/ +[Git for Windows]: http://git-scm.com/download/win diff --git a/deps/uv/appveyor.yml b/deps/uv/appveyor.yml index c542e34b991168..be90ef7b435c74 100644 --- a/deps/uv/appveyor.yml +++ b/deps/uv/appveyor.yml @@ -1,4 +1,4 @@ -version: v1.12.0.build{build} +version: v1.13.1.build{build} install: - cinst -y nsis diff --git a/deps/uv/common.gypi b/deps/uv/common.gypi index 94e760030335bc..ec482340c27b47 100644 --- a/deps/uv/common.gypi +++ b/deps/uv/common.gypi @@ -49,9 +49,6 @@ 'cflags': [ '-O3', '-fstrict-aliasing', - '-fomit-frame-pointer', - '-fdata-sections', - '-ffunction-sections', ], 'msvs_settings': { 'VCCLCompilerTool': { @@ -82,6 +79,15 @@ 'LinkIncremental': 1, # disable incremental linking }, }, + 'conditions': [ + ['OS != "os390"', { + 'cflags': [ + '-fomit-frame-pointer', + '-fdata-sections', + '-ffunction-sections', + ], + }], + ] } }, 'msvs_settings': { diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index 8ac06f7fc8c84e..a52cfc622cbb5f 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.12.0], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.13.1], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) @@ -66,9 +66,7 @@ AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false]) AS_CASE([$host_os],[mingw*], [ LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32" ]) -AS_CASE([$host_os], [openbsd*], [], [ - AC_CHECK_LIB([kvm], [kvm_open]) -]) +AS_CASE([$host_os], [netbsd*], [AC_CHECK_LIB([kvm], [kvm_open])]) AC_CHECK_HEADERS([sys/ahafs_evProds.h]) AC_CHECK_PROG(PKG_CONFIG, pkg-config, yes) AM_CONDITIONAL([HAVE_PKG_CONFIG], [test "x$PKG_CONFIG" != "x"]) diff --git a/deps/uv/include/uv-version.h b/deps/uv/include/uv-version.h index 34d4a43f9e5f22..c80c40ea7f1bb0 100644 --- a/deps/uv/include/uv-version.h +++ b/deps/uv/include/uv-version.h @@ -31,8 +31,8 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 12 -#define UV_VERSION_PATCH 0 +#define UV_VERSION_MINOR 13 +#define UV_VERSION_PATCH 1 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/src/unix/aix.c b/deps/uv/src/unix/aix.c index 388c9cca9707ee..426f7f4735fd39 100644 --- a/deps/uv/src/unix/aix.c +++ b/deps/uv/src/unix/aix.c @@ -855,6 +855,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, uv__io_init(&handle->event_watcher, uv__ahafs_event, fd); handle->path = uv__strdup(filename); handle->cb = cb; + handle->dir_filename = NULL; uv__io_start(handle->loop, &handle->event_watcher, POLLIN); diff --git a/deps/uv/src/unix/atomic-ops.h b/deps/uv/src/unix/atomic-ops.h index 9dac2557f867e5..7cac1f98890d77 100644 --- a/deps/uv/src/unix/atomic-ops.h +++ b/deps/uv/src/unix/atomic-ops.h @@ -20,7 +20,6 @@ #if defined(__SUNPRO_C) || defined(__SUNPRO_CC) #include -#define __sync_val_compare_and_swap(p, o, n) atomic_cas_ptr(p, o, n) #endif UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)); @@ -49,6 +48,8 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) { return oldval; else return op4; +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) + return atomic_cas_uint(ptr, oldval, newval); #else return __sync_val_compare_and_swap(ptr, oldval, newval); #endif @@ -83,6 +84,8 @@ UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) { return oldval; else return op4; +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) + return atomic_cas_ulong(ptr, oldval, newval); #else return __sync_val_compare_and_swap(ptr, oldval, newval); #endif diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index 8276c604132995..4c744925e29607 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -28,7 +28,6 @@ #include #include #include -#include /* MAXHOSTNAMELEN on Linux and the BSDs */ #include #include #include @@ -82,6 +81,10 @@ #include #endif +#if !defined(__MVS__) +#include /* MAXHOSTNAMELEN on Linux and the BSDs */ +#endif + /* Fallback for the maximum hostname length */ #ifndef MAXHOSTNAMELEN # define MAXHOSTNAMELEN 256 diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c index e52ae99dbe9030..c3c4902be9a568 100644 --- a/deps/uv/src/unix/freebsd.c +++ b/deps/uv/src/unix/freebsd.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -203,35 +202,31 @@ int uv_get_process_title(char* buffer, size_t size) { return 0; } - int uv_resident_set_memory(size_t* rss) { - kvm_t *kd = NULL; - struct kinfo_proc *kinfo = NULL; - pid_t pid; - int nprocs; - size_t page_size = getpagesize(); + struct kinfo_proc kinfo; + size_t page_size; + size_t kinfo_size; + int mib[4]; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); - pid = getpid(); + kinfo_size = sizeof(kinfo); - kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open"); - if (kd == NULL) goto error; + if (sysctl(mib, 4, &kinfo, &kinfo_size, NULL, 0)) + return -errno; - kinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, &nprocs); - if (kinfo == NULL) goto error; + page_size = getpagesize(); #ifdef __DragonFly__ - *rss = kinfo->kp_vm_rssize * page_size; + *rss = kinfo.kp_vm_rssize * page_size; #else - *rss = kinfo->ki_rssize * page_size; + *rss = kinfo.ki_rssize * page_size; #endif - kvm_close(kd); - return 0; - -error: - if (kd) kvm_close(kd); - return -EPERM; } diff --git a/deps/uv/src/unix/os390.c b/deps/uv/src/unix/os390.c index 2ba5abf35490d7..de7df91169ad8f 100644 --- a/deps/uv/src/unix/os390.c +++ b/deps/uv/src/unix/os390.c @@ -25,6 +25,7 @@ #include #include #include +#include #if defined(__clang__) #include "csrsic.h" #else @@ -118,9 +119,10 @@ void uv__platform_loop_delete(uv_loop_t* loop) { uint64_t uv__hrtime(uv_clocktype_t type) { - struct timeval time; - gettimeofday(&time, NULL); - return (uint64_t) time.tv_sec * 1e9 + time.tv_usec * 1e3; + unsigned long long timestamp; + __stckf(×tamp); + /* Convert to nanoseconds */ + return timestamp / 10; } diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c index f2fe30521c1d9b..80b9686ec828f4 100644 --- a/deps/uv/src/unix/process.c +++ b/deps/uv/src/unix/process.c @@ -279,9 +279,12 @@ static void uv__process_child_init(const uv_process_options_t* options, int stdio_count, int (*pipes)[2], int error_fd) { + sigset_t set; int close_fd; int use_fd; + int err; int fd; + int n; if (options->flags & UV_PROCESS_DETACHED) setsid(); @@ -376,6 +379,31 @@ static void uv__process_child_init(const uv_process_options_t* options, environ = options->env; } + /* Reset signal disposition. Use a hard-coded limit because NSIG + * is not fixed on Linux: it's either 32, 34 or 64, depending on + * whether RT signals are enabled. We are not allowed to touch + * RT signal handlers, glibc uses them internally. + */ + for (n = 1; n < 32; n += 1) { + if (n == SIGKILL || n == SIGSTOP) + continue; /* Can't be changed. */ + + if (SIG_ERR != signal(n, SIG_DFL)) + continue; + + uv__write_int(error_fd, -errno); + _exit(127); + } + + /* Reset signal mask. */ + sigemptyset(&set); + err = pthread_sigmask(SIG_SETMASK, &set, NULL); + + if (err != 0) { + uv__write_int(error_fd, -err); + _exit(127); + } + execvp(options->file, options->args); uv__write_int(error_fd, -errno); _exit(127); diff --git a/deps/uv/src/unix/proctitle.c b/deps/uv/src/unix/proctitle.c index 9160f7eafb3729..2ed0b21c6625bd 100644 --- a/deps/uv/src/unix/proctitle.c +++ b/deps/uv/src/unix/proctitle.c @@ -98,7 +98,9 @@ int uv_get_process_title(char* buffer, size_t size) { else if (size <= process_title.len) return -ENOBUFS; - memcpy(buffer, process_title.str, process_title.len + 1); + if (process_title.len != 0) + memcpy(buffer, process_title.str, process_title.len + 1); + buffer[process_title.len] = '\0'; return 0; diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 7b23d16ecf1407..c502098dcf1b38 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -514,7 +514,7 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { int err; stream = container_of(w, uv_stream_t, io_watcher); - assert(events == POLLIN); + assert(events & POLLIN); assert(stream->accepted_fd == -1); assert(!(stream->flags & UV_CLOSING)); @@ -750,6 +750,7 @@ static void uv__write(uv_stream_t* stream) { int iovmax; int iovcnt; ssize_t n; + int err; start: @@ -782,14 +783,21 @@ static void uv__write(uv_stream_t* stream) { */ if (req->send_handle) { + int fd_to_send; struct msghdr msg; struct cmsghdr *cmsg; - int fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle); union { char data[64]; struct cmsghdr alias; } scratch; + if (uv__is_closing(req->send_handle)) { + err = -EBADF; + goto error; + } + + fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle); + memset(&scratch, 0, sizeof(scratch)); assert(fd_to_send >= 0); @@ -852,14 +860,8 @@ static void uv__write(uv_stream_t* stream) { if (n < 0) { if (errno != EAGAIN && errno != EWOULDBLOCK) { - /* Error */ - req->error = -errno; - uv__write_req_finish(req); - uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); - if (!uv__io_active(&stream->io_watcher, POLLIN)) - uv__handle_stop(stream); - uv__stream_osx_interrupt_select(stream); - return; + err = -errno; + goto error; } else if (stream->flags & UV_STREAM_BLOCKING) { /* If this is a blocking stream, try again. */ goto start; @@ -923,6 +925,16 @@ static void uv__write(uv_stream_t* stream) { /* Notify select() thread about state change */ uv__stream_osx_interrupt_select(stream); + + return; + +error: + req->error = err; + uv__write_req_finish(req); + uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); + if (!uv__io_active(&stream->io_watcher, POLLIN)) + uv__handle_stop(stream); + uv__stream_osx_interrupt_select(stream); } diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index 2dc02ae457cd06..49de5a7fcd5b1f 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -747,7 +747,8 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent) { return 1; if (ent->ifa_addr == NULL) return 1; - if (ent->ifa_addr->sa_family == PF_PACKET) + if (ent->ifa_addr->sa_family != AF_INET && + ent->ifa_addr->sa_family != AF_INET6) return 1; return 0; } diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 2d72cdc70fe7d8..8223d6f655d1df 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -556,9 +556,14 @@ void fs__read(uv_fs_t* req) { DWORD error; int result; unsigned int index; + LARGE_INTEGER original_position; + LARGE_INTEGER zero_offset; + int restore_position; VERIFY_FD(fd, req); + zero_offset.QuadPart = 0; + restore_position = 0; handle = uv__get_osfhandle(fd); if (handle == INVALID_HANDLE_VALUE) { @@ -569,6 +574,10 @@ void fs__read(uv_fs_t* req) { if (offset != -1) { memset(&overlapped, 0, sizeof overlapped); overlapped_ptr = &overlapped; + if (SetFilePointerEx(handle, zero_offset, &original_position, + FILE_CURRENT)) { + restore_position = 1; + } } else { overlapped_ptr = NULL; } @@ -593,6 +602,9 @@ void fs__read(uv_fs_t* req) { ++index; } while (result && index < req->fs.info.nbufs); + if (restore_position) + SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN); + if (result || bytes > 0) { SET_REQ_RESULT(req, bytes); } else { @@ -615,9 +627,14 @@ void fs__write(uv_fs_t* req) { DWORD bytes; int result; unsigned int index; + LARGE_INTEGER original_position; + LARGE_INTEGER zero_offset; + int restore_position; VERIFY_FD(fd, req); + zero_offset.QuadPart = 0; + restore_position = 0; handle = uv__get_osfhandle(fd); if (handle == INVALID_HANDLE_VALUE) { SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); @@ -627,6 +644,10 @@ void fs__write(uv_fs_t* req) { if (offset != -1) { memset(&overlapped, 0, sizeof overlapped); overlapped_ptr = &overlapped; + if (SetFilePointerEx(handle, zero_offset, &original_position, + FILE_CURRENT)) { + restore_position = 1; + } } else { overlapped_ptr = NULL; } @@ -651,6 +672,9 @@ void fs__write(uv_fs_t* req) { ++index; } while (result && index < req->fs.info.nbufs); + if (restore_position) + SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN); + if (result || bytes > 0) { SET_REQ_RESULT(req, bytes); } else { diff --git a/deps/uv/src/win/pipe.c b/deps/uv/src/win/pipe.c index edf30021217980..9b10cc9fe22bf6 100644 --- a/deps/uv/src/win/pipe.c +++ b/deps/uv/src/win/pipe.c @@ -968,27 +968,31 @@ static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) { uv_mutex_unlock(m); } restart_readfile: - result = ReadFile(handle->handle, - &uv_zero_, - 0, - &bytes, - NULL); - if (!result) { - err = GetLastError(); - if (err == ERROR_OPERATION_ABORTED && - handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { - if (handle->flags & UV_HANDLE_READING) { - /* just a brief break to do something else */ - handle->pipe.conn.readfile_thread = NULL; - /* resume after it is finished */ - uv_mutex_lock(m); - handle->pipe.conn.readfile_thread = hThread; - uv_mutex_unlock(m); - goto restart_readfile; - } else { - result = 1; /* successfully stopped reading */ + if (handle->flags & UV_HANDLE_READING) { + result = ReadFile(handle->handle, + &uv_zero_, + 0, + &bytes, + NULL); + if (!result) { + err = GetLastError(); + if (err == ERROR_OPERATION_ABORTED && + handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) { + if (handle->flags & UV_HANDLE_READING) { + /* just a brief break to do something else */ + handle->pipe.conn.readfile_thread = NULL; + /* resume after it is finished */ + uv_mutex_lock(m); + handle->pipe.conn.readfile_thread = hThread; + uv_mutex_unlock(m); + goto restart_readfile; + } else { + result = 1; /* successfully stopped reading */ + } } } + } else { + result = 1; /* successfully aborted read before it even started */ } if (hThread) { assert(hThread == handle->pipe.conn.readfile_thread); @@ -1515,7 +1519,10 @@ static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error, static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle, int error, uv_buf_t buf) { - if (error == ERROR_BROKEN_PIPE) { + if (error == ERROR_OPERATION_ABORTED) { + /* do nothing (equivalent to EINTR) */ + } + else if (error == ERROR_BROKEN_PIPE) { uv_pipe_read_eof(loop, handle, buf); } else { uv_pipe_read_error(loop, handle, error, buf); diff --git a/deps/uv/src/win/udp.c b/deps/uv/src/win/udp.c index 2fd15cfa9a64fa..21348f3796926a 100644 --- a/deps/uv/src/win/udp.c +++ b/deps/uv/src/win/udp.c @@ -897,13 +897,12 @@ int uv__udp_send(uv_udp_send_t* req, int err; if (!(handle->flags & UV_HANDLE_BOUND)) { - if (addrlen == sizeof(uv_addr_ip4_any_)) { + if (addrlen == sizeof(uv_addr_ip4_any_)) bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_; - } else if (addrlen == sizeof(uv_addr_ip6_any_)) { + else if (addrlen == sizeof(uv_addr_ip6_any_)) bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; - } else { - abort(); - } + else + return UV_EINVAL; err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); if (err) return uv_translate_sys_error(err); @@ -922,5 +921,40 @@ int uv__udp_try_send(uv_udp_t* handle, unsigned int nbufs, const struct sockaddr* addr, unsigned int addrlen) { - return UV_ENOSYS; + DWORD bytes; + const struct sockaddr* bind_addr; + int err; + + assert(nbufs > 0); + + /* Already sending a message.*/ + if (handle->send_queue_count != 0) + return UV_EAGAIN; + + if (!(handle->flags & UV_HANDLE_BOUND)) { + if (addrlen == sizeof(uv_addr_ip4_any_)) + bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_; + else if (addrlen == sizeof(uv_addr_ip6_any_)) + bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; + else + return UV_EINVAL; + err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); + if (err) + return uv_translate_sys_error(err); + } + + err = WSASendTo(handle->socket, + (WSABUF*)bufs, + nbufs, + &bytes, + 0, + addr, + addrlen, + NULL, + NULL); + + if (err) + return uv_translate_sys_error(WSAGetLastError()); + + return bytes; } diff --git a/deps/uv/test/run-tests.c b/deps/uv/test/run-tests.c index 1e344f05002ac6..4e10b68f3b42f7 100644 --- a/deps/uv/test/run-tests.c +++ b/deps/uv/test/run-tests.c @@ -38,6 +38,7 @@ int ipc_helper(int listen_after_write); int ipc_helper_tcp_connection(void); +int ipc_helper_closed_handle(void); int ipc_send_recv_helper(void); int ipc_helper_bind_twice(void); int stdio_over_pipes_helper(void); @@ -89,6 +90,10 @@ static int maybe_run_test(int argc, char **argv) { return ipc_helper_tcp_connection(); } + if (strcmp(argv[1], "ipc_helper_closed_handle") == 0) { + return ipc_helper_closed_handle(); + } + if (strcmp(argv[1], "ipc_helper_bind_twice") == 0) { return ipc_helper_bind_twice(); } diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index 2ff18ce75647fe..3167ed44bf695a 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -61,12 +61,14 @@ int platform_init(int argc, char **argv) { /* Make sure that all stdio output of the processes is buffered up. */ int process_start(char* name, char* part, process_info_t* p, int is_helper) { FILE* stdout_file; + int stdout_fd; const char* arg; char* args[16]; int n; pid_t pid; stdout_file = tmpfile(); + stdout_fd = fileno(stdout_file); if (!stdout_file) { perror("tmpfile"); return -1; @@ -103,8 +105,8 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) { args[n++] = part; args[n++] = NULL; - dup2(fileno(stdout_file), STDOUT_FILENO); - dup2(fileno(stdout_file), STDERR_FILENO); + dup2(stdout_fd, STDOUT_FILENO); + dup2(stdout_fd, STDERR_FILENO); execvp(args[0], args); perror("execvp()"); _exit(127); diff --git a/deps/uv/test/test-async-null-cb.c b/deps/uv/test/test-async-null-cb.c index 757944a2762dd0..52652d91ebf098 100644 --- a/deps/uv/test/test-async-null-cb.c +++ b/deps/uv/test/test-async-null-cb.c @@ -21,6 +21,7 @@ #include "uv.h" #include "task.h" +#include static uv_async_t async_handle; static uv_check_t check_handle; @@ -43,6 +44,14 @@ static void check_cb(uv_check_t* handle) { TEST_IMPL(async_null_cb) { + /* + * Fill async_handle with garbage values. + * uv_async_init() should properly initialize struct fields regardless of + * initial values. + * This is added to verify paddings between fields do not affect behavior. + */ + memset(&async_handle, 0xff, sizeof(async_handle)); + ASSERT(0 == uv_async_init(uv_default_loop(), &async_handle, NULL)); ASSERT(0 == uv_check_init(uv_default_loop(), &check_handle)); ASSERT(0 == uv_check_start(&check_handle, check_cb)); diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index c482ab5c71c06a..404d0426f38aed 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -2804,3 +2804,43 @@ TEST_IMPL(get_osfhandle_valid_handle) { MAKE_VALGRIND_HAPPY(); return 0; } + +TEST_IMPL(fs_file_pos_after_op_with_offset) { + int r; + + /* Setup. */ + unlink("test_file"); + loop = uv_default_loop(); + + r = uv_fs_open(loop, + &open_req1, + "test_file", + O_RDWR | O_CREAT, + S_IWUSR | S_IRUSR, + NULL); + ASSERT(r > 0); + uv_fs_req_cleanup(&open_req1); + + iov = uv_buf_init(test_buf, sizeof(test_buf)); + r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, 0, NULL); + ASSERT(r == sizeof(test_buf)); + ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0); + uv_fs_req_cleanup(&write_req); + + iov = uv_buf_init(buf, sizeof(buf)); + r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, 0, NULL); + ASSERT(r == sizeof(test_buf)); + ASSERT(strcmp(buf, test_buf) == 0); + ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0); + uv_fs_req_cleanup(&read_req); + + r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); + ASSERT(r == 0); + uv_fs_req_cleanup(&close_req); + + /* Cleanup */ + unlink("test_file"); + + MAKE_VALGRIND_HAPPY(); + return 0; +} diff --git a/deps/uv/test/test-ipc.c b/deps/uv/test/test-ipc.c index a2fda2458546ba..88d63d4dc670a7 100644 --- a/deps/uv/test/test-ipc.c +++ b/deps/uv/test/test-ipc.c @@ -44,6 +44,7 @@ static int close_cb_called; static int connection_accepted; static int tcp_conn_read_cb_called; static int tcp_conn_write_cb_called; +static int closed_handle_data_read; typedef struct { uv_connect_t conn_req; @@ -53,6 +54,7 @@ typedef struct { #define CONN_COUNT 100 #define BACKLOG 128 +#define LARGE_SIZE 1000000 static void close_server_conn_cb(uv_handle_t* handle) { @@ -395,6 +397,26 @@ static void on_read_connection(uv_stream_t* handle, } +#ifndef _WIN32 +static void on_read_closed_handle(uv_stream_t* handle, + ssize_t nread, + const uv_buf_t* buf) { + if (nread == 0 || nread == UV_EOF) { + free(buf->base); + return; + } + + if (nread < 0) { + printf("error recving on channel: %s\n", uv_strerror(nread)); + abort(); + } + + closed_handle_data_read += nread; + free(buf->base); +} +#endif + + static int run_ipc_test(const char* helper, uv_read_cb read_cb) { uv_process_t process; int r; @@ -448,6 +470,15 @@ TEST_IMPL(ipc_tcp_connection) { return r; } +#ifndef _WIN32 +TEST_IMPL(ipc_closed_handle) { + int r; + r = run_ipc_test("ipc_helper_closed_handle", on_read_closed_handle); + ASSERT(r == 0); + return 0; +} +#endif + #ifdef _WIN32 TEST_IMPL(listen_with_simultaneous_accepts) { @@ -536,6 +567,17 @@ static void tcp_connection_write_cb(uv_write_t* req, int status) { } +static void closed_handle_large_write_cb(uv_write_t* req, int status) { + ASSERT(status == 0); + ASSERT(closed_handle_data_read = LARGE_SIZE); +} + + +static void closed_handle_write_cb(uv_write_t* req, int status) { + ASSERT(status == UV_EBADF); +} + + static void on_tcp_child_process_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { @@ -742,6 +784,60 @@ int ipc_helper_tcp_connection(void) { return 0; } + +int ipc_helper_closed_handle(void) { + int r; + struct sockaddr_in addr; + uv_write_t write_req; + uv_write_t write_req2; + uv_buf_t buf; + char buffer[LARGE_SIZE]; + + r = uv_pipe_init(uv_default_loop(), &channel, 1); + ASSERT(r == 0); + + uv_pipe_open(&channel, 0); + + ASSERT(1 == uv_is_readable((uv_stream_t*) &channel)); + ASSERT(1 == uv_is_writable((uv_stream_t*) &channel)); + ASSERT(0 == uv_is_closing((uv_handle_t*) &channel)); + + memset(buffer, '.', LARGE_SIZE); + buf = uv_buf_init(buffer, LARGE_SIZE); + + r = uv_tcp_init(uv_default_loop(), &tcp_server); + ASSERT(r == 0); + + ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + + r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); + ASSERT(r == 0); + + r = uv_write(&write_req, + (uv_stream_t*)&channel, + &buf, + 1, + closed_handle_large_write_cb); + ASSERT(r == 0); + + r = uv_write2(&write_req2, + (uv_stream_t*)&channel, + &buf, + 1, + (uv_stream_t*)&tcp_server, + closed_handle_write_cb); + ASSERT(r == 0); + + uv_close((uv_handle_t*)&tcp_server, NULL); + + r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); + ASSERT(r == 0); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + + int ipc_helper_bind_twice(void) { /* * This is launched from test-ipc.c. stdin is a duplex channel diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 3571aa2308397f..0c32d84d2038ba 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -63,6 +63,9 @@ TEST_DECLARE (ipc_send_recv_pipe_inprocess) TEST_DECLARE (ipc_send_recv_tcp) TEST_DECLARE (ipc_send_recv_tcp_inprocess) TEST_DECLARE (ipc_tcp_connection) +#ifndef _WIN32 +TEST_DECLARE (ipc_closed_handle) +#endif TEST_DECLARE (tcp_alloc_cb_fail) TEST_DECLARE (tcp_ping_pong) TEST_DECLARE (tcp_ping_pong_v6) @@ -308,6 +311,7 @@ TEST_DECLARE (fs_read_write_null_arguments) TEST_DECLARE (get_osfhandle_valid_handle) TEST_DECLARE (fs_write_alotof_bufs) TEST_DECLARE (fs_write_alotof_bufs_with_offset) +TEST_DECLARE (fs_file_pos_after_op_with_offset) TEST_DECLARE (threadpool_queue_work_simple) TEST_DECLARE (threadpool_queue_work_einval) TEST_DECLARE (threadpool_multiple_event_loops) @@ -443,6 +447,9 @@ TASK_LIST_START TEST_ENTRY (ipc_send_recv_tcp) TEST_ENTRY (ipc_send_recv_tcp_inprocess) TEST_ENTRY (ipc_tcp_connection) +#ifndef _WIN32 + TEST_ENTRY (ipc_closed_handle) +#endif TEST_ENTRY (tcp_alloc_cb_fail) @@ -793,6 +800,7 @@ TASK_LIST_START TEST_ENTRY (fs_write_alotof_bufs) TEST_ENTRY (fs_write_alotof_bufs_with_offset) TEST_ENTRY (fs_read_write_null_arguments) + TEST_ENTRY (fs_file_pos_after_op_with_offset) TEST_ENTRY (get_osfhandle_valid_handle) TEST_ENTRY (threadpool_queue_work_simple) TEST_ENTRY (threadpool_queue_work_einval) diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index 52fc7f6cc5e95d..bb35e32b28a285 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -929,9 +929,30 @@ TEST_IMPL(kill) { init_process_options("spawn_helper4", kill_cb); + /* Verify that uv_spawn() resets the signal disposition. */ +#ifndef _WIN32 + { + sigset_t set; + sigemptyset(&set); + sigaddset(&set, SIGTERM); + ASSERT(0 == pthread_sigmask(SIG_BLOCK, &set, NULL)); + } + ASSERT(SIG_ERR != signal(SIGTERM, SIG_IGN)); +#endif + r = uv_spawn(uv_default_loop(), &process, &options); ASSERT(r == 0); +#ifndef _WIN32 + { + sigset_t set; + sigemptyset(&set); + sigaddset(&set, SIGTERM); + ASSERT(0 == pthread_sigmask(SIG_UNBLOCK, &set, NULL)); + } + ASSERT(SIG_ERR != signal(SIGTERM, SIG_DFL)); +#endif + /* Sending signum == 0 should check if the * child process is still alive, not kill it. */ diff --git a/deps/uv/test/test-udp-try-send.c b/deps/uv/test/test-udp-try-send.c index 7b6de365487274..a31d3822955632 100644 --- a/deps/uv/test/test-udp-try-send.c +++ b/deps/uv/test/test-udp-try-send.c @@ -26,16 +26,6 @@ #include #include -#ifdef _WIN32 - -TEST_IMPL(udp_try_send) { - - MAKE_VALGRIND_HAPPY(); - return 0; -} - -#else /* !_WIN32 */ - #define CHECK_HANDLE(handle) \ ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) @@ -129,5 +119,3 @@ TEST_IMPL(udp_try_send) { MAKE_VALGRIND_HAPPY(); return 0; } - -#endif /* !_WIN32 */ diff --git a/deps/uv/tools/vswhere_usability_wrapper.cmd b/deps/uv/tools/vswhere_usability_wrapper.cmd new file mode 100644 index 00000000000000..e4acf03e1ee952 --- /dev/null +++ b/deps/uv/tools/vswhere_usability_wrapper.cmd @@ -0,0 +1,33 @@ +:: Copyright 2017 - Refael Ackermann +:: Distributed under MIT style license or the libuv license +:: See accompanying file LICENSE at https://github.com/node4good/windows-autoconf +:: or libuv LICENSE file at https://github.com/libuv/libuv +:: version: 1.15.3 + +@if not defined DEBUG_HELPER @ECHO OFF +setlocal +set "InstallerPath=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" +if not exist "%InstallerPath%" set "InstallerPath=%ProgramFiles%\Microsoft Visual Studio\Installer" +if not exist "%InstallerPath%" exit goto :no-vswhere +:: Manipulate %Path% for easier " handeling +set Path=%Path%;%InstallerPath% +where vswhere 2> nul > nul +if errorlevel 1 goto :no-vswhere +set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 +set VSWHERE_PRP=-property installationPath +set VSWHERE_LMT=-version "[15.0,16.0)" +vswhere -prerelease > nul +if "%~1"=="prerelase" set VSWHERE_WITH_PRERELASE=1 +if not errorlevel 1 if "%VSWHERE_WITH_PRERELASE%"=="1" set "VSWHERE_LMT=%VSWHERE_LMT% -prerelease" +SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT% +for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( + endlocal + set "VCINSTALLDIR=%%i\VC\" + set "VS150COMNTOOLS=%%i\Common7\Tools\" + exit /B 0 +) + +:no-vswhere +endlocal +echo could not find "vswhere" +exit /B 1 \ No newline at end of file diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index a3a42787b37b78..6f61d725a90b99 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -253,7 +253,7 @@ 'src/unix/linux-syscalls.h', 'src/unix/pthread-fixes.c', 'src/unix/android-ifaddrs.c', - 'src/unix/pthread-barrier.c' + 'src/unix/pthread-barrier.c', 'src/unix/procfs-exepath.c', 'src/unix/sysinfo-loadavg.c', 'src/unix/sysinfo-memory.c', @@ -302,12 +302,12 @@ 'sources': [ 'src/unix/openbsd.c' ], }], [ 'OS=="netbsd"', { - 'sources': [ 'src/unix/netbsd.c' ], - }], - [ 'OS in "freebsd dragonflybsd openbsd netbsd".split()', { 'link_settings': { 'libraries': [ '-lkvm' ], }, + 'sources': [ 'src/unix/netbsd.c' ], + }], + [ 'OS in "freebsd dragonflybsd openbsd netbsd".split()', { 'sources': [ 'src/unix/posix-hrtime.c' ], }], [ 'OS in "ios mac freebsd dragonflybsd openbsd netbsd".split()', { diff --git a/deps/uv/vcbuild.bat b/deps/uv/vcbuild.bat index 91f45b72195301..e33573d108e16f 100644 --- a/deps/uv/vcbuild.bat +++ b/deps/uv/vcbuild.bat @@ -14,10 +14,11 @@ if /i "%1"=="/?" goto help @rem Process arguments. set config= set target=Build +set target_arch=ia32 +set target_env= set noprojgen= set nobuild= set run= -set target_arch=ia32 set vs_toolset=x86 set msbuild_platform=WIN32 set library=static_library @@ -29,6 +30,7 @@ if /i "%1"=="release" set config=Release&goto arg-ok if /i "%1"=="test" set run=run-tests.exe&goto arg-ok if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok if /i "%1"=="clean" set target=Clean&goto arg-ok +if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok if /i "%1"=="x86" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok @@ -41,10 +43,28 @@ shift goto next-arg :args-done -if defined WindowsSDKDir goto select-target -if defined VCINSTALLDIR goto select-target +@rem Look for Visual Studio 2017 only if explicitly requested. +if "%target_env%" NEQ "vs2017" goto vs-set-2015 +echo Looking for Visual Studio 2017 +@rem Check if VS2017 is already setup, and for the requested arch. +if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%vs_toolset%_" goto found_vs2017 +set "VSINSTALLDIR=" +call tools\vswhere_usability_wrapper.cmd +if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015 +@rem Need to clear VSINSTALLDIR for vcvarsall to work as expected. +set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vs_toolset% +echo calling: %vcvars_call% +call %vcvars_call% + +:found_vs2017 +echo Found MSVS version %VisualStudioVersion% +if %VSCMD_ARG_TGT_ARCH%==x64 set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64 +set GYP_MSVS_VERSION=2017 +goto select-target + @rem Look for Visual Studio 2015 +:vs-set-2015 if not defined VS140COMNTOOLS goto vc-set-2013 if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2013 call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% @@ -148,7 +168,9 @@ echo Failed to create vc project files. exit /b 1 :help -echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared] + +echo "vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared]" + echo Examples: echo vcbuild.bat : builds debug build echo vcbuild.bat test : builds debug build and runs tests