Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Build: Produces identifiable binary name #657

Merged
merged 2 commits into from
Feb 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var fs = require('fs'),
path = require('path');
path = require('path'),
utils = require('./utils');

/**
* Get binding
Expand All @@ -8,11 +9,10 @@ var fs = require('fs'),
*/

function getBinding() {
var name = process.platform + '-' + process.arch;
var candidates = [
path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'build', 'Debug', 'binding.node'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xzyfer, @kevva,
I think Debug should take precedence over Release here; because if you explicitly build Debug binary with node-gyp rebuild -d, then your primary intent is to debug that binary in debug mode. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because if you explicitly build Debug binary with node-gyp rebuild -d , then your primary intent is to debug that binary in debug mode

path.join(__dirname, '..', 'vendor', name, 'binding.node')
path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'vendor', utils.getBinaryIdentifiableName(), 'binding.node')
];

var candidate = candidates.filter(fs.existsSync)[0];
Expand Down Expand Up @@ -255,6 +255,7 @@ module.exports.renderSync = function(options) {
/**
* API Info
*
* @api public
*/

module.exports.info = function() {
Expand Down
28 changes: 28 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var semver = require('semver'),
runtimeVersion = semver.parse(process.version);

/**
* Get Runtime Name
*
* @api private
*/

function getRuntimeName() {
return process.execPath
.split(/[\\/]+/).pop()
.split('.')[0];
}

/**
* Get unique name of binary for current platform
*
* @api public
*/

module.exports.getBinaryIdentifiableName = function() {
return process.platform + '-' +
process.arch + '-' +
getRuntimeName() + '-' +
runtimeVersion.major + '.' +
runtimeVersion.minor;
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
],
"dependencies": {
"chalk": "^0.5.1",
"cross-spawn": "^0.2.3",
"cross-spawn": "^0.2.6",
"gaze": "^0.5.1",
"get-stdin": "^4.0.1",
"meow": "^3.0.0",
Expand All @@ -56,6 +56,7 @@
"replace-ext": "0.0.1",
"request": "^2.53.0",
"sass-graph": "^1.0.3",
"semver": "^4.2.2",
"shelljs": "^0.3.0"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var fs = require('fs'),
path = require('path'),
spawn = require('child_process').spawn,
mkdir = require('mkdirp'),
Mocha = require('mocha');
Mocha = require('mocha'),
utils = require('../lib/utils');

/**
* After build
Expand Down Expand Up @@ -109,7 +110,7 @@ function parseArgs(args) {
*/

function testBinary(options) {
options.bin = options.platform + '-' + options.arch;
options.bin = utils.getBinaryIdentifiableName();

if (options.force || process.env.SASS_FORCE_BUILD) {
return build(options);
Expand Down
5 changes: 3 additions & 2 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var fs = require('fs'),
path = require('path'),
request = require('request'),
mkdirp = require('mkdirp'),
exec = require('shelljs').exec;
exec = require('shelljs').exec,
utils = require('../lib/utils');

/**
* Download file, if succeeds save, if not delete
Expand Down Expand Up @@ -76,7 +77,7 @@ function applyProxy(options, cb) {
*/

function exists() {
var name = process.platform + '-' + process.arch;
var name = utils.getBinaryIdentifiableName();

fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) {
if (exists) {
Expand Down