Skip to content

Commit b2dbf78

Browse files
authored
Revert preprocesing of pre/post JS files (#19006)
Reverts #18525 Fixes: #19002, #18609
1 parent 5db9a87 commit b2dbf78

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ See docs/process.md for more on how version tagging works.
2222
-----------------------
2323
- `-z` arguments are now passed directly to wasm-ld without the need for the
2424
`-Wl,` prefix. This matches the behaviour of both clang and gcc. (#18956)
25+
- Reverted #18525 which runs the JS pre-processor over files passed via
26+
--pre-js and --post-js. It turned out this change caused issue for several
27+
folks who had JS files with lines that start with `#` so can't be run through
28+
the pre-processor. If folks want to re-enable this we can looks into ways to
29+
make it conditional/optional.
2530

2631
3.1.34 - 03/14/23
2732
-----------------

src/jsifier.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,12 @@ function ${name}(${args}) {
457457
print(`// end include: ${fileName}`);
458458
}
459459

460+
function includeFileRaw(fileName) {
461+
print(`// include: ${fileName}`);
462+
print(read(fileName));
463+
print(`// end include: ${fileName}`);
464+
}
465+
460466
function finalCombiner() {
461467
const splitPostSets = splitter(postSets, (x) => x.symbol && x.dependencies);
462468
postSets = splitPostSets.leftIn;
@@ -525,7 +531,7 @@ function ${name}(${args}) {
525531
includeFile(postFile);
526532

527533
for (const fileName of POST_JS_FILES) {
528-
includeFile(fileName);
534+
includeFileRaw(fileName);
529535
}
530536

531537
print('//FORWARDED_DATA:' + JSON.stringify({

src/parseTools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ function getEntryFunction() {
991991
function preJS() {
992992
let result = '';
993993
for (const fileName of PRE_JS_FILES) {
994-
result += preprocess(fileName);
994+
result += read(fileName);
995995
}
996996
return result;
997997
}

test/test_other.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9295,21 +9295,6 @@ def test_js_preprocess(self):
92959295
self.assertContained('JSLIB: EXIT_RUNTIME', err)
92969296
self.assertNotContained('JSLIB: MAIN_MODULE', err)
92979297

9298-
def test_js_preprocess_pre_post(self):
9299-
create_file('pre.js', '''
9300-
#if ASSERTIONS
9301-
console.log('assertions enabled')
9302-
#else
9303-
console.log('assertions disabled')
9304-
#endif
9305-
''')
9306-
create_file('post.js', '''
9307-
console.log({{{ POINTER_SIZE }}});
9308-
''')
9309-
self.emcc_args += ['--pre-js', 'pre.js', '--post-js', 'post.js']
9310-
self.do_runf(test_file('hello_world.c'), 'assertions enabled\n4')
9311-
self.do_runf(test_file('hello_world.c'), 'assertions disabled\n4', emcc_args=['-sASSERTIONS=0'])
9312-
93139298
def test_html_preprocess(self):
93149299
src_file = test_file('module/test_stdin.c')
93159300
output_file = 'test_stdin.html'

0 commit comments

Comments
 (0)