Skip to content

Commit

Permalink
Build: Produces identifiable binary name.
Browse files Browse the repository at this point in the history
The new format is:
{platform}-{arch}-{runtime}-{major.minor}
where major and minor version belong to
the runtime.

Related Issue: sass#655.
PR URL: sass#657.
  • Loading branch information
am11 committed Feb 10, 2015
1 parent 01ca5e2 commit 8cf4540
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
7 changes: 4 additions & 3 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'),
path.join(__dirname, '..', 'vendor', name, '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
27 changes: 27 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var semver = require('semver'),
runtimeVersion = semver.parse(process.version),
runtime = runtimeVersion.major < 1 ? 'node' : 'iojs';

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

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

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

module.exports.getBinaryIdentifiableName = function() {
return process.platform + '-' +
process.arch + '-' +
getRuntimeName() + '-' +
runtimeVersion.major + '.' +
runtimeVersion.minor;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8cf4540

Please sign in to comment.