diff --git a/binding.gyp b/binding.gyp index a5e993353c9557b44a820acb3236c81c1b6611c6..1ec7a67f6554ed7f8fdb37020bb7782f3a5a23c9 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 ffbcc06b0ea497f5746f450873f1e785ca554479..f38178e665371294545305abf2ae41006e6fb7b8 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 0d1a7fd887bd5724eee705d2fa919c85c3c27f4f..7eacdc67b1d6ae0b460f8e747ac8f4d879a5aeac 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 d57826781d391d6872e6f00b757ee380ffa8a134..b5247a69ee01610313aab95dda1df1dbffa07283 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 dcbfac18f4647900db5fd9496663d133ecd5f3ba..710ab6d879cd36c8e13da6523de5d888919699a2 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 0000000000000000000000000000000000000000..d4eca65fcbf422595644820d7b8ba00d51c986eb --- /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 fef79f959e49323e6e5fad04f106324f21678c37..51a9f8a21622d71296a8000efcc6f7eefc772ed1 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 ceaa9f5d1fcbfe840653f98ef1d9599aeff03555..e5aadcd5658e05652f14c4045ad5faa9abe66af6 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 f1f86b35db39a4efc201e415dc26e73326917558..2300096d03e272910c0279ce3aca826af0288709 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 7163a5fb5ee2467ae025a43f6da5623c718d22ff..c0ae2b769a0ea99d3128aed3c011ea644219b398 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 b17cd339cb0effafdacfd574606376e8f73646f5..712c70706d95b962635bc99086fdd00882c608db 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 0f6c5941c4de48246510019d009851d9838ff305..353c6c761de3564c4e7a80c4cdc2e0e504dcae22 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 592f47e1456db6d4f99e34668b89c2440ae034ec..71a964718443bf21b32a043382fafa784801f7fe 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 8014ff3718cffe803b9d0d0f30cd36fd99d2bdff..ed59e72bf786bc9669858455a703611d175f5a9f 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 deb6b49ffd5e3e7c035bf1bb2e72459e966097f6..4b1906b10bd3ec3af06e35024bf57f3d6759fc66 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",