Skip to content

Commit bf5d63c

Browse files
authored
Fix makeRemovedFSAssert() resolved path (#24567)
This fixes an issue where `path.resolve()` resolves using the CWD (which is usually the target project path) instead of the directory of the script itself. The current behavior [causes issues with the Closure compiler](godotengine/godot#107460 (comment)), as stubs are erroneously created instead of being skipped in `src/shell.js`. Closure then complains that variables are declared twice. The issue was caused by #23348 which changed the logic of the search.
1 parent c38fe09 commit bf5d63c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/parseTools.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
runInMacroContext,
2020
pushCurrentFile,
2121
popCurrentFile,
22+
localFile,
2223
warn,
2324
srcDir,
2425
} from './utility.mjs';
@@ -921,7 +922,7 @@ function makeModuleReceiveWithVar(localName, moduleName, defaultValue) {
921922
function makeRemovedFSAssert(fsName) {
922923
assert(ASSERTIONS);
923924
const lower = fsName.toLowerCase();
924-
if (JS_LIBRARIES.includes(path.resolve(path.join('lib', `lib${lower}.js`)))) return '';
925+
if (JS_LIBRARIES.includes(localFile(path.join('lib', `lib${lower}.js`)))) return '';
925926
return `var ${fsName} = '${fsName} is no longer included by default; build with -l${lower}.js';`;
926927
}
927928

test/test_other.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16234,3 +16234,18 @@ def test_libcxx_errors(self):
1623416234
# and in debug mode at least we expect to see the error message from libc++
1623516235
expected = 'system_error was thrown in -fno-exceptions mode with error 6 and message "thread constructor failed"'
1623616236
self.do_runf('main.cpp', expected, assert_returncode=NON_ZERO)
16237+
16238+
def test_parsetools_make_removed_fs_assert(self):
16239+
"""
16240+
This tests that parseTools.mjs `makeRemovedFSAssert()` works as intended,
16241+
if it creates a stub when a builtin library isn't included, but not when
16242+
it is.
16243+
"""
16244+
16245+
removed_fs_assert_content = "IDBFS is no longer included by default"
16246+
16247+
self.emcc(test_file('hello_world.c'), output_filename='hello_world.js')
16248+
self.assertContained(removed_fs_assert_content, read_file('hello_world.js'))
16249+
16250+
self.emcc(test_file('hello_world.c'), ['-lidbfs.js'], output_filename='hello_world.js')
16251+
self.assertNotContained(removed_fs_assert_content, read_file('hello_world.js'))

0 commit comments

Comments
 (0)