Skip to content

Commit

Permalink
tools,bootstrap: preprocess gypi files to json
Browse files Browse the repository at this point in the history
PR-URL: #19140
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
devsnek authored and MylesBorins committed Aug 17, 2018
1 parent 98fe68f commit 4df93dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 1 addition & 8 deletions lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,9 @@ function setupMemoryUsage(_memoryUsage) {
function setupConfig(_source) {
// NativeModule._source
// used for `process.config`, but not a real module
var config = _source.config;
const config = _source.config;
delete _source.config;

// strip the gyp comment line at the beginning
config = config.split('\n')
.slice(1)
.join('\n')
.replace(/"/g, '\\"')
.replace(/'/g, '"');

process.config = JSON.parse(config, function(key, value) {
if (value === 'true') return true;
if (value === 'false') return false;
Expand Down
5 changes: 5 additions & 0 deletions tools/js2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def JS2C(source, target):
if '/' in name or '\\' in name:
name = '/'.join(re.split('/|\\\\', name)[1:])

# if its a gypi file we're going to want it as json
# later on anyway, so get it out of the way now
if name.endswith(".gypi"):
lines = re.sub(r'#.*?\n', '', lines)
lines = re.sub(r'\'', '"', lines)
name = name.split('.', 1)[0]
var = name.replace('-', '_').replace('/', '_')
key = '%s_key' % var
Expand Down

0 comments on commit 4df93dc

Please sign in to comment.