Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use target_arch config variable to link against node.lib #964

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
'-luuid.lib',
'-lodbc32.lib',
'-lDelayImp.lib',
'-l"<(node_root_dir)/$(ConfigurationName)/<(node_lib_file)"'
'-l"<(node_root_dir)/<(target_arch)/<(node_lib_file)"'
Copy link
Member

@richardlau richardlau Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will break users on Windows who compile Node.js from source and use --nodedir to point at their source tree. When building from source, the node.lib file is written to either the Release or Debug directory depending on the build configuration (i.e. the value of $(ConfigurationName)) used.

],
'msvs_disabled_warnings': [
# warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent<T>'
Expand Down
31 changes: 2 additions & 29 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var fs = require('graceful-fs')
, glob = require('glob')
, log = require('npmlog')
, which = require('which')
, mkdirp = require('mkdirp')
, exec = require('child_process').exec
, processRelease = require('./process-release')
, win = process.platform == 'win32'
Expand All @@ -36,7 +35,6 @@ function build (gyp, argv, callback) {
, config
, arch
, nodeDir
, copyDevLib

loadConfigGypi()

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

if ('debug' in gyp.opts) {
buildType = gyp.opts.debug ? 'Debug' : 'Release'
Expand Down Expand Up @@ -115,7 +112,7 @@ function build (gyp, argv, callback) {
return
}
log.verbose('`which` succeeded for `' + command + '`', execPath)
copyNodeLib()
doBuild()
})
}

Expand Down Expand Up @@ -173,36 +170,12 @@ function build (gyp, argv, callback) {
return
}
command = msbuildPath
copyNodeLib()
doBuild()
})
})()
})
}

/**
* Copies the node.lib file for the current target architecture into the
* current proper dev dir location.
*/

function copyNodeLib () {
if (!win || !copyDevLib) return doBuild()

var buildDir = path.resolve(nodeDir, buildType)
, archNodeLibPath = path.resolve(nodeDir, arch, release.name + '.lib')
, buildNodeLibPath = path.resolve(buildDir, release.name + '.lib')

mkdirp(buildDir, function (err, isNew) {
if (err) return callback(err)
log.verbose('"' + buildType + '" dir needed to be created?', isNew)
var rs = fs.createReadStream(archNodeLibPath)
, ws = fs.createWriteStream(buildNodeLibPath)
log.verbose('copying "' + release.name + '.lib" for ' + arch, buildNodeLibPath)
rs.pipe(ws)
rs.on('error', callback)
ws.on('error', callback)
rs.on('end', doBuild)
})
}

/**
* Actually spawn the process and compile the module.
Expand Down
3 changes: 0 additions & 3 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ function configure (gyp, argv, callback) {
// set the node development directory
variables.nodedir = nodeDir

// don't copy dev libraries with nodedir option
variables.copy_dev_lib = !gyp.opts.nodedir

// disable -T "thin" static archives by default
variables.standalone_static_library = gyp.opts.thin ? 0 : 1

Expand Down