Files
MINGW-packages/mingw-w64-nodejs/0002-node_mingw64.patch

250 lines
8.6 KiB
Diff

diff -urN node-v0.10.29.orig/deps/cares/cares.gyp node-v0.10.29/deps/cares/cares.gyp
--- node-v0.10.29.orig/deps/cares/cares.gyp 2014-07-21 01:06:32.674976600 +0100
+++ node-v0.10.29/deps/cares/cares.gyp 2014-07-21 01:06:49.665634100 +0100
@@ -114,8 +114,8 @@
'src/ares_platform.c'
],
'libraries': [
- '-lws2_32.lib',
- '-liphlpapi.lib'
+ '-lws2_32',
+ '-liphlpapi'
],
}, {
# Not Windows i.e. POSIX
diff -urN node-v0.10.29.orig/deps/openssl/openssl.gyp node-v0.10.29/deps/openssl/openssl.gyp
--- node-v0.10.29.orig/deps/openssl/openssl.gyp 2014-07-21 01:06:41.120549000 +0100
+++ node-v0.10.29/deps/openssl/openssl.gyp 2014-07-21 01:06:49.800151200 +0100
@@ -941,8 +941,8 @@
],
'link_settings': {
'libraries': [
- '-lgdi32.lib',
- '-luser32.lib',
+ '-lgdi32',
+ '-luser32',
]
}
}, {
diff -urN node-v0.10.29.orig/deps/uv/include/uv-private/uv-win.h node-v0.10.29/deps/uv/include/uv-private/uv-win.h
--- node-v0.10.29.orig/deps/uv/include/uv-private/uv-win.h 2014-07-21 01:06:41.141551700 +0100
+++ node-v0.10.29/deps/uv/include/uv-private/uv-win.h 2014-07-21 01:06:49.809652400 +0100
@@ -34,6 +34,11 @@
#include <ws2tcpip.h>
#include <windows.h>
+#ifdef __MINGW64_VERSION_MAJOR
+typedef PVOID RTL_SRWLOCK;
+typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
+#endif
+
#include <process.h>
#include <signal.h>
#include <sys/stat.h>
diff -urN node-v0.10.29.orig/deps/uv/src/win/core.c node-v0.10.29/deps/uv/src/win/core.c
--- node-v0.10.29.orig/deps/uv/src/win/core.c 2014-07-21 01:06:41.184557200 +0100
+++ node-v0.10.29/deps/uv/src/win/core.c 2014-07-21 01:06:49.812152700 +0100
@@ -55,7 +55,7 @@
/* Tell the CRT to not exit the application when an invalid parameter is */
/* passed. The main issue is that invalid FDs will trigger this behavior. */
-#if !defined(__MINGW32__) || __MSVCRT_VERSION__ >= 0x800
+#if !defined(__MINGW32__) || (defined (_MSC_VER) && __MSVCRT_VERSION__ >= 0x800)
_set_invalid_parameter_handler(uv__crt_invalid_parameter_handler);
#endif
diff -urN node-v0.10.29.orig/deps/uv/src/win/pipe.c node-v0.10.29/deps/uv/src/win/pipe.c
--- node-v0.10.29.orig/deps/uv/src/win/pipe.c 2014-07-21 01:06:41.194058400 +0100
+++ node-v0.10.29/deps/uv/src/win/pipe.c 2014-07-21 01:06:49.813652900 +0100
@@ -30,6 +30,9 @@
#include "stream-inl.h"
#include "req-inl.h"
+#ifndef FILE_FLAG_FIRST_PIPE_INSTANCE
+#define FILE_FLAG_FIRST_PIPE_INSTANCE 524288
+#endif
/* A zero-size buffer for use by uv_pipe_read */
static char uv_zero_[] = "";
diff -urN node-v0.10.29.orig/deps/uv/src/win/process.c node-v0.10.29/deps/uv/src/win/process.c
--- node-v0.10.29.orig/deps/uv/src/win/process.c 2014-07-21 01:06:41.196558700 +0100
+++ node-v0.10.29/deps/uv/src/win/process.c 2014-07-21 01:06:49.817653400 +0100
@@ -30,6 +30,9 @@
#include "handle-inl.h"
#include "req-inl.h"
+#ifndef JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
+#define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x2000
+#endif
#define SIGKILL 9
diff -urN node-v0.10.29.orig/deps/uv/uv.gyp node-v0.10.29/deps/uv/uv.gyp
--- node-v0.10.29.orig/deps/uv/uv.gyp 2014-07-21 01:06:41.286070000 +0100
+++ node-v0.10.29/deps/uv/uv.gyp 2014-07-21 01:06:49.834655600 +0100
@@ -110,11 +110,11 @@
],
'link_settings': {
'libraries': [
- '-ladvapi32.lib',
- '-liphlpapi.lib',
- '-lpsapi.lib',
- '-lshell32.lib',
- '-lws2_32.lib'
+ '-ladvapi32',
+ '-liphlpapi',
+ '-lpsapi',
+ '-lshell32',
+ '-lws2_32'
],
},
}, { # Not Windows i.e. POSIX
@@ -376,7 +376,7 @@
'test/runner-win.c',
'test/runner-win.h'
],
- 'libraries': [ 'ws2_32.lib' ]
+ 'libraries': [ 'ws2_32' ]
}, { # POSIX
'defines': [ '_GNU_SOURCE' ],
'sources': [
@@ -440,7 +440,7 @@
'test/runner-win.c',
'test/runner-win.h',
],
- 'libraries': [ 'ws2_32.lib' ]
+ 'libraries': [ 'ws2_32' ]
}, { # POSIX
'defines': [ '_GNU_SOURCE' ],
'sources': [
diff -urN node-v0.10.29.orig/deps/v8/tools/gyp/v8.gyp node-v0.10.29/deps/v8/tools/gyp/v8.gyp
--- node-v0.10.29.orig/deps/v8/tools/gyp/v8.gyp 2014-07-21 01:06:42.441216700 +0100
+++ node-v0.10.29/deps/v8/tools/gyp/v8.gyp 2014-07-21 01:06:50.006177400 +0100
@@ -737,7 +737,7 @@
],
'msvs_disabled_warnings': [4351, 4355, 4800],
'link_settings': {
- 'libraries': [ '-lwinmm.lib', '-lws2_32.lib' ],
+ 'libraries': [ '-lwinmm', '-lws2_32' ],
},
}],
['component=="shared_library"', {
diff -urN node-v0.10.29.orig/lib/path.js node-v0.10.29/lib/path.js
--- node-v0.10.29.orig/lib/path.js 2014-07-21 01:06:42.685247700 +0100
+++ node-v0.10.29/lib/path.js 2014-07-21 01:06:50.009177700 +0100
@@ -466,6 +466,8 @@
return '';
}
+ if (path.indexOf('/') == 0) path = mingwToWindowsPath(path);
+
var resolvedPath = exports.resolve(path);
if (/^[a-zA-Z]\:\\/.test(resolvedPath)) {
@@ -485,3 +487,56 @@
return path;
};
}
+
+var mingwMounts = [], mingwGotMounts = false;
+function mingwGetMounts() {
+ if (mingwGotMounts) return mingwMounts;
+ var spawn = require('child_process').spawn;
+ var fs = require('fs');
+ var os = require('os');
+ var tmp = os.tmpdir() + '/node-mount.tmp';
+ var fd = fs.openSync(tmp, 'w+');
+ var mount = spawn('sh', ['-c', 'mount; echo "EOF"'], {
+ 'stdio': ['ignore', fd, 'ignore']
+ });
+ var eof = os.EOL + 'EOF' + os.EOL;
+ var buflen = 4096;
+ var buf = new Buffer (buflen);
+ do {
+ var bytes = fs.readSync(fd, buf, 0, buflen, 0);
+ if (bytes >= buflen) {
+ console.error('mount overran the buffer');
+ mingwGotMounts = true;
+ return mingwMounts;
+ }
+ } while (buf.slice(bytes - eof.length, bytes).toString() != eof);
+ fs.closeSync(fd);
+ var lines = buf.slice(0, bytes).toString().split(os.EOL);
+ var splitLineRe = /^(.+) on (.+) type /;
+ for (var i = 0; i < lines.length; i++) {
+ var match = splitLineRe.exec(lines[i]);
+ if (! match) continue;
+ mingwMounts.push([match[1], match[2]]);
+ }
+ mingwMounts.sort(function(a, b) {
+ var cmp = b[1].length - a[1].length;
+ if (cmp) return cmp;
+ else return a[1] > b[1];
+ });
+ mingwGotMounts = true;
+ return mingwMounts;
+}
+function mingwToWindowsPath(path) {
+ var mounts = mingwGetMounts();
+ for (var i = 0; i < mounts.length; i++) {
+ var to = mounts[i][0], from = mounts[i][1];
+ from = from.replace(/\/$/, '');
+ var re = new RegExp('^' + from + '(.*)$');
+ var match = re.exec(path);
+ if (match && (match[1].length == 0 || match[1][0] == '/')) {
+ return to + match[1];
+ }
+ }
+ console.error(path + ' not found in mount');
+ return path;
+}
diff -urN node-v0.10.29.orig/node.gyp node-v0.10.29/node.gyp
--- node-v0.10.29.orig/node.gyp 2014-07-21 01:06:42.699249500 +0100
+++ node-v0.10.29/node.gyp 2014-07-21 01:06:50.104689900 +0100
@@ -257,7 +257,7 @@
'PLATFORM="win32"',
'_UNICODE=1',
],
- 'libraries': [ '-lpsapi.lib' ]
+ 'libraries': [ '-municode', '-lpsapi' ]
}, { # POSIX
'defines': [ '__POSIX__' ],
}],
diff -urN node-v0.10.29.orig/src/node_internals.h node-v0.10.29/src/node_internals.h
--- node-v0.10.29.orig/src/node_internals.h 2014-07-21 01:06:42.730253400 +0100
+++ node-v0.10.29/src/node_internals.h 2014-07-21 01:06:50.013178200 +0100
@@ -34,7 +34,7 @@
// Defined in node.cc at startup.
extern v8::Persistent<v8::Object> process;
-#ifdef _WIN32
+#ifdef _MSC_VER
// emulate snprintf() on windows, _snprintf() doesn't zero-terminate the buffer
// on overflow...
#include <stdarg.h>
diff -urN node-v0.10.29.orig/src/node_main.cc node-v0.10.29/src/node_main.cc
--- node-v0.10.29.orig/src/node_main.cc 2014-07-21 01:06:42.730753500 +0100
+++ node-v0.10.29/src/node_main.cc 2014-07-21 01:06:50.036681200 +0100
@@ -21,7 +21,10 @@
#include "node.h"
-#ifdef _WIN32
+#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
+#if defined (__cplusplus) && defined(__MINGW64_VERSION_MAJOR)
+extern "C" {
+#endif
int wmain(int argc, wchar_t *wargv[]) {
// Convert argv to to UTF8
char** argv = new char*[argc];
@@ -59,6 +62,9 @@
// Now that conversion is done, we can finally start.
return node::Start(argc, argv);
}
+#if defined (__cplusplus) && defined(__MINGW64_VERSION_MAJOR)
+}
+#endif
#else
// UNIX
int main(int argc, char *argv[]) {