Skip to content

Commit 18c483b

Browse files
committed
tools: dump config.gypi as json
1 parent 8eaa243 commit 18c483b

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

configure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2437,8 +2437,9 @@ def make_bin_override():
24372437

24382438
print_verbose(output)
24392439

2440+
# Dump as JSON to allow js2c.cc read it as a simple json file.
24402441
write('config.gypi', do_not_edit +
2441-
pprint.pformat(output, indent=2, width=128) + '\n')
2442+
json.dumps(output, indent=2) + '\n')
24422443

24432444
write('config.status', '#!/bin/sh\nset -x\nexec ./configure ' +
24442445
' '.join([shlex.quote(arg) for arg in original_argv]) + '\n')

test/parallel/test-process-config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ let config = fs.readFileSync(configPath, 'utf8');
4949

5050
// Clean up comment at the first line.
5151
config = config.split('\n').slice(1).join('\n');
52-
config = config.replace(/"/g, '\\"');
53-
config = config.replace(/'/g, '"');
52+
// Turn pseudo-booleans strings into booleans.
5453
config = JSON.parse(config, (key, value) => {
5554
if (value === 'true') return true;
5655
if (value === 'false') return false;

tools/js2c.cc

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -796,21 +796,11 @@ std::vector<char> JSONify(const std::vector<char>& code) {
796796
// 1. Remove string comments
797797
std::vector<char> stripped = StripComments(code);
798798

799-
// 2. join multiline strings
800-
std::vector<char> joined = JoinMultilineString(stripped);
799+
// 2. turn pseudo-booleans strings into Booleans
800+
std::vector<char> result1 = ReplaceAll(stripped, R"("true")", "true");
801+
std::vector<char> result2 = ReplaceAll(result1, R"("false")", "false");
801802

802-
// 3. normalize string literals from ' into "
803-
for (size_t i = 0; i < joined.size(); ++i) {
804-
if (joined[i] == '\'') {
805-
joined[i] = '"';
806-
}
807-
}
808-
809-
// 4. turn pseudo-booleans strings into Booleans
810-
std::vector<char> result3 = ReplaceAll(joined, R"("true")", "true");
811-
std::vector<char> result4 = ReplaceAll(result3, R"("false")", "false");
812-
813-
return result4;
803+
return result2;
814804
}
815805

816806
int AddGypi(const std::string& var,

0 commit comments

Comments
 (0)