Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert pre-processing of pre/post JS files #19006

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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