Merge pull request #4788 from murgatroid99/node_binary_precompile

Add ability to create and handle precompiled binaries in Node library
pull/4868/head
Nicolas Noble 9 years ago
commit 8c7aabfa72
  1. 13
      binding.gyp
  2. 14
      package.json
  3. 4
      src/node/index.js
  4. 4
      src/node/src/client.js
  5. 4
      src/node/src/credentials.js
  6. 40
      src/node/src/grpc_extension.js
  7. 2
      src/node/src/metadata.js
  8. 4
      src/node/src/server.js
  9. 4
      src/node/test/call_test.js
  10. 4
      src/node/test/channel_test.js
  11. 4
      src/node/test/constant_test.js
  12. 4
      src/node/test/end_to_end_test.js
  13. 4
      src/node/test/server_test.js
  14. 14
      src/node/test/surface_test.js
  15. 13
      templates/binding.gyp.template
  16. 14
      templates/package.json.template
  17. 2
      tools/jenkins/grpc_interop_node/build_interop.sh
  18. 2
      tools/run_tests/build_node.sh

@ -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
@ -723,5 +723,16 @@
"gpr",
]
},
{
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node"],
"destination": "<(module_path)"
}
]
}
]
}

@ -22,12 +22,14 @@
"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",
"protobufjs": "^4.0.0"
},
"devDependencies": {
@ -45,6 +47,14 @@
"engines": {
"node": ">=0.10.13"
},
"binary": {
"module_name": "grpc_node",
"module_path": "./build/Release/",
"host": "https://storage.googleapis.com/",
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
"package_name": "{node_abi}-{platform}-{arch}.tar.gz",
"module_path": "src/node/extension_binary"
},
"files": [
"LICENSE",
"src/node/README.md",

@ -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.

@ -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');

@ -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;

@ -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;

@ -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.

@ -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');

@ -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

@ -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

@ -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

@ -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

@ -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() {

@ -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();
});

@ -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
@ -209,5 +209,16 @@
]
},
% endfor
{
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node"],
"destination": "<(module_path)"
}
]
}
]
}

@ -24,12 +24,14 @@
"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",
"protobufjs": "^4.0.0"
},
"devDependencies": {
@ -47,6 +49,14 @@
"engines": {
"node": ">=0.10.13"
},
"binary": {
"module_name": "grpc_node",
"module_path": "./build/Release/",
"host": "https://storage.googleapis.com/",
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
"package_name": "{node_abi}-{platform}-{arch}.tar.gz",
"module_path": "src/node/extension_binary"
},
"files": [
"LICENSE",
"src/node/README.md",

@ -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

@ -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

Loading…
Cancel
Save