aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-01-29 14:11:06 -0800
committerGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-01-29 14:11:06 -0800
commit1c686e8b25726aa42875ecd3b790151f05f275c7 (patch)
tree7937bd01872a48e40d7a1ad246a98b05cb615fce
parent86d8f5ca71ec176682281f63421852f0c16ebe91 (diff)
parent8e4103e7d005b5f279e5769c05c6d7a7e23896a9 (diff)
Merge pull request #4952 from murgatroid99/node_windows_compile
Compile Node library on Windows
-rw-r--r--.gitignore4
-rw-r--r--binding.gyp77
-rw-r--r--src/node/ext/node_grpc.cc4
-rw-r--r--templates/binding.gyp.template74
4 files changed, 119 insertions, 40 deletions
diff --git a/.gitignore b/.gitignore
index 66c546eb58..8d5b7fee4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,10 @@ htmlcov/
dist/
*.egg
+# Node installation output
+node_modules/
+src/node/extension_binary/
+
# gcov coverage data
reports
coverage
diff --git a/binding.gyp b/binding.gyp
index b1c0214d5f..651c2e13af 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -37,29 +37,45 @@
# Some of this file is built with the help of
# https://n8.io/converting-a-c-library-to-gyp/
{
- 'variables': {
- 'config': '<!(echo $CONFIG)'
- },
- # TODO: Finish windows support
'target_defaults': {
- # Empirically, Node only exports ALPN symbols if its major version is >0.
- # io.js always reports versions >0 and always exports ALPN symbols.
- # Therefore, Node's major version will be truthy if and only if it
- # supports ALPN. The output of "node -v" is v[major].[minor].[patch],
- # like "v4.1.1" in a recent version. We use cut to split by period and
- # take the first field (resulting in "v[major]"), then use cut again
- # to take all but the first character, removing the "v".
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=<!(node --version | cut -d. -f1 | cut -c2-)'
- ],
'include_dirs': [
'.',
'include'
],
'conditions': [
['OS == "win"', {
- "include_dirs": [ "third_party/boringssl/include" ]
- }, {
+ "include_dirs": [ "third_party/boringssl/include" ],
+ "defines": [
+ '_WIN32_WINNT=0x0600',
+ 'WIN32_LEAN_AND_MEAN',
+ '_HAS_EXCEPTIONS=0',
+ 'UNICODE',
+ '_UNICODE',
+ 'NOMINMAX',
+ 'OPENSSL_NO_ASM'
+ ],
+ "msvs_settings": {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary': 1, # static debug
+ }
+ },
+ "libraries": [
+ "ws2_32"
+ ]
+ }, { # OS != "win"
+ # Empirically, Node only exports ALPN symbols if its major version is >0.
+ # io.js always reports versions >0 and always exports ALPN symbols.
+ # Therefore, Node's major version will be truthy if and only if it
+ # supports ALPN. The output of "node -v" is v[major].[minor].[patch],
+ # like "v4.1.1" in a recent version. We use cut to split by period and
+ # take the first field (resulting in "v[major]"), then use cut again
+ # to take all but the first character, removing the "v".
+ 'defines': [
+ 'TSI_OPENSSL_ALPN_SUPPORT=<!(node --version | cut -d. -f1 | cut -c2-)'
+ ],
+ 'variables': {
+ 'config': '<!(echo $CONFIG)'
+ },
'include_dirs': [
'<(node_root_dir)/deps/openssl/openssl/include',
'<(node_root_dir)/deps/zlib'
@@ -93,6 +109,29 @@
'conditions': [
['OS == "win"', {
'targets': [
+ {
+ # IMPORTANT WINDOWS BUILD INFORMATION
+ # This library does not build on Windows without modifying the Node
+ # development packages that node-gyp downloads in order to build.
+ # Due to https://github.com/nodejs/node/issues/4932, the headers for
+ # BoringSSL conflict with the OpenSSL headers included by default
+ # when including the Node headers. The remedy for this is to remove
+ # the OpenSSL headers, from the downloaded Node development package,
+ # which is typically located in `.node-gyp` in your home directory.
+ 'target_name': 'WINDOWS_BUILD_WARNING',
+ 'actions': [
+ {
+ 'action_name': 'WINDOWS_BUILD_WARNING',
+ 'inputs': [
+ 'package.json'
+ ],
+ 'outputs': [
+ 'ignore_this_part'
+ ],
+ 'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
+ }
+ ]
+ },
# Only want to compile BoringSSL and zlib under Windows
{
'cflags': [
@@ -400,8 +439,7 @@
'third_party/boringssl/ssl/t1_enc.c',
'third_party/boringssl/ssl/t1_lib.c',
'third_party/boringssl/ssl/tls_record.c',
- ],
- "include_dirs": [ "third_party/boringssl/include" ]
+ ]
},
{
'cflags': [
@@ -430,8 +468,7 @@
'third_party/zlib/trees.c',
'third_party/zlib/uncompr.c',
'third_party/zlib/zutil.c',
- ],
- "include_dirs": [ "third_party/boringssl/include" ]
+ ]
},
]
}]
diff --git a/src/node/ext/node_grpc.cc b/src/node/ext/node_grpc.cc
index a2b8e0d22b..654c5aed09 100644
--- a/src/node/ext/node_grpc.cc
+++ b/src/node/ext/node_grpc.cc
@@ -112,8 +112,8 @@ void InitCallErrorConstants(Local<Object> exports) {
Nan::Set(exports, Nan::New("callError").ToLocalChecked(), call_error);
Local<Value> OK(Nan::New<Uint32, uint32_t>(GRPC_CALL_OK));
Nan::Set(call_error, Nan::New("OK").ToLocalChecked(), OK);
- Local<Value> ERROR(Nan::New<Uint32, uint32_t>(GRPC_CALL_ERROR));
- Nan::Set(call_error, Nan::New("ERROR").ToLocalChecked(), ERROR);
+ Local<Value> CALL_ERROR(Nan::New<Uint32, uint32_t>(GRPC_CALL_ERROR));
+ Nan::Set(call_error, Nan::New("ERROR").ToLocalChecked(), CALL_ERROR);
Local<Value> NOT_ON_SERVER(
Nan::New<Uint32, uint32_t>(GRPC_CALL_ERROR_NOT_ON_SERVER));
Nan::Set(call_error, Nan::New("NOT_ON_SERVER").ToLocalChecked(),
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template
index 71276e75e5..a913585240 100644
--- a/templates/binding.gyp.template
+++ b/templates/binding.gyp.template
@@ -39,29 +39,45 @@
# Some of this file is built with the help of
# https://n8.io/converting-a-c-library-to-gyp/
{
- 'variables': {
- 'config': '<!(echo $CONFIG)'
- },
- # TODO: Finish windows support
'target_defaults': {
- # Empirically, Node only exports ALPN symbols if its major version is >0.
- # io.js always reports versions >0 and always exports ALPN symbols.
- # Therefore, Node's major version will be truthy if and only if it
- # supports ALPN. The output of "node -v" is v[major].[minor].[patch],
- # like "v4.1.1" in a recent version. We use cut to split by period and
- # take the first field (resulting in "v[major]"), then use cut again
- # to take all but the first character, removing the "v".
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=<!(node --version | cut -d. -f1 | cut -c2-)'
- ],
'include_dirs': [
'.',
'include'
],
'conditions': [
['OS == "win"', {
- "include_dirs": [ "third_party/boringssl/include" ]
- }, {
+ "include_dirs": [ "third_party/boringssl/include" ],
+ "defines": [
+ '_WIN32_WINNT=0x0600',
+ 'WIN32_LEAN_AND_MEAN',
+ '_HAS_EXCEPTIONS=0',
+ 'UNICODE',
+ '_UNICODE',
+ 'NOMINMAX',
+ 'OPENSSL_NO_ASM'
+ ],
+ "msvs_settings": {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary': 1, # static debug
+ }
+ },
+ "libraries": [
+ "ws2_32"
+ ]
+ }, { # OS != "win"
+ # Empirically, Node only exports ALPN symbols if its major version is >0.
+ # io.js always reports versions >0 and always exports ALPN symbols.
+ # Therefore, Node's major version will be truthy if and only if it
+ # supports ALPN. The output of "node -v" is v[major].[minor].[patch],
+ # like "v4.1.1" in a recent version. We use cut to split by period and
+ # take the first field (resulting in "v[major]"), then use cut again
+ # to take all but the first character, removing the "v".
+ 'defines': [
+ 'TSI_OPENSSL_ALPN_SUPPORT=<!(node --version | cut -d. -f1 | cut -c2-)'
+ ],
+ 'variables': {
+ 'config': '<!(echo $CONFIG)'
+ },
'include_dirs': [
'<(node_root_dir)/deps/openssl/openssl/include',
'<(node_root_dir)/deps/zlib'
@@ -95,6 +111,29 @@
'conditions': [
['OS == "win"', {
'targets': [
+ {
+ # IMPORTANT WINDOWS BUILD INFORMATION
+ # This library does not build on Windows without modifying the Node
+ # development packages that node-gyp downloads in order to build.
+ # Due to https://github.com/nodejs/node/issues/4932, the headers for
+ # BoringSSL conflict with the OpenSSL headers included by default
+ # when including the Node headers. The remedy for this is to remove
+ # the OpenSSL headers, from the downloaded Node development package,
+ # which is typically located in `.node-gyp` in your home directory.
+ 'target_name': 'WINDOWS_BUILD_WARNING',
+ 'actions': [
+ {
+ 'action_name': 'WINDOWS_BUILD_WARNING',
+ 'inputs': [
+ 'package.json'
+ ],
+ 'outputs': [
+ 'ignore_this_part'
+ ],
+ 'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
+ }
+ ]
+ },
# Only want to compile BoringSSL and zlib under Windows
% for module in node_modules:
% for lib in libs:
@@ -117,8 +156,7 @@
% for source in lib.src:
'${source}',
% endfor
- ],
- "include_dirs": [ "third_party/boringssl/include" ]
+ ]
},
% endif
% endfor