aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/binding.gyp.template121
-rw-r--r--templates/package.json.template2
2 files changed, 93 insertions, 30 deletions
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template
index e6592acebb..9b9e4e116d 100644
--- a/templates/binding.gyp.template
+++ b/templates/binding.gyp.template
@@ -39,18 +39,64 @@
# 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'
+ ]
+ }],
+ # This is the condition for using boringssl
+ ['OS=="win" or runtime=="electron"', {
+ "include_dirs": [
+ "third_party/boringssl/include"
+ ],
+ "defines": [
+ 'OPENSSL_NO_ASM',
+ 'OPENSSL_NO_THREADS'
+ ]
+ }, {
+ # 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": [
@@ -60,8 +106,6 @@
'UNICODE',
'_UNICODE',
'NOMINMAX',
- 'OPENSSL_NO_ASM',
- 'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
"msvs_settings": {
'VCCLCompilerTool': {
@@ -74,21 +118,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': [
@@ -103,21 +134,42 @@
'-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" or runtime=="electron"', {
+ 'targets': [
+ % for module in node_modules:
+ % for lib in libs:
+ % if lib.name in module.transitive_deps and lib.name == 'boringssl':
+ {
+ 'cflags': [
+ '-std=c99',
+ '-Wall',
+ '-Werror'
+ ],
+ 'target_name': '${lib.name}',
+ 'product_prefix': 'lib',
+ 'type': 'static_library',
+ 'dependencies': [
+ % for dep in getattr(lib, 'deps', []):
+ '${dep}',
+ % endfor
+ ],
+ 'sources': [
+ % for source in lib.src:
+ '${source}',
+ % endfor
+ ]
+ },
+ % endif
+ % endfor
+ % endfor
+ ]
+ }],
['OS == "win"', {
'targets': [
{
@@ -143,10 +195,10 @@
}
]
},
- # Only want to compile BoringSSL and zlib under Windows
+ # Only want to compile zlib under Windows
% for module in node_modules:
% for lib in libs:
- % if lib.name in module.transitive_deps and lib.name in ('boringssl', 'z'):
+ % if lib.name in module.transitive_deps and lib.name == 'z':
{
'cflags': [
'-std=c99',
@@ -223,6 +275,15 @@
'-g'
],
"conditions": [
+ ['OS=="win" or runtime=="electron"', {
+ 'dependencies': [
+ % for dep in getattr(module, 'deps', []):
+ % if dep == 'boringssl':
+ "${dep}",
+ % endif
+ % endfor
+ ]
+ }],
['OS=="mac"', {
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.9',
@@ -235,7 +296,7 @@
['OS=="win"', {
'dependencies': [
% for dep in getattr(module, 'deps', []):
- % if dep in ('boringssl', 'z'):
+ % if dep == 'z':
"${dep}",
% endif
% endfor
diff --git a/templates/package.json.template b/templates/package.json.template
index 81f39d27f5..a4eb6209ad 100644
--- a/templates/package.json.template
+++ b/templates/package.json.template
@@ -23,6 +23,7 @@
"scripts": {
"lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore",
"test": "./node_modules/.bin/mocha src/node/test && npm run-script lint",
+ "electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
"gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build"
@@ -40,6 +41,7 @@
"devDependencies": {
"async": "^2.0.1",
"body-parser": "^1.15.2",
+ "electron-mocha": "^3.1.1",
"express": "^4.14.0",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",