Permalink
Browse files

tools,bootstrap: preprocess gypi files to json

PR-URL: #19140
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information...
devsnek committed Mar 5, 2018
1 parent 099e621 commit 7314b170a49fd5f24ef91f95dfc6ee3bf93b73ae
Showing with 6 additions and 8 deletions.
  1. +1 −8 lib/internal/process.js
  2. +5 −0 tools/js2c.py
@@ -128,16 +128,9 @@ function setupMemoryUsage() {
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;
@@ -292,6 +292,11 @@ def JS2C(source, target):
split = split[1:]
name = '/'.join(split)

# 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

1 comment on commit 7314b17

@bnoordhuis

This comment has been minimized.

Copy link
Member

bnoordhuis commented on 7314b17 Mar 29, 2018

For posterity, fixes #18930.

Please sign in to comment.