Skip to content

Commit 21eee45

Browse files
committed
build: use target_arch config variable to link against node lib
Using `target_arch` in addon.gypi to link against Node.js library. This variable was written into build/config.gypi on the `configure` stage. Do not copy node.lib into node_root_dir/Release or node_root_dir/Debug on Windows, link from node_root_dir/target_arch Removed unused copyNodeLib() function.
1 parent 40d7ea8 commit 21eee45

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

addon.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
'-luuid.lib',
9393
'-lodbc32.lib',
9494
'-lDelayImp.lib',
95-
'-l"<(node_root_dir)/$(ConfigurationName)/<(node_lib_file)"'
95+
'-l"<(node_root_dir)/<(target_arch)/<(node_lib_file)"'
9696
],
9797
'msvs_disabled_warnings': [
9898
# warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent<T>'

lib/build.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var fs = require('graceful-fs')
1111
, glob = require('glob')
1212
, log = require('npmlog')
1313
, which = require('which')
14-
, mkdirp = require('mkdirp')
1514
, exec = require('child_process').exec
1615
, processRelease = require('./process-release')
1716
, win = process.platform == 'win32'
@@ -37,7 +36,6 @@ function build (gyp, argv, callback) {
3736
, arch
3837
, nodeDir
3938
, vcDir
40-
, copyDevLib
4139

4240
if (gyp.opts.gypjs) {
4341
command = gyp.opts.ninja || process.env.NINJA || 'ninja'
@@ -64,7 +62,6 @@ function build (gyp, argv, callback) {
6462
buildType = config.target_defaults.default_configuration
6563
arch = config.variables.target_arch
6664
nodeDir = config.variables.nodedir
67-
copyDevLib = config.variables.copy_dev_lib == 'true'
6865

6966
if ('debug' in gyp.opts) {
7067
buildType = gyp.opts.debug ? 'Debug' : 'Release'
@@ -146,7 +143,7 @@ function build (gyp, argv, callback) {
146143
return
147144
}
148145
log.verbose('`which` succeeded for `' + command + '`', execPath)
149-
copyNodeLib()
146+
doBuild()
150147
})
151148
}
152149

@@ -204,36 +201,12 @@ function build (gyp, argv, callback) {
204201
return
205202
}
206203
command = msbuildPath
207-
copyNodeLib()
204+
doBuild()
208205
})
209206
})()
210207
})
211208
}
212209

213-
/**
214-
* Copies the node.lib file for the current target architecture into the
215-
* current proper dev dir location.
216-
*/
217-
218-
function copyNodeLib () {
219-
if (!win || !copyDevLib) return doBuild()
220-
221-
var buildDir = path.resolve(nodeDir, buildType)
222-
, archNodeLibPath = path.resolve(nodeDir, arch, release.name + '.lib')
223-
, buildNodeLibPath = path.resolve(buildDir, release.name + '.lib')
224-
225-
mkdirp(buildDir, function (err, isNew) {
226-
if (err) return callback(err)
227-
log.verbose('"' + buildType + '" dir needed to be created?', isNew)
228-
var rs = fs.createReadStream(archNodeLibPath)
229-
, ws = fs.createWriteStream(buildNodeLibPath)
230-
log.verbose('copying "' + release.name + '.lib" for ' + arch, buildNodeLibPath)
231-
rs.pipe(ws)
232-
rs.on('error', callback)
233-
ws.on('error', callback)
234-
rs.on('end', doBuild)
235-
})
236-
}
237210

238211
/**
239212
* Actually spawn the process and compile the module.

0 commit comments

Comments
 (0)