Skip to content

Commit

Permalink
Revert preprocesing of pre/post JS files (#19006)
Browse files Browse the repository at this point in the history
Reverts #18525

Fixes: #19002, #18609
  • Loading branch information
sbc100 committed Mar 20, 2023
1 parent 5db9a87 commit b2dbf78
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------
Expand Down
8 changes: 7 additions & 1 deletion src/jsifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 0 additions & 15 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit b2dbf78

Please sign in to comment.