-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Conversation
tools/js2c.py
Outdated
# 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 = json.dumps(eval(lines)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is code for similar purposes in tools/install.py
and it only does:
Lines 23 to 24 in a8b5192
s = re.sub(r'#.*?\n', '', s) # strip comments | |
s = re.sub(r'\'', '"', s) # convert quotes |
Maybe we can just do the same so don't have to eval
the config then redump it here..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo eval is cleaner, what if (for some ungodly reason) a config value has an escaped quote in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does the right thing. config.gypi
is produced by pprint.pformat()
and always uses single quotes for strings. \'hola\'
becomes \"hola\"
and that's legal JSON.
no good on windows |
something somewhere is matching edit: i think its happening here? but i don't know where its being called. i'm still searching around |
fwiw the commit prefix should be with a comma, probably either |
It seems that (The code link points to where Fs load points in bootstrapOn BSD that happens here: node/lib/internal/bootstrap_node.js Lines 78 to 81 in 1d2ab79
If ESM is enabled, it is possible that this tree of loads loads node/lib/internal/bootstrap_node.js Lines 106 to 110 in 1d2ab79
If there are node/lib/internal/bootstrap_node.js Lines 583 to 586 in 1d2ab79
Otherwise, node/lib/internal/bootstrap_node.js Line 201 in 1d2ab79
|
# 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
landed in 7314b17 |
PR-URL: #19140 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: #19140 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: #19140 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: nodejs#19140 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: #19140 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
bootstrap, tools