From 23dd2b00dd333592089e4b1a73e94511203e9cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 5 Nov 2020 21:47:47 +0100 Subject: [PATCH] tools: fix config serialization w/ long strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Joyee Cheung Reviewed-By: Richard Lau Reviewed-By: Rich Trott --- tools/js2c.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/js2c.py b/tools/js2c.py index 195e6a6189a989..0f073e182bdb28 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -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