Skip to content

Commit 5e5313a

Browse files
Add files via upload
1 parent 219e8cb commit 5e5313a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+11999
-0
lines changed

@mapbox/node-pre-gyp/CHANGELOG.md

Lines changed: 510 additions & 0 deletions
Large diffs are not rendered by default.

@mapbox/node-pre-gyp/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c), Mapbox
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without modification,
6+
are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
* Neither the name of node-pre-gyp nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@mapbox/node-pre-gyp/README.md

Lines changed: 742 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
require('../lib/main');
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
node "%~dp0\node-pre-gyp" %*
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Contributing
2+
3+
4+
### Releasing a new version:
5+
6+
- Ensure tests are passing on travis and appveyor
7+
- Run `node scripts/abi_crosswalk.js` and commit any changes
8+
- Update the changelog
9+
- Tag a new release like: `git tag -a v0.6.34 -m "tagging v0.6.34" && git push --tags`
10+
- Run `npm publish`

@mapbox/node-pre-gyp/lib/build.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
3+
module.exports = exports = build;
4+
5+
exports.usage = 'Attempts to compile the module by dispatching to node-gyp or nw-gyp';
6+
7+
const napi = require('./util/napi.js');
8+
const compile = require('./util/compile.js');
9+
const handle_gyp_opts = require('./util/handle_gyp_opts.js');
10+
const configure = require('./configure.js');
11+
12+
function do_build(gyp, argv, callback) {
13+
handle_gyp_opts(gyp, argv, (err, result) => {
14+
let final_args = ['build'].concat(result.gyp).concat(result.pre);
15+
if (result.unparsed.length > 0) {
16+
final_args = final_args.
17+
concat(['--']).
18+
concat(result.unparsed);
19+
}
20+
if (!err && result.opts.napi_build_version) {
21+
napi.swap_build_dir_in(result.opts.napi_build_version);
22+
}
23+
compile.run_gyp(final_args, result.opts, (err2) => {
24+
if (result.opts.napi_build_version) {
25+
napi.swap_build_dir_out(result.opts.napi_build_version);
26+
}
27+
return callback(err2);
28+
});
29+
});
30+
}
31+
32+
function build(gyp, argv, callback) {
33+
34+
// Form up commands to pass to node-gyp:
35+
// We map `node-pre-gyp build` to `node-gyp configure build` so that we do not
36+
// trigger a clean and therefore do not pay the penalty of a full recompile
37+
if (argv.length && (argv.indexOf('rebuild') > -1)) {
38+
argv.shift(); // remove `rebuild`
39+
// here we map `node-pre-gyp rebuild` to `node-gyp rebuild` which internally means
40+
// "clean + configure + build" and triggers a full recompile
41+
compile.run_gyp(['clean'], {}, (err3) => {
42+
if (err3) return callback(err3);
43+
configure(gyp, argv, (err4) => {
44+
if (err4) return callback(err4);
45+
return do_build(gyp, argv, callback);
46+
});
47+
});
48+
} else {
49+
return do_build(gyp, argv, callback);
50+
}
51+
}

@mapbox/node-pre-gyp/lib/clean.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
module.exports = exports = clean;
4+
5+
exports.usage = 'Removes the entire folder containing the compiled .node module';
6+
7+
const rm = require('rimraf');
8+
const exists = require('fs').exists || require('path').exists;
9+
const versioning = require('./util/versioning.js');
10+
const napi = require('./util/napi.js');
11+
const path = require('path');
12+
13+
function clean(gyp, argv, callback) {
14+
const package_json = gyp.package_json;
15+
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
16+
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
17+
const to_delete = opts.module_path;
18+
if (!to_delete) {
19+
return callback(new Error('module_path is empty, refusing to delete'));
20+
} else if (path.normalize(to_delete) === path.normalize(process.cwd())) {
21+
return callback(new Error('module_path is not set, refusing to delete'));
22+
} else {
23+
exists(to_delete, (found) => {
24+
if (found) {
25+
if (!gyp.opts.silent_clean) console.log('[' + package_json.name + '] Removing "%s"', to_delete);
26+
return rm(to_delete, callback);
27+
}
28+
return callback();
29+
});
30+
}
31+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict';
2+
3+
module.exports = exports = configure;
4+
5+
exports.usage = 'Attempts to configure node-gyp or nw-gyp build';
6+
7+
const napi = require('./util/napi.js');
8+
const compile = require('./util/compile.js');
9+
const handle_gyp_opts = require('./util/handle_gyp_opts.js');
10+
11+
function configure(gyp, argv, callback) {
12+
handle_gyp_opts(gyp, argv, (err, result) => {
13+
let final_args = result.gyp.concat(result.pre);
14+
// pull select node-gyp configure options out of the npm environ
15+
const known_gyp_args = ['dist-url', 'python', 'nodedir', 'msvs_version'];
16+
known_gyp_args.forEach((key) => {
17+
const val = gyp.opts[key] || gyp.opts[key.replace('-', '_')];
18+
if (val) {
19+
final_args.push('--' + key + '=' + val);
20+
}
21+
});
22+
// --ensure=false tell node-gyp to re-install node development headers
23+
// but it is only respected by node-gyp install, so we have to call install
24+
// as a separate step if the user passes it
25+
if (gyp.opts.ensure === false) {
26+
const install_args = final_args.concat(['install', '--ensure=false']);
27+
compile.run_gyp(install_args, result.opts, (err2) => {
28+
if (err2) return callback(err2);
29+
if (result.unparsed.length > 0) {
30+
final_args = final_args.
31+
concat(['--']).
32+
concat(result.unparsed);
33+
}
34+
compile.run_gyp(['configure'].concat(final_args), result.opts, (err3) => {
35+
return callback(err3);
36+
});
37+
});
38+
} else {
39+
if (result.unparsed.length > 0) {
40+
final_args = final_args.
41+
concat(['--']).
42+
concat(result.unparsed);
43+
}
44+
compile.run_gyp(['configure'].concat(final_args), result.opts, (err4) => {
45+
if (!err4 && result.opts.napi_build_version) {
46+
napi.swap_build_dir_out(result.opts.napi_build_version);
47+
}
48+
return callback(err4);
49+
});
50+
}
51+
});
52+
}

@mapbox/node-pre-gyp/lib/info.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
module.exports = exports = info;
4+
5+
exports.usage = 'Lists all published binaries (requires aws-sdk)';
6+
7+
const log = require('npmlog');
8+
const versioning = require('./util/versioning.js');
9+
const s3_setup = require('./util/s3_setup.js');
10+
11+
function info(gyp, argv, callback) {
12+
const package_json = gyp.package_json;
13+
const opts = versioning.evaluate(package_json, gyp.opts);
14+
const config = {};
15+
s3_setup.detect(opts, config);
16+
const s3 = s3_setup.get_s3(config);
17+
const s3_opts = {
18+
Bucket: config.bucket,
19+
Prefix: config.prefix
20+
};
21+
s3.listObjects(s3_opts, (err, meta) => {
22+
if (err && err.code === 'NotFound') {
23+
return callback(new Error('[' + package_json.name + '] Not found: https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + config.prefix));
24+
} else if (err) {
25+
return callback(err);
26+
} else {
27+
log.verbose(JSON.stringify(meta, null, 1));
28+
if (meta && meta.Contents) {
29+
meta.Contents.forEach((obj) => {
30+
console.log(obj.Key);
31+
});
32+
} else {
33+
console.error('[' + package_json.name + '] No objects found at https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + config.prefix);
34+
}
35+
return callback();
36+
}
37+
});
38+
}

0 commit comments

Comments
 (0)