LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File node-gyp-addon-gypi.patch of Package nodejs (Project devel:languages:nodejs)

From 32f9dc9b1e22ce0ba4a7ca4f40dee023682e5e52 Mon Sep 17 00:00:00 2001
From: "T.C. Hollingsworth" <tchollingsworth@gmail.com>
Date: Sat, 5 Jan 2013 02:28:01 -0700
Subject: [PATCH 1/2] use custom addon.gypi by default instead of downloading
 node source

---
 addon-rpm.gypi   | 35 +++++++++++++++++++++++++++++++++++
 lib/configure.js | 38 ++++++++++++++++++++------------------
 2 files changed, 55 insertions(+), 18 deletions(-)
 create mode 100644 addon-rpm.gypi

diff --git a/addon-rpm.gypi b/addon-rpm.gypi
new file mode 100644
index 0000000..3e259ef
--- /dev/null
+++ b/addon-rpm.gypi
@@ -0,0 +1,35 @@
+{
+  'target_defaults': {
+    'type': 'loadable_module',
+    'product_prefix': '',
+    'include_dirs': [
+      '/usr/include/node/',
+      '/usr/include/'
+    ],
+
+    'target_conditions': [
+      ['_type=="loadable_module"', {
+        'product_extension': 'node',
+        'defines': [ 'BUILDING_NODE_EXTENSION' ],
+      }]
+    ],
+
+    'conditions': [
+      [ 'OS=="mac"', {
+        'libraries': [ '-undefined dynamic_lookup' ],
+        'xcode_settings': {
+          'DYLIB_INSTALL_NAME_BASE': '@rpath'
+        },
+      }],
+      [ 'OS=="win"', {
+        'libraries': [ '-l<(node_root_dir)/$(Configuration)/node.lib' ],
+        # warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent<T>'
+        # needs to have dll-interface to be used by clients of class 'node::ObjectWrap'
+        'msvs_disabled_warnings': [ 4251 ],
+      }],
+      [ 'OS=="freebsd" or OS=="openbsd" or OS=="solaris" or (OS=="linux" and target_arch!="ia32")', {
+        'cflags': [ '-fPIC' ],
+      }]
+    ]
+  }
+}
diff --git a/lib/configure.js b/lib/configure.js
index 82de1e6..0e6f76a 100644
--- a/lib/configure.js
+++ b/lib/configure.js
@@ -206,26 +206,27 @@ function configure (gyp, argv, callback) {
         // if --target was given, then determine a target version to compile for
         versionStr = gyp.opts.target
         log.verbose('get node dir', 'compiling against --target node version: %s', versionStr)
-      } else {
-        // if no --target was specified then use the current host node version
-        versionStr = process.version
-        log.verbose('get node dir', 'no --target version specified, falling back to host node version: %s', versionStr)
-      }
 
-      // make sure we have a valid version
-      version = semver.parse(versionStr)
-      if (!version) {
-        return callback(new Error('Invalid version number: ' + versionStr))
-      }
+        // make sure we have a valid version
+        version = semver.parse(versionStr)
+        if (!version) {
+            return callback(new Error('Invalid version number: ' + versionStr))
+        }
 
-      // ensure that the target node version's dev files are installed
-      gyp.opts.ensure = true
-      gyp.commands.install([ versionStr ], function (err, version) {
-        if (err) return callback(err)
-        log.verbose('get node dir', 'target node version installed:', version)
-        nodeDir = path.resolve(gyp.devDir, version)
+        // ensure that the target node version's dev files are installed
+        gyp.opts.ensure = true
+        gyp.commands.install([ versionStr ], 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 RPM-installed headers
+        log.verbose('get node dir', 'no --target version specified, falling back to RPM installed headers')
+        nodeDir = '/usr/share/node'
         createBuildDir()
-      })
+      }
     }
   }
 
@@ -379,7 +380,8 @@ function configure (gyp, argv, callback) {
 
     // this logic ported from the old `gyp_addon` python file
     var gyp_script = path.resolve(__dirname, '..', 'gyp', '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, 'common.gypi')
     var output_dir = 'build'
     if (win) {
-- 
1.7.11.7