Skip to content

Commit 0913b2d

Browse files
pmedjoaocgreis
authored andcommitted
build, win: use target_arch to link with 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 it from node_root_dir/target_arch directory. PR-URL: #964 Reviewed-By: João Reis <[email protected]>
1 parent c307b30 commit 0913b2d

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
lines changed

Diff for: addon.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
'-luuid.lib',
110110
'-lodbc32.lib',
111111
'-lDelayImp.lib',
112-
'-l"<(node_root_dir)/$(ConfigurationName)/<(node_lib_file)"'
112+
'-l"<(node_root_dir)/<(target_arch)/<(node_lib_file)"'
113113
],
114114
'msvs_disabled_warnings': [
115115
# warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent<T>'

Diff for: lib/build.js

+2-29
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'
@@ -36,7 +35,6 @@ function build (gyp, argv, callback) {
3635
, config
3736
, arch
3837
, nodeDir
39-
, copyDevLib
4038

4139
loadConfigGypi()
4240

@@ -60,7 +58,6 @@ function build (gyp, argv, callback) {
6058
buildType = config.target_defaults.default_configuration
6159
arch = config.variables.target_arch
6260
nodeDir = config.variables.nodedir
63-
copyDevLib = config.variables.copy_dev_lib == 'true'
6461

6562
if ('debug' in gyp.opts) {
6663
buildType = gyp.opts.debug ? 'Debug' : 'Release'
@@ -115,7 +112,7 @@ function build (gyp, argv, callback) {
115112
return
116113
}
117114
log.verbose('`which` succeeded for `' + command + '`', execPath)
118-
copyNodeLib()
115+
doBuild()
119116
})
120117
}
121118

@@ -180,36 +177,12 @@ function build (gyp, argv, callback) {
180177
return
181178
}
182179
command = msbuildPath
183-
copyNodeLib()
180+
doBuild()
184181
})
185182
})()
186183
})
187184
}
188185

189-
/**
190-
* Copies the node.lib file for the current target architecture into the
191-
* current proper dev dir location.
192-
*/
193-
194-
function copyNodeLib () {
195-
if (!win || !copyDevLib) return doBuild()
196-
197-
var buildDir = path.resolve(nodeDir, buildType)
198-
, archNodeLibPath = path.resolve(nodeDir, arch, release.name + '.lib')
199-
, buildNodeLibPath = path.resolve(buildDir, release.name + '.lib')
200-
201-
mkdirp(buildDir, function (err, isNew) {
202-
if (err) return callback(err)
203-
log.verbose('"' + buildType + '" dir needed to be created?', isNew)
204-
var rs = fs.createReadStream(archNodeLibPath)
205-
, ws = fs.createWriteStream(buildNodeLibPath)
206-
log.verbose('copying "' + release.name + '.lib" for ' + arch, buildNodeLibPath)
207-
rs.pipe(ws)
208-
rs.on('error', callback)
209-
ws.on('error', callback)
210-
rs.on('end', doBuild)
211-
})
212-
}
213186

214187
/**
215188
* Actually spawn the process and compile the module.

Diff for: lib/configure.js

-3
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ function configure (gyp, argv, callback) {
144144
// set the node development directory
145145
variables.nodedir = nodeDir
146146

147-
// don't copy dev libraries with nodedir option
148-
variables.copy_dev_lib = !gyp.opts.nodedir
149-
150147
// disable -T "thin" static archives by default
151148
variables.standalone_static_library = gyp.opts.thin ? 0 : 1
152149

0 commit comments

Comments
 (0)