---
diff --git a/lib/configure.js b/lib/configure.js
index a446943..13eb9d3 100644
--- a/lib/configure.js
+++ b/lib/configure.js
@@ -59,9 +59,30 @@ function configure (gyp, argv, callback) {
if ('v' + release.version !== process.version) {
// if --target was given, then determine a target version to compile for
log.verbose('get node dir', 'compiling against --target node version: %s', release.version)
+ // make sure we have a valid version
+ try {
+ version = semver.parse(release.version)
+ } catch (e) {
+ return callback(e)
+ }
+ if (!version) {
+ return callback(new Error('Invalid version number: ' + release.version))
+ }
+ // ensure that the target node version's dev files are installed
+ gyp.opts.ensure = true
+ gyp.commands.install([ release.version ], function (err, version) {
+ if (err) return callback(err)
+ log.verbose('get node dir', 'target node version installed:', version)
+ nodeDir = path.resolve(gyp.devDir, version)
+ createBuildDir()
+ })
} else {
// if no --target was specified then use the current host node version
+ // if no --target was specified then use RPM-installed headers
log.verbose('get node dir', 'no --target version specified, falling back to host node version: %s', release.version)
+ log.verbose('get node dir', 'no --target version specified, falling back to RPM installed headers')
+ nodeDir = '/opt/rh/rh-nodejs4/root/usr/share/node'
+ createBuildDir()
}
if (!release.semver) {
@@ -248,7 +269,8 @@ function configure (gyp, argv, callback) {
// this logic ported from the old `gyp_addon` python file
var gyp_script = '/opt/rh/rh-nodejs4/root/usr/bin/gyp'
- var addon_gypi = path.resolve(__dirname, '..', 'addon.gypi')
+ var addon_gypi_file = gyp.opts.target || gyp.opts.nodeDir ? 'addon.gypi' : 'addon-rpm.gypi'
+ var addon_gypi = path.resolve(__dirname, '..', addon_gypi_file)
var common_gypi = path.resolve(nodeDir, 'include/node/common.gypi')
fs.stat(common_gypi, function (err, stat) {
if (err)
--
2.5.0