tools: fix config serialization w/ long strings

So that “config.gypi” gets serialized correctly in cases such as:

    ./configure --v8-options='--write-protect-code-memory \
    --wasm-write-protect-code-memory'

Where “v8_options” gets prettyprinted into a multiline string.

PR-URL: https://github.com/nodejs/node/pull/35982
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
pull/35961/head
Ole André Vadla Ravnås 2020-11-05 21:47:47 +01:00 committed by Node.js GitHub Bot
parent 35274cbddf
commit f6ada622b7
1 changed files with 3 additions and 1 deletions

View File

@ -163,9 +163,11 @@ def handle_config_gypi(config_filename):
def jsonify(config):
# 1. string comments
config = re.sub(r'#.*?\n', '', config)
# 2. join multiline strings
config = re.sub(r"'$\s+'", '', config, flags=re.M)
# 3. normalize string literals from ' into "
config = re.sub('\'', '"', config)
# 2. turn pseudo-booleans strings into Booleans
# 4. turn pseudo-booleans strings into Booleans
config = re.sub('"true"', 'true', config)
config = re.sub('"false"', 'false', config)
return config