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

Enable install and build using node-chakracore #1777

Closed
wants to merge 18 commits into from
Closed
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
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js

dist: trusty
compiler: gcc
sudo: false

Expand Down Expand Up @@ -41,6 +41,11 @@ jobs:
- stage: platform-test
node_js: "0.10"
os: linux
- stage: platform-test
node_js: "node"
env:
- NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/chakracore-release/
os: linux

addons:
apt:
Expand Down
63 changes: 42 additions & 21 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,53 @@
- '%AppData%\npm-cache'

environment:
# https://github.com/jasongin/nvs/blob/master/doc/CI.md
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth looking at https://github.com/appveyor/ci/blob/master/scripts/nodejs-utils.psm1 to get "native" support for Chakra on Appveyor

Copy link
Author

Choose a reason for hiding this comment

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

That is definitely an option (and likewise in nvm and hence node-chakracore), but at this time we just preferred using nvs since it added support for CI recently.

NVS_VERSION: 1.4.0
SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true
matrix:
- nodejs_version: 0.10
- NODEJS_VERSION: node/0.10
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 0.12
- NODEJS_VERSION: node/0.12
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 1.0
- NODEJS_VERSION: iojs/1
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 1
- NODEJS_VERSION: iojs/2
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 2
- NODEJS_VERSION: iojs/3
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 3
- NODEJS_VERSION: node/4
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 4
- NODEJS_VERSION: node/5
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 5
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 6
- NODEJS_VERSION: node/6
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 7
- NODEJS_VERSION: node/7
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 8
- NODEJS_VERSION: node/8
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- NODEJS_VERSION: chakracore/8
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015

install:
- ps: Install-Product node $env:nodejs_version $env:platform
# Install NVS
- git clone --branch v%NVS_VERSION% --depth 1 https://github.com/jasongin/nvs %LOCALAPPDATA%\nvs
- set PATH=%LOCALAPPDATA%\nvs;%PATH%
- nvs --version
# Install selected version of Node.js using NVS
- nvs add %NODEJS_VERSION%
- nvs use %NODEJS_VERSION%

- node --version
- npm --version
- npm install
Expand Down Expand Up @@ -131,29 +140,41 @@
- '%AppData%\npm-cache'

environment:
# https://github.com/jasongin/nvs/blob/master/doc/CI.md
NVS_VERSION: 1.4.0
SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true
matrix:
- nodejs_version: 0.10
- NODEJS_VERSION: node/0.10
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 0.12
- NODEJS_VERSION: node/0.12
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 4
- NODEJS_VERSION: node/4
GYP_MSVS_VERSION: 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- nodejs_version: 6
- NODEJS_VERSION: node/6
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 7
- NODEJS_VERSION: node/7
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 8
- NODEJS_VERSION: node/8
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- NODEJS_VERSION: chakracore/8
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015

install:
- ps: Install-Product node $env:nodejs_version $env:platform
# Install NVS
- git clone --branch v%NVS_VERSION% --depth 1 https://github.com/jasongin/nvs %LOCALAPPDATA%\nvs
- set PATH=%LOCALAPPDATA%\nvs;%PATH%
- nvs --version
# Install selected version of Node.js using NVS
- nvs add %NODEJS_VERSION%
- nvs use %NODEJS_VERSION%

- node --version
- npm --version
- npm install
Expand Down
38 changes: 31 additions & 7 deletions lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ function getHumanNodeVersion(abi) {
}
}

/**
* Get the friendly name of the Javascript engine that Node environment being run
* is using
*
* @param {string} engine - Javascript engine value - `v8` or `chakracore`
* @return {Object} Returns same engine name or false if unmatched
*
* @api public
*/
function getHumanJsEngine(engine) {
switch (engine) {
case 'v8': return 'v8';
case 'chakracore': return 'chakracore';
default: return false;
}
}

/**
* Get a human readable description of where node-sass is running to support
* user error reporting when something goes wrong
Expand All @@ -93,9 +110,10 @@ function getHumanEnvironment(env) {
parts = binding.split('-'),
platform = getHumanPlatform(parts[0]),
arch = getHumanArchitecture(parts[1]),
runtime = getHumanNodeVersion(parts[2]);

if (parts.length !== 3) {
runtime = getHumanNodeVersion(parts[2]),
jsEngine = getHumanJsEngine(parts[3]);

if (parts.length !== 3 && !(parts.length === 4 && jsEngine !== 'undefined')) {
return 'Unknown environment (' + binding + ')';
}

Expand Down Expand Up @@ -196,10 +214,16 @@ function getBinaryName() {
}

binaryName = [
platform, '-',
process.arch, '-',
process.versions.modules
].join('');
platform,
process.arch,
process.versions.modules,
];

if (process.jsEngine === 'chakracore') {
binaryName = binaryName.concat(process.jsEngine);
}

binaryName = binaryName.join('-');
}

return [binaryName, 'binding.node'].join('_');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"meow": "^3.7.0",
"mkdirp": "^0.5.1",
"nan": "^2.3.2",
"node-gyp": "^3.3.1",
"node-gyp": "^3.6.0",
"npmlog": "^4.0.0",
"request": "^2.79.0",
"sass-graph": "^2.2.4",
Expand Down
35 changes: 27 additions & 8 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,20 @@ function afterBuild(options) {
*/

function build(options) {
var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose'].concat(
['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function(subject) {
return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join('');
})).concat(options.args);

console.log('Building:', [process.execPath].concat(args).join(' '));

var proc = spawn(process.execPath, args, {
var nodeGyp = resolveNodeGyp();
var nodeGypArgs = nodeGyp.args.concat([
'rebuild',
'--verbose',
'--libsass_ext=' + (process.env['LIBSASS_EXT'] || ''),
'--libsass_cflags=' + (process.env['LIBSASS_CFLAGS'] || ''),
'--libsass_ldflags=' + (process.env['LIBSASS_LDFLAGS'] || ''),
'--libsass_library=' + (process.env['LIBSASS_LIBRARY'] || ''),
])
.concat(options.args);

console.log(['Building:', nodeGyp.exeName].concat(nodeGypArgs).join(' '));

var proc = spawn(nodeGyp.exeName, nodeGypArgs, {
stdio: [0, 1, 2]
});

Expand All @@ -83,6 +89,19 @@ function build(options) {
});
}

/**
* Resolve node-gyp command to invoke
*
* @api private
*/
function resolveNodeGyp() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this now that the version is bumped to 3.6?

Copy link
Author

Choose a reason for hiding this comment

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

No and that's why i removed my changes in 5021dff . I just kept the resolution of node-gyp in separate function for easy readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 that makes sense

var localNodeGypBin = require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js'));

return {
exeName: process.execPath,
args: [localNodeGypBin],
};
}
/**
* Parse arguments
*
Expand Down