diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/binding.gyp.template | 125 | ||||
-rw-r--r-- | templates/package.json.template | 2 | ||||
-rw-r--r-- | templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template | 15 |
3 files changed, 110 insertions, 32 deletions
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template index e6592acebb..851effc4f3 100644 --- a/templates/binding.gyp.template +++ b/templates/binding.gyp.template @@ -39,18 +39,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' + ] + }], + ['OS!="win" and 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": [ @@ -60,8 +110,6 @@ 'UNICODE', '_UNICODE', 'NOMINMAX', - 'OPENSSL_NO_ASM', - 'GPR_BACKWARDS_COMPATIBILITY_MODE' ], "msvs_settings": { 'VCCLCompilerTool': { @@ -74,21 +122,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 +138,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 +199,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 +279,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 +300,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 eb85c06590..316c28e478 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", diff --git a/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template b/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template index 72b098f0c2..ceaa9aa5ab 100644 --- a/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template @@ -28,10 +28,21 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + FROM debian:jessie - + <%include file="../../apt_get_basic.include"/> + + # Install Electron apt dependencies + RUN apt-get update && apt-get install -y ${'\\'} + libasound2 ${'\\'} + libgconf-2-4 ${'\\'} + libgtk2.0-0 ${'\\'} + libnss3 ${'\\'} + libxss1 ${'\\'} + libxtst6 ${'\\'} + xvfb + <%include file="../../python_deps.include"/> <%include file="../../node_deps.include"/> <%include file="../../run_tests_addons.include"/> |