Blame SOURCES/node-gyp-addon-gypi.patch

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