Skip to content

Commit 9613e02

Browse files
devsnekMylesBorins
authored andcommitted
tools,bootstrap: preprocess gypi files to json
PR-URL: #19140 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 5a1437c commit 9613e02

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/internal/process.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,9 @@ function setupMemoryUsage() {
118118
function setupConfig(_source) {
119119
// NativeModule._source
120120
// used for `process.config`, but not a real module
121-
var config = _source.config;
121+
const config = _source.config;
122122
delete _source.config;
123123

124-
// strip the gyp comment line at the beginning
125-
config = config.split('\n')
126-
.slice(1)
127-
.join('\n')
128-
.replace(/"/g, '\\"')
129-
.replace(/'/g, '"');
130-
131124
process.config = JSON.parse(config, function(key, value) {
132125
if (value === 'true') return true;
133126
if (value === 'false') return false;

tools/js2c.py

+5
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ def JS2C(source, target):
261261
if '/' in name or '\\' in name:
262262
name = '/'.join(re.split('/|\\\\', name)[1:])
263263

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

0 commit comments

Comments
 (0)