Commit 4b5ebafa by Adeel

Build: Produces identifiable binary name.

The new format is:
{platform}-{arch}-{runtime}-{major.minor}
where major and minor version belong to
the runtime.

Related Issue: #655.
PR URL: sass/node-sass#657.
parent 9c3accb7
var fs = require('fs'), var fs = require('fs'),
path = require('path'); path = require('path'),
utils = require('./utils');
/** /**
* Get binding * Get binding
...@@ -8,11 +9,10 @@ var fs = require('fs'), ...@@ -8,11 +9,10 @@ var fs = require('fs'),
*/ */
function getBinding() { function getBinding() {
var name = process.platform + '-' + process.arch;
var candidates = [ var candidates = [
path.join(__dirname, '..', 'build', 'Release', 'binding.node'), path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'build', 'Debug', '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]; var candidate = candidates.filter(fs.existsSync)[0];
...@@ -255,6 +255,7 @@ module.exports.renderSync = function(options) { ...@@ -255,6 +255,7 @@ module.exports.renderSync = function(options) {
/** /**
* API Info * API Info
* *
* @api public
*/ */
module.exports.info = function() { module.exports.info = function() {
......
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;
};
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
], ],
"dependencies": { "dependencies": {
"chalk": "^0.5.1", "chalk": "^0.5.1",
"cross-spawn": "^0.2.3", "cross-spawn": "^0.2.6",
"gaze": "^0.5.1", "gaze": "^0.5.1",
"get-stdin": "^4.0.1", "get-stdin": "^4.0.1",
"meow": "^3.0.0", "meow": "^3.0.0",
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
"replace-ext": "0.0.1", "replace-ext": "0.0.1",
"request": "^2.53.0", "request": "^2.53.0",
"sass-graph": "^1.0.3", "sass-graph": "^1.0.3",
"semver": "^4.2.2",
"shelljs": "^0.3.0" "shelljs": "^0.3.0"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -2,7 +2,8 @@ var fs = require('fs'), ...@@ -2,7 +2,8 @@ var fs = require('fs'),
path = require('path'), path = require('path'),
spawn = require('child_process').spawn, spawn = require('child_process').spawn,
mkdir = require('mkdirp'), mkdir = require('mkdirp'),
Mocha = require('mocha'); Mocha = require('mocha'),
utils = require('../lib/utils');
/** /**
* After build * After build
...@@ -109,7 +110,7 @@ function parseArgs(args) { ...@@ -109,7 +110,7 @@ function parseArgs(args) {
*/ */
function testBinary(options) { function testBinary(options) {
options.bin = options.platform + '-' + options.arch; options.bin = utils.getBinaryIdentifiableName();
if (options.force || process.env.SASS_FORCE_BUILD) { if (options.force || process.env.SASS_FORCE_BUILD) {
return build(options); return build(options);
......
...@@ -2,7 +2,8 @@ var fs = require('fs'), ...@@ -2,7 +2,8 @@ var fs = require('fs'),
path = require('path'), path = require('path'),
request = require('request'), request = require('request'),
mkdirp = require('mkdirp'), mkdirp = require('mkdirp'),
exec = require('shelljs').exec; exec = require('shelljs').exec,
utils = require('../lib/utils');
/** /**
* Download file, if succeeds save, if not delete * Download file, if succeeds save, if not delete
...@@ -76,7 +77,7 @@ function applyProxy(options, cb) { ...@@ -76,7 +77,7 @@ function applyProxy(options, cb) {
*/ */
function exists() { function exists() {
var name = process.platform + '-' + process.arch; var name = utils.getBinaryIdentifiableName();
fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) { fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) {
if (exists) { if (exists) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment