diff --git a/lib/configure.js b/lib/configure.js index e101a315a4..273cc4d4b1 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -1,4 +1,3 @@ - module.exports = exports = configure /** @@ -175,7 +174,7 @@ function configure (gyp, argv, callback) { var config = process.config || {} , defaults = config.target_defaults - , variables = config.variables + , variablesa = config.variables // default "config.variables" if (!variables) variables = config.variables = {} @@ -303,13 +302,18 @@ function configure (gyp, argv, callback) { // Windows expects an absolute path output_dir = buildDir } - - argv.push('-I', addon_gypi) - argv.push('-I', common_gypi) + + // Fix for spaces and other special characters in path. + function shellEscape(str) { + return str.replace(/(["\s'$`\\])/g, '\\$1'); + }; + + argv.push('-I', shellEscape(addon_gypi)) + argv.push('-I', shellEscape(common_gypi)) argv.push('-Dlibrary=shared_library') argv.push('-Dvisibility=default') - argv.push('-Dnode_root_dir=' + nodeDir) - argv.push('-Dmodule_root_dir=' + process.cwd()) + argv.push('-Dnode_root_dir=' + shellEscape(nodeDir)) + argv.push('-Dmodule_root_dir=' + shellEscape(process.cwd())) argv.push('--depth=.') // tell gyp to write the Makefile/Solution files into output_dir