diff --git a/ChangeLog.md b/ChangeLog.md index 104d5f017105e..ead54a346cbae 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -22,6 +22,11 @@ See docs/process.md for more on how version tagging works. ----------------------- - `-z` arguments are now passed directly to wasm-ld without the need for the `-Wl,` prefix. This matches the behaviour of both clang and gcc. (#18956) +- Reverted #18525 which runs the JS pre-processor over files passed via + --pre-js and --post-js. It turned out this change caused issue for several + folks who had JS files with lines that start with `#` so can't be run through + the pre-processor. If folks want to re-enable this we can looks into ways to + make it conditional/optional. 3.1.34 - 03/14/23 ----------------- diff --git a/src/jsifier.js b/src/jsifier.js index 01faabd03da42..804355b3e8ec3 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -457,6 +457,12 @@ function ${name}(${args}) { print(`// end include: ${fileName}`); } + function includeFileRaw(fileName) { + print(`// include: ${fileName}`); + print(read(fileName)); + print(`// end include: ${fileName}`); + } + function finalCombiner() { const splitPostSets = splitter(postSets, (x) => x.symbol && x.dependencies); postSets = splitPostSets.leftIn; @@ -525,7 +531,7 @@ function ${name}(${args}) { includeFile(postFile); for (const fileName of POST_JS_FILES) { - includeFile(fileName); + includeFileRaw(fileName); } print('//FORWARDED_DATA:' + JSON.stringify({ diff --git a/src/parseTools.js b/src/parseTools.js index 49d569ad55290..be894884d048f 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -991,7 +991,7 @@ function getEntryFunction() { function preJS() { let result = ''; for (const fileName of PRE_JS_FILES) { - result += preprocess(fileName); + result += read(fileName); } return result; } diff --git a/test/test_other.py b/test/test_other.py index 9b5376b8485c5..a41b1cfa83e71 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -9295,21 +9295,6 @@ def test_js_preprocess(self): self.assertContained('JSLIB: EXIT_RUNTIME', err) self.assertNotContained('JSLIB: MAIN_MODULE', err) - def test_js_preprocess_pre_post(self): - create_file('pre.js', ''' - #if ASSERTIONS - console.log('assertions enabled') - #else - console.log('assertions disabled') - #endif - ''') - create_file('post.js', ''' - console.log({{{ POINTER_SIZE }}}); - ''') - self.emcc_args += ['--pre-js', 'pre.js', '--post-js', 'post.js'] - self.do_runf(test_file('hello_world.c'), 'assertions enabled\n4') - self.do_runf(test_file('hello_world.c'), 'assertions disabled\n4', emcc_args=['-sASSERTIONS=0']) - def test_html_preprocess(self): src_file = test_file('module/test_stdin.c') output_file = 'test_stdin.html'