mirror of
https://github.com/electron/node-gyp.git
synced 2025-09-15 13:43:40 +02:00
configure: add support for "config.gypi" and "commong.gypi" files
When present alongside the "binding.gyp" file. This gives addons a chance to overwrite default variables specified in the gyp files of the native addon's gyp dependencies.
This commit is contained in:
parent
bae7580ff8
commit
2e5e6a66a8
1 changed files with 32 additions and 8 deletions
|
@ -29,7 +29,8 @@ function configure (gyp, argv, callback) {
|
||||||
, hasVC2012Express = false
|
, hasVC2012Express = false
|
||||||
, hasWin71SDK = false
|
, hasWin71SDK = false
|
||||||
, hasWin8SDK = false
|
, hasWin8SDK = false
|
||||||
, configPath
|
, configNames = [ 'config.gypi', 'common.gypi' ]
|
||||||
|
, configs = []
|
||||||
, nodeDir
|
, nodeDir
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,9 +242,9 @@ function configure (gyp, argv, callback) {
|
||||||
if (err) return callback(err)
|
if (err) return callback(err)
|
||||||
|
|
||||||
var configFilename = 'config.gypi'
|
var configFilename = 'config.gypi'
|
||||||
configPath = path.resolve(buildDir, configFilename)
|
var configPath = path.resolve(buildDir, configFilename)
|
||||||
|
|
||||||
log.verbose(configFilename, 'creating config file')
|
log.verbose('build/' + configFilename, 'creating config file')
|
||||||
|
|
||||||
var config = process.config || {}
|
var config = process.config || {}
|
||||||
, defaults = config.target_defaults
|
, defaults = config.target_defaults
|
||||||
|
@ -311,13 +312,34 @@ function configure (gyp, argv, callback) {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
log.silly(configFilename, config)
|
log.silly('build/' + configFilename, config)
|
||||||
|
|
||||||
// now write out the config.gypi file to the build/ dir
|
// now write out the config.gypi file to the build/ dir
|
||||||
var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step'
|
var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step'
|
||||||
, json = JSON.stringify(config, boolsToString, 2)
|
, json = JSON.stringify(config, boolsToString, 2)
|
||||||
log.verbose(configFilename, 'writing out config file: %s', configPath)
|
log.verbose('build/' + configFilename, 'writing out config file: %s', configPath)
|
||||||
fs.writeFile(configPath, [prefix, json, ''].join('\n'), runGyp)
|
configs.push(configPath)
|
||||||
|
fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs)
|
||||||
|
}
|
||||||
|
|
||||||
|
function findConfigs (err) {
|
||||||
|
if (err) return callback(err)
|
||||||
|
var name = configNames.shift();
|
||||||
|
if (!name) return runGyp();
|
||||||
|
var fullPath = path.resolve(name);
|
||||||
|
log.verbose(name, 'checking for gypi file: %s', fullPath);
|
||||||
|
fs.stat(fullPath, function (err, stat) {
|
||||||
|
if (err) {
|
||||||
|
if (err.code == 'ENOENT') {
|
||||||
|
findConfigs() // check next gypi filename
|
||||||
|
} else {
|
||||||
|
callback(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
configs.push(fullPath);
|
||||||
|
findConfigs()
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function runGyp (err) {
|
function runGyp (err) {
|
||||||
|
@ -349,8 +371,10 @@ function configure (gyp, argv, callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// include the "config.gypi" file that was generated
|
// include all the ".gypi" files that were found
|
||||||
argv.push('-I', configPath)
|
configs.forEach(function (config) {
|
||||||
|
argv.push('-I', config)
|
||||||
|
})
|
||||||
|
|
||||||
// this logic ported from the old `gyp_addon` python file
|
// this logic ported from the old `gyp_addon` python file
|
||||||
var gyp_script = path.resolve(nodeDir, 'tools', 'gyp', 'gyp')
|
var gyp_script = path.resolve(nodeDir, 'tools', 'gyp', 'gyp')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue