diff options
Diffstat (limited to 'binding.gyp')
-rw-r--r-- | binding.gyp | 144 |
1 files changed, 89 insertions, 55 deletions
diff --git a/binding.gyp b/binding.gyp index 3a80402c06..fd48da875a 100644 --- a/binding.gyp +++ b/binding.gyp @@ -37,18 +37,68 @@ # Some of this file is built with the help of # https://n8.io/converting-a-c-library-to-gyp/ { + 'variables': { + 'runtime%': 'node' + }, 'target_defaults': { 'include_dirs': [ '.', 'include' ], 'defines': [ - 'GRPC_UV' + 'GPR_BACKWARDS_COMPATIBILITY_MODE' ], 'conditions': [ + ['runtime=="node"', { + 'defines': [ + 'GRPC_UV' + ] + }], + ['runtime=="electron"', { + "defines": [ + 'OPENSSL_NO_THREADS' + ] + }], + # This is the condition for using boringssl + ['OS=="win" or runtime=="electron"', { + "include_dirs": [ + "third_party/boringssl/include" + ], + "defines": [ + 'OPENSSL_NO_ASM' + ] + }, { + # Based on logic above, we know that this must be a non-Windows system + 'variables': { + # The output of "node --version" is "v[version]". We use cut to + # remove the first character. + 'target%': '<!(node --version | cut -c2-)' + }, + # 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 target is "[major].[minor].[patch]". We split by + # periods and take the first field to get the major version. + 'defines': [ + 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)' + ], + 'include_dirs': [ + '<(node_root_dir)/deps/openssl/openssl/include', + ], + 'conditions': [ + ["target_arch=='ia32'", { + "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ] + }], + ["target_arch=='x64'", { + "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ] + }], + ["target_arch=='arm'", { + "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ] + }] + ] + }], ['OS == "win"', { "include_dirs": [ - "third_party/boringssl/include", "third_party/zlib" ], "defines": [ @@ -58,8 +108,6 @@ 'UNICODE', '_UNICODE', 'NOMINMAX', - 'OPENSSL_NO_ASM', - 'GPR_BACKWARDS_COMPATIBILITY_MODE' ], "msvs_settings": { 'VCCLCompilerTool': { @@ -72,21 +120,8 @@ }, { # OS != "win" 'variables': { 'config': '<!(echo $CONFIG)', - # The output of "node --version" is "v[version]". We use cut to - # remove the first character. - 'target%': '<!(node --version | cut -c2-)' }, - # 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 target is "[major].[minor].[patch]". We split by - # periods and take the first field to get the major version. - 'defines': [ - 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)', - 'GPR_BACKWARDS_COMPATIBILITY_MODE' - ], 'include_dirs': [ - '<(node_root_dir)/deps/openssl/openssl/include', '<(node_root_dir)/deps/zlib' ], 'conditions': [ @@ -101,48 +136,15 @@ '-fprofile-arcs' ] } - ], - ["target_arch=='ia32'", { - "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ] - }], - ["target_arch=='x64'", { - "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ] - }], - ["target_arch=='arm'", { - "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ] - }] + ] ] }] ] }, 'conditions': [ - ['OS == "win"', { + ['OS=="win" or runtime=="electron"', { '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': [ '-std=c99', '-Wall', @@ -453,6 +455,34 @@ 'third_party/boringssl/ssl/tls_record.c', ] }, + ] + }], + ['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 zlib under Windows { 'cflags': [ '-std=c99', @@ -807,6 +837,11 @@ '-g' ], "conditions": [ + ['OS=="win" or runtime=="electron"', { + 'dependencies': [ + "boringssl", + ] + }], ['OS=="mac"', { 'xcode_settings': { 'MACOSX_DEPLOYMENT_TARGET': '10.9', @@ -818,7 +853,6 @@ }], ['OS=="win"', { 'dependencies': [ - "boringssl", "z", ] }], @@ -835,8 +869,8 @@ "src/node/ext/call_credentials.cc", "src/node/ext/channel.cc", "src/node/ext/channel_credentials.cc", - "src/node/ext/completion_queue.cc", - "src/node/ext/completion_queue_async_worker.cc", + "src/node/ext/completion_queue_threadpool.cc", + "src/node/ext/completion_queue_uv.cc", "src/node/ext/node_grpc.cc", "src/node/ext/server.cc", "src/node/ext/server_credentials.cc", |