Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/bootstrap_node: preprocess gypi files to json #19140

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,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;
Expand Down
5 changes: 5 additions & 0 deletions tools/js2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does python maybe offer a package that converts a dict into json? That would be cleaner than replacing characters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. missed that context. thanks.

lines = re.sub(r'\'', '"', lines)
name = name.split('.', 1)[0]
var = name.replace('-', '_').replace('/', '_')
key = '%s_key' % var
Expand Down