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",