mirror of
https://github.com/electron/node-gyp.git
synced 2025-09-17 22:33:40 +02:00
Prepare for a potential "0.10" release.
We can no longer treat the version like a Number, since `0.10` gets represented as `0.1`.
This commit is contained in:
parent
58b0abe4fe
commit
2461ff762c
4 changed files with 51 additions and 13 deletions
|
@ -8,6 +8,7 @@ module.exports = exports = configure
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
, path = require('path')
|
, path = require('path')
|
||||||
, glob = require('glob')
|
, glob = require('glob')
|
||||||
|
, nodeVersion = require('./util/node_version')
|
||||||
, win = process.platform == 'win32'
|
, win = process.platform == 'win32'
|
||||||
|
|
||||||
exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'
|
exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'
|
||||||
|
@ -20,11 +21,11 @@ function configure (gyp, argv, callback) {
|
||||||
|
|
||||||
if (gyp.opts.target) {
|
if (gyp.opts.target) {
|
||||||
// if --target was given, then ensure that version is installed
|
// if --target was given, then ensure that version is installed
|
||||||
version = parseFloat(gyp.opts.target)
|
version = nodeVersion.parse(gyp.opts.target)
|
||||||
gyp.verbose('compiling against --target node version', version)
|
gyp.verbose('compiling against --target node version', version)
|
||||||
} else {
|
} else {
|
||||||
// if no --target was specified then use the current host node version
|
// if no --target was specified then use the current host node version
|
||||||
version = parseFloat(process.versions.node)
|
version = nodeVersion.parse(process.versions.node)
|
||||||
gyp.verbose('no --target version specified, falling back to host node version', version)
|
gyp.verbose('no --target version specified, falling back to host node version', version)
|
||||||
}
|
}
|
||||||
gyp.opts.ensure = true
|
gyp.opts.ensure = true
|
||||||
|
@ -67,7 +68,7 @@ function configure (gyp, argv, callback) {
|
||||||
, devDir = path.join(process.env.HOME, '.node-gyp', target)
|
, devDir = path.join(process.env.HOME, '.node-gyp', target)
|
||||||
, gyp_addon = path.join(devDir, 'tools', 'gyp_addon')
|
, gyp_addon = path.join(devDir, 'tools', 'gyp_addon')
|
||||||
|
|
||||||
if (win && version < 0.8) {
|
if (win && nodeVersion.lessThan(version, 0, 8)) {
|
||||||
gyp.verbose('on Windows and target version is less than 0.8; applying #2685 patch')
|
gyp.verbose('on Windows and target version is less than 0.8; applying #2685 patch')
|
||||||
// if < 0.8, we need to manually apply the patch at joyent/node#2685,
|
// if < 0.8, we need to manually apply the patch at joyent/node#2685,
|
||||||
// since it got merged somewhere in 0.7.x.
|
// since it got merged somewhere in 0.7.x.
|
||||||
|
@ -76,7 +77,7 @@ function configure (gyp, argv, callback) {
|
||||||
argv.push(path.join(devDir, 'tools', 'patch.gypi'))
|
argv.push(path.join(devDir, 'tools', 'patch.gypi'))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!win && version < 0.8) {
|
if (!win && nodeVersion.lessThan(version, 0, 8)) {
|
||||||
gyp.verbose('on Unix and target version is less than 0.8; applying #2722 patch')
|
gyp.verbose('on Unix and target version is less than 0.8; applying #2722 patch')
|
||||||
argv.push('-I')
|
argv.push('-I')
|
||||||
argv.push(path.join(devDir, 'tools', 'patch2722.gypi'))
|
argv.push(path.join(devDir, 'tools', 'patch2722.gypi'))
|
||||||
|
|
|
@ -15,6 +15,7 @@ var fs = require('fs')
|
||||||
, mkdir = require('mkdirp')
|
, mkdir = require('mkdirp')
|
||||||
, request = require('request')
|
, request = require('request')
|
||||||
, minimatch = require('minimatch')
|
, minimatch = require('minimatch')
|
||||||
|
, nodeVersion = require('./util/node_version')
|
||||||
, distUrl = 'http://nodejs.org/dist'
|
, distUrl = 'http://nodejs.org/dist'
|
||||||
, win = process.platform == 'win32'
|
, win = process.platform == 'win32'
|
||||||
// a map for legacy releases:
|
// a map for legacy releases:
|
||||||
|
@ -36,12 +37,12 @@ function install (gyp, argv, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var version = parseFloat(argv[0] || gyp.opts.target)
|
var version = nodeVersion.parse(argv[0] || gyp.opts.target)
|
||||||
|
|
||||||
if (isNaN(version)) {
|
if (!version) {
|
||||||
return cb(new Error('You must specify a version to install (like "0.7")'))
|
return cb(new Error('You must specify a version to install (like "0.7")'))
|
||||||
}
|
}
|
||||||
if (version < 0.6) {
|
if (nodeVersion.lessThan(version, 0, 6)) {
|
||||||
return cb(new Error('Minimum target version is `0.6` or greater. Got: ' + version))
|
return cb(new Error('Minimum target version is `0.6` or greater. Got: ' + version))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ function install (gyp, argv, callback) {
|
||||||
|
|
||||||
// now download the node tarball
|
// now download the node tarball
|
||||||
// TODO: download the newest version instead of the .0 release
|
// TODO: download the newest version instead of the .0 release
|
||||||
var tarballUrl = distUrl + '/v' + version.toFixed(1) + '.0/node-v' + version.toFixed(1) + '.0.tar.gz'
|
var tarballUrl = distUrl + '/v' + version + '.0/node-v' + version + '.0.tar.gz'
|
||||||
, badDownload = false
|
, badDownload = false
|
||||||
, parser = tar.Parse()
|
, parser = tar.Parse()
|
||||||
|
|
||||||
|
@ -147,7 +148,7 @@ function install (gyp, argv, callback) {
|
||||||
gyp.verbose('done parsing tarball')
|
gyp.verbose('done parsing tarball')
|
||||||
var async = 0
|
var async = 0
|
||||||
|
|
||||||
if (version < 0.7) {
|
if (nodeVersion.lessThan(version, 0, 7)) {
|
||||||
// copy over gyp_addon, addon.gypi and common.gypi
|
// copy over gyp_addon, addon.gypi and common.gypi
|
||||||
async++
|
async++
|
||||||
copyLegacy(deref)
|
copyLegacy(deref)
|
||||||
|
@ -159,12 +160,12 @@ function install (gyp, argv, callback) {
|
||||||
downloadNodeLib(deref)
|
downloadNodeLib(deref)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (win && version < 0.8) {
|
if (win && nodeVersion.lessThan(version, 0, 8)) {
|
||||||
// before node 0.8 we need to manually link to node.lib
|
// before node 0.8 we need to manually link to node.lib
|
||||||
async++
|
async++
|
||||||
copy2685(deref)
|
copy2685(deref)
|
||||||
}
|
}
|
||||||
if (!win && version < 0.8) {
|
if (!win && nodeVersion.lessThan(version, 0, 8)) {
|
||||||
async++
|
async++
|
||||||
copy2722(deref)
|
copy2722(deref)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ exports.usage = 'Removes the node development files for the specified version'
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
, rm = require('rimraf')
|
, rm = require('rimraf')
|
||||||
, path = require('path')
|
, path = require('path')
|
||||||
|
, nodeVersion = require('./util/node_version')
|
||||||
|
|
||||||
function remove (gyp, argv, callback) {
|
function remove (gyp, argv, callback) {
|
||||||
|
|
||||||
|
@ -18,8 +19,8 @@ function remove (gyp, argv, callback) {
|
||||||
|
|
||||||
gyp.verbose('using node-gyp dir', nodeGypDir)
|
gyp.verbose('using node-gyp dir', nodeGypDir)
|
||||||
|
|
||||||
var version = parseFloat(argv[0] || gyp.opts.target)
|
var version = nodeVersion.parse(argv[0] || gyp.opts.target)
|
||||||
, versionPath = path.join(nodeGypDir, version.toString())
|
, versionPath = path.join(nodeGypDir, version)
|
||||||
|
|
||||||
gyp.verbose('removing development files for version', version)
|
gyp.verbose('removing development files for version', version)
|
||||||
|
|
||||||
|
|
35
lib/util/node_version.js
Normal file
35
lib/util/node_version.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper functions for parsing and testing node versions.
|
||||||
|
* Just plain `parseFloat` doesn't work in case there's ever a "x.10" release,
|
||||||
|
* which would be parsed as x.1 when represented as a Number.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var regexp = /^(\d+)\.(\d+)/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts a String like "v0.10.4" and returns a String
|
||||||
|
* containing the major and minor versions ("0.10").
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.parse = function parse (str) {
|
||||||
|
str = String(str)
|
||||||
|
if (str[0] === 'v') {
|
||||||
|
str = str.substring(1)
|
||||||
|
}
|
||||||
|
return str.match(regexp)[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts a major-minor version string (from `parseVersion`) and a major
|
||||||
|
* and minor Number value to test that the given version is less that the
|
||||||
|
* specified version. Returns true or false.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.lessThan = function lessThan (ver, major, minor) {
|
||||||
|
var exec = regexp.exec(ver)
|
||||||
|
, inMaj = parseInt(exec[1])
|
||||||
|
, inMin = parseInt(exec[2])
|
||||||
|
if (inMaj > major) return false
|
||||||
|
return inMin < minor
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue