From 7905a72eace4760f3c8792bd2b8f9efbd7c686b5 Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Fri, 15 Jan 2016 15:28:22 -0800 Subject: [PATCH 1/8] Added node-pre-gyp stuff to package.json --- package.json | 12 +++++++++++- templates/package.json.template | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e0bbb7d80ff..f174231b140 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,15 @@ "lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js", "test": "./node_modules/.bin/mocha src/node/test && npm run-script lint", "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" + "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test", + "preinstall": "npm install node-pre-gyp", + "install": "node -e \"require('node-pre-gyp').install()\"" }, "dependencies": { "bindings": "^1.2.0", "lodash": "^3.9.3", "nan": "^2.0.0", + "node-pre-gyp": "^0.6.19", "protobufjs": "^4.0.0" }, "devDependencies": { @@ -45,6 +48,13 @@ "engines": { "node": ">=0.10.13" }, + "binary": { + "module_name": "grpc_node", + "module_path": "./build/Release/", + "host": "https://x20web.corp.google.com/", + "remote_path": "~mlumish/node_grpc_bin/{name}/v{version}", + "package_name": "{node_abi}-{platform}-{arch}.tar.gz" + }, "files": [ "LICENSE", "src/node/README.md", diff --git a/templates/package.json.template b/templates/package.json.template index ec6827ef766..deb6b49ffd5 100644 --- a/templates/package.json.template +++ b/templates/package.json.template @@ -30,6 +30,7 @@ "bindings": "^1.2.0", "lodash": "^3.9.3", "nan": "^2.0.0", + "node-pre-gyp": "^0.6.19", "protobufjs": "^4.0.0" }, "devDependencies": { @@ -47,6 +48,11 @@ "engines": { "node": ">=0.10.13" }, + "binary": { + "module_name": "grpc_node", + "module_path": "./build/Release/", + "host": "localhost" + }, "files": [ "LICENSE", "src/node/README.md", From 31de1450a63e7b6a1c806337b5b49f00f47c9a28 Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Fri, 15 Jan 2016 16:12:26 -0800 Subject: [PATCH 2/8] Change node-pre-gyp install command line --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f174231b140..cb9de26c29a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "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", "preinstall": "npm install node-pre-gyp", - "install": "node -e \"require('node-pre-gyp').install()\"" + "install": "./node_modules/.bin/node-pre-gyp install" }, "dependencies": { "bindings": "^1.2.0", From f1e9552ccf5c15b5b3275f6cc57427bc831e6cf0 Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Tue, 19 Jan 2016 10:42:06 -0800 Subject: [PATCH 3/8] Updated node-pre-gyp to use Google Cloud Storage --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cb9de26c29a..ffbcc06b0ea 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "binary": { "module_name": "grpc_node", "module_path": "./build/Release/", - "host": "https://x20web.corp.google.com/", - "remote_path": "~mlumish/node_grpc_bin/{name}/v{version}", + "host": "https://storage.googleapis.com/", + "remote_path": "tmp-mlumish/v{version}", "package_name": "{node_abi}-{platform}-{arch}.tar.gz" }, "files": [ From e190f35e66a6d1c2efa15d43551535402c96772a Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Wed, 20 Jan 2016 13:52:08 -0800 Subject: [PATCH 4/8] Completed integration of node-pre-gyp into Node library --- binding.gyp | 11 +++++++++ package.json | 8 +++---- src/node/index.js | 4 ++-- src/node/src/client.js | 4 ++-- src/node/src/credentials.js | 4 ++-- src/node/src/grpc_extension.js | 40 ++++++++++++++++++++++++++++++++ src/node/src/metadata.js | 2 +- src/node/src/server.js | 4 ++-- src/node/test/call_test.js | 4 ++-- src/node/test/channel_test.js | 4 ++-- src/node/test/constant_test.js | 4 ++-- src/node/test/end_to_end_test.js | 4 ++-- src/node/test/server_test.js | 4 ++-- templates/binding.gyp.template | 11 +++++++++ templates/package.json.template | 10 +++++--- 15 files changed, 92 insertions(+), 26 deletions(-) create mode 100644 src/node/src/grpc_extension.js diff --git a/binding.gyp b/binding.gyp index a5e993353c9..1ec7a67f655 100644 --- a/binding.gyp +++ b/binding.gyp @@ -366,5 +366,16 @@ "gpr", ] }, + { + "target_name": "action_after_build", + "type": "none", + "dependencies": [ "<(module_name)" ], + "copies": [ + { + "files": [ "<(PRODUCT_DIR)/<(module_name).node"], + "destination": "<(module_path)" + } + ] + } ] } diff --git a/package.json b/package.json index ffbcc06b0ea..f38178e6653 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,9 @@ "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", "preinstall": "npm install node-pre-gyp", - "install": "./node_modules/.bin/node-pre-gyp install" + "install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build" }, "dependencies": { - "bindings": "^1.2.0", "lodash": "^3.9.3", "nan": "^2.0.0", "node-pre-gyp": "^0.6.19", @@ -52,8 +51,9 @@ "module_name": "grpc_node", "module_path": "./build/Release/", "host": "https://storage.googleapis.com/", - "remote_path": "tmp-mlumish/v{version}", - "package_name": "{node_abi}-{platform}-{arch}.tar.gz" + "remote_path": "grpc-precompiled-binaries/{name}/v{version}", + "package_name": "{node_abi}-{platform}-{arch}.tar.gz", + "module_path": "src/node/extension_binary" }, "files": [ "LICENSE", diff --git a/src/node/index.js b/src/node/index.js index 0d1a7fd887b..7eacdc67b1d 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,7 +51,7 @@ var server = require('./src/server.js'); var Metadata = require('./src/metadata.js'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('./src/grpc_extension'); /** * Load a gRPC object from an existing ProtoBuf.Reflect object. diff --git a/src/node/src/client.js b/src/node/src/client.js index d57826781d3..b5247a69ee0 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,7 +51,7 @@ var _ = require('lodash'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('./grpc_extension'); var common = require('./common'); diff --git a/src/node/src/credentials.js b/src/node/src/credentials.js index dcbfac18f46..710ab6d879c 100644 --- a/src/node/src/credentials.js +++ b/src/node/src/credentials.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,7 +61,7 @@ 'use strict'; -var grpc = require('bindings')('grpc_node.node'); +var grpc = require('./grpc_extension'); var CallCredentials = grpc.CallCredentials; diff --git a/src/node/src/grpc_extension.js b/src/node/src/grpc_extension.js new file mode 100644 index 00000000000..d4eca65fcbf --- /dev/null +++ b/src/node/src/grpc_extension.js @@ -0,0 +1,40 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * 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. + * + */ + +var binary = require('node-pre-gyp'); +var path = require('path'); +var binding_path = binary.find(path.resolve( + path.join(__dirname,'../../../package.json'))); +var binding = require(binding_path); + +module.exports = binding; diff --git a/src/node/src/metadata.js b/src/node/src/metadata.js index fef79f959e4..51a9f8a2162 100644 --- a/src/node/src/metadata.js +++ b/src/node/src/metadata.js @@ -49,7 +49,7 @@ var _ = require('lodash'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('./grpc_extension'); /** * Class for storing metadata. Keys are normalized to lowercase ASCII. diff --git a/src/node/src/server.js b/src/node/src/server.js index ceaa9f5d1fc..e5aadcd5658 100644 --- a/src/node/src/server.js +++ b/src/node/src/server.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,7 +51,7 @@ var _ = require('lodash'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('./grpc_extension'); var common = require('./common'); diff --git a/src/node/test/call_test.js b/src/node/test/call_test.js index f1f86b35db3..2300096d03e 100644 --- a/src/node/test/call_test.js +++ b/src/node/test/call_test.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,7 +34,7 @@ 'use strict'; var assert = require('assert'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('../src/grpc_extension'); /** * Helper function to return an absolute deadline given a relative timeout in diff --git a/src/node/test/channel_test.js b/src/node/test/channel_test.js index 7163a5fb5ee..c0ae2b769a0 100644 --- a/src/node/test/channel_test.js +++ b/src/node/test/channel_test.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,7 +34,7 @@ 'use strict'; var assert = require('assert'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('../src/grpc_extension'); /** * This is used for testing functions with multiple asynchronous calls that diff --git a/src/node/test/constant_test.js b/src/node/test/constant_test.js index b17cd339cb0..712c70706d9 100644 --- a/src/node/test/constant_test.js +++ b/src/node/test/constant_test.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,7 +34,7 @@ 'use strict'; var assert = require('assert'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('../src/grpc_extension'); /** * List of all status names diff --git a/src/node/test/end_to_end_test.js b/src/node/test/end_to_end_test.js index 0f6c5941c4d..353c6c761de 100644 --- a/src/node/test/end_to_end_test.js +++ b/src/node/test/end_to_end_test.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,7 +34,7 @@ 'use strict'; var assert = require('assert'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('../src/grpc_extension'); /** * This is used for testing functions with multiple asynchronous calls that diff --git a/src/node/test/server_test.js b/src/node/test/server_test.js index 592f47e1456..71a96471844 100644 --- a/src/node/test/server_test.js +++ b/src/node/test/server_test.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,7 @@ var assert = require('assert'); var fs = require('fs'); var path = require('path'); -var grpc = require('bindings')('grpc_node'); +var grpc = require('../src/grpc_extension'); describe('server', function() { describe('constructor', function() { diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template index 8014ff3718c..ed59e72bf78 100644 --- a/templates/binding.gyp.template +++ b/templates/binding.gyp.template @@ -160,5 +160,16 @@ ] }, % endfor + { + "target_name": "action_after_build", + "type": "none", + "dependencies": [ "<(module_name)" ], + "copies": [ + { + "files": [ "<(PRODUCT_DIR)/<(module_name).node"], + "destination": "<(module_path)" + } + ] + } ] } diff --git a/templates/package.json.template b/templates/package.json.template index deb6b49ffd5..4b1906b10bd 100644 --- a/templates/package.json.template +++ b/templates/package.json.template @@ -24,10 +24,11 @@ "lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js", "test": "./node_modules/.bin/mocha src/node/test && npm run-script lint", "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" + "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test", + "preinstall": "npm install node-pre-gyp", + "install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build" }, "dependencies": { - "bindings": "^1.2.0", "lodash": "^3.9.3", "nan": "^2.0.0", "node-pre-gyp": "^0.6.19", @@ -51,7 +52,10 @@ "binary": { "module_name": "grpc_node", "module_path": "./build/Release/", - "host": "localhost" + "host": "https://storage.googleapis.com/", + "remote_path": "grpc-precompiled-binaries/{name}/v{version}", + "package_name": "{node_abi}-{platform}-{arch}.tar.gz", + "module_path": "src/node/extension_binary" }, "files": [ "LICENSE", From a3508e3bcf4208ac0f7c3148cc53e2c8c16c6638 Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Wed, 20 Jan 2016 13:58:24 -0800 Subject: [PATCH 5/8] Make sure that the binary URL includes the word Node --- package.json | 2 +- templates/package.json.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f38178e6653..4074bd6a2ec 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "module_name": "grpc_node", "module_path": "./build/Release/", "host": "https://storage.googleapis.com/", - "remote_path": "grpc-precompiled-binaries/{name}/v{version}", + "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}", "package_name": "{node_abi}-{platform}-{arch}.tar.gz", "module_path": "src/node/extension_binary" }, diff --git a/templates/package.json.template b/templates/package.json.template index 4b1906b10bd..ed4dca50e28 100644 --- a/templates/package.json.template +++ b/templates/package.json.template @@ -53,7 +53,7 @@ "module_name": "grpc_node", "module_path": "./build/Release/", "host": "https://storage.googleapis.com/", - "remote_path": "grpc-precompiled-binaries/{name}/v{version}", + "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}", "package_name": "{node_abi}-{platform}-{arch}.tar.gz", "module_path": "src/node/extension_binary" }, From fc32e62dbf4d9a2581468e79e338b3220ac870b5 Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Wed, 20 Jan 2016 13:59:12 -0800 Subject: [PATCH 6/8] Fix Node test lint error --- src/node/test/surface_test.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js index fc765ed7314..c65d95f7673 100644 --- a/src/node/test/surface_test.js +++ b/src/node/test/surface_test.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -952,6 +952,7 @@ describe('Call propagation', function() { describe('Cancellation', function() { it('With a unary call', function(done) { done = multiDone(done, 2); + var call; proxy_impl.unary = function(parent, callback) { client.unary(parent.request, function(err, value) { try { @@ -969,12 +970,13 @@ describe('Call propagation', function() { proxy.start(); var proxy_client = new Client('localhost:' + proxy_port, grpc.credentials.createInsecure()); - var call = proxy_client.unary({}, function(err, value) { + call = proxy_client.unary({}, function(err, value) { done(); }); }); it('With a client stream call', function(done) { done = multiDone(done, 2); + var call; proxy_impl.clientStream = function(parent, callback) { client.clientStream(function(err, value) { try { @@ -992,12 +994,13 @@ describe('Call propagation', function() { proxy.start(); var proxy_client = new Client('localhost:' + proxy_port, grpc.credentials.createInsecure()); - var call = proxy_client.clientStream(function(err, value) { + call = proxy_client.clientStream(function(err, value) { done(); }); }); it('With a server stream call', function(done) { done = multiDone(done, 2); + var call; proxy_impl.serverStream = function(parent) { var child = client.serverStream(parent.request, null, {parent: parent}); @@ -1013,13 +1016,14 @@ describe('Call propagation', function() { proxy.start(); var proxy_client = new Client('localhost:' + proxy_port, grpc.credentials.createInsecure()); - var call = proxy_client.serverStream({}); + call = proxy_client.serverStream({}); call.on('error', function(err) { done(); }); }); it('With a bidi stream call', function(done) { done = multiDone(done, 2); + var call; proxy_impl.bidiStream = function(parent) { var child = client.bidiStream(null, {parent: parent}); child.on('error', function(err) { @@ -1034,7 +1038,7 @@ describe('Call propagation', function() { proxy.start(); var proxy_client = new Client('localhost:' + proxy_port, grpc.credentials.createInsecure()); - var call = proxy_client.bidiStream(); + call = proxy_client.bidiStream(); call.on('error', function(err) { done(); }); From 7586db85937019653b687d81275d1c721ac8be34 Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Wed, 20 Jan 2016 14:02:42 -0800 Subject: [PATCH 7/8] Update copyright in binding.gyp --- binding.gyp | 2 +- templates/binding.gyp.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index 1ec7a67f655..ef72c76b640 100644 --- a/binding.gyp +++ b/binding.gyp @@ -5,7 +5,7 @@ # This file can be regenerated from the template by running # tools/buildgen/generate_projects.sh -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template index ed59e72bf78..ae5eb29ab04 100644 --- a/templates/binding.gyp.template +++ b/templates/binding.gyp.template @@ -7,7 +7,7 @@ # This file can be regenerated from the template by running # tools/buildgen/generate_projects.sh - # Copyright 2015, Google Inc. + # Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without From 50dac1c2762adbfd38436301e655d227a060397f Mon Sep 17 00:00:00 2001 From: murgatroid99 <mlumish@google.com> Date: Wed, 20 Jan 2016 14:45:25 -0800 Subject: [PATCH 8/8] Make Jenkins Node tests always build from source --- tools/jenkins/grpc_interop_node/build_interop.sh | 2 +- tools/run_tests/build_node.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/jenkins/grpc_interop_node/build_interop.sh b/tools/jenkins/grpc_interop_node/build_interop.sh index 3b69715c9af..4d4290d0b41 100755 --- a/tools/jenkins/grpc_interop_node/build_interop.sh +++ b/tools/jenkins/grpc_interop_node/build_interop.sh @@ -45,4 +45,4 @@ make install-certs # build Node interop client & server npm install -g node-gyp -(npm install && node-gyp rebuild) +npm install --unsafe-perm --build-from-source diff --git a/tools/run_tests/build_node.sh b/tools/run_tests/build_node.sh index faa7b624b8e..b856b97942b 100755 --- a/tools/run_tests/build_node.sh +++ b/tools/run_tests/build_node.sh @@ -36,4 +36,4 @@ CONFIG=${CONFIG:-opt} # change to grpc repo root cd $(dirname $0)/../.. -npm install --unsafe-perm +npm install --unsafe-perm --build-from-source