Skip to content

Commit 8db9e57

Browse files
committed
build: use target_arch config variable to link against node.lib on Windows
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. Removed unused copyNodeLib() function Removed unused `copy_dev_lib` variable introduced in commit @84d24189735e19350a93aaf9f6a327bb4c52349e
1 parent 77383dd commit 8db9e57

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
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'
@@ -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

@@ -173,36 +170,12 @@ function build (gyp, argv, callback) {
173170
return
174171
}
175172
command = msbuildPath
176-
copyNodeLib()
173+
doBuild()
177174
})
178175
})()
179176
})
180177
}
181178

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

207180
/**
208181
* Actually spawn the process and compile the module.

lib/configure.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ function configure (gyp, argv, callback) {
131131
// set the node development directory
132132
variables.nodedir = nodeDir
133133

134-
// don't copy dev libraries with nodedir option
135-
variables.copy_dev_lib = !gyp.opts.nodedir
136-
137134
// disable -T "thin" static archives by default
138135
variables.standalone_static_library = gyp.opts.thin ? 0 : 1
139136

0 commit comments

Comments
 (0)