Skip to content

Commit

Permalink
Make paths in output gypi file relative to its location.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrv committed Aug 9, 2015
1 parent c91c97d commit 55fa335
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions autogypi.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,14 @@ function findDepends(confPath, dependList, resolver, result) {
} else {
// No configuration file found, try to do something useful for
// hopefully getting the module included. This is enough for nan.
result.gypi['include_dirs'].push(modulePath);
result.gypi['include_dirs'].push(path.relative(result.outputDir, modulePath));
}
}
}

/** Parse an autogypi.json configuration file.
* @param {string} confPath Path to configuration file to parse.
* @param {Object.<string, *>} conf Configuration file contents as an object.
* @param {*} resolver Like resolver function defined in this file, but possibly executing in the context of another module.
* @param {*} resolverPrev Like resolver function defined in this file, but possibly executing in the context of another module.
* @param {{gypi: *}} result Object that forms the output .gypi file when written out as JSON. */
function parseConf(confPath, resolverPrev, result) {
var conf = link.readConf(confPath);
Expand All @@ -107,6 +106,15 @@ function parseConf(confPath, resolverPrev, result) {
* @return {Array.<string>} Full paths to modules. */
var resolver;

if(!result.outputPath) {
if(!conf['output']) {
throw('"output" property with output file path is missing from configuration file ' + confPath);
}

result.outputPath = path.resolve(path.dirname(confPath), conf['output']);
result.outputDir = path.dirname(result.outputPath);
}

if(!resolverPath) resolverPath = 'autoresolver.js';
resolverPath = path.resolve(path.dirname(confPath), resolverPath);

Expand Down Expand Up @@ -135,7 +143,7 @@ function parseConf(confPath, resolverPrev, result) {
Array.prototype.push.apply(
result.gypi['includes'],
includeList.map(function(includePath) {
return(path.relative('.', path.join(path.dirname(confPath), includePath)));
return(path.relative(result.outputDir, path.join(path.dirname(confPath), includePath)));
})
);
}
Expand Down Expand Up @@ -163,12 +171,6 @@ if(fs.statSync(confPath).isDirectory()) confPath = path.join(confPath, 'autogypi

var conf = parseConf(confPath, null, result);

if(!conf['output']) {
throw('"output" property with output file path is missing from configuration file ' + confPath);
}

result.outputPath = path.resolve(path.dirname(confPath), conf['output']);

var header = [
'# Automatically generated file. Edits will be lost.',
'# Based on: ' + path.relative(path.dirname(result.outputPath), confPath)
Expand Down

0 comments on commit 55fa335

Please sign in to comment.