Skip to content

Commit 120250f

Browse files
committed
Remove magic handling of FS_xxx symbols in exportRuntime. NFC
This helps with my work towards emscripten-core#8380
1 parent 728959d commit 120250f

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

src/library_fs.js

+3
Original file line numberDiff line numberDiff line change
@@ -1863,4 +1863,7 @@ FS.staticInit();` +
18631863
*/`,
18641864
$FS_mkdirTree__deps: ['$FS'],
18651865
$FS_mkdirTree: (path, mode) => FS.mkdirTree(path, mode),
1866+
1867+
$FS_createLazyFile__deps: ['$FS'],
1868+
$FS_createLazyFile: 'FS.createLazyFile',
18661869
});

src/library_fs_shared.js

+20
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,26 @@ addToLibrary({
170170
}
171171
return FS_stdin_getChar_buffer.shift();
172172
},
173+
174+
$FS_unlink__deps: ['$FS'],
175+
$FS_unlink: 'FS.unlink',
176+
177+
$FS_mkdirTree__docs: `
178+
/**
179+
* @param {number=} mode Optionally, the mode to create in. Uses mkdir's
180+
* default if not set.
181+
*/`,
182+
$FS_mkdirTree__deps: ['$FS'],
183+
$FS_mkdirTree: (path, mode) => FS.mkdirTree(path, mode),
184+
185+
$FS_createPath__deps: ['$FS'],
186+
$FS_createPath: 'FS.createPath',
187+
188+
$FS_createDevice__deps: ['$FS'],
189+
$FS_createDevice: 'FS.createDevice',
190+
191+
$FS_readFile__deps: ['$FS'],
192+
$FS_readFile: 'FS.readFile',
173193
});
174194

175195
// Normally only the FS things that the compiler sees are needed are included.

src/modules.mjs

+6-22
Original file line numberDiff line numberDiff line change
@@ -371,23 +371,11 @@ function exportRuntime() {
371371
const EXPORTED_RUNTIME_METHODS_SET = new Set(EXPORTED_RUNTIME_METHODS);
372372

373373
// optionally export something.
374-
// in ASSERTIONS mode we show a useful error if it is used without
375-
// being exported. how we show the message depends on whether it's
376-
// a function (almost all of them) or a number.
377374
function maybeExport(name) {
378-
// HEAP objects are exported separately in updateMemoryViews
379-
if (name.startsWith('HEAP')) {
380-
return;
381-
}
382-
// if requested to be exported, export it
383-
if (EXPORTED_RUNTIME_METHODS_SET.has(name)) {
384-
let exported = name;
385-
// the exported name may differ from the internal name
386-
if (exported.startsWith('FS_')) {
387-
// this is a filesystem value, FS.x exported as FS_x
388-
exported = 'FS.' + exported.substr(3);
389-
}
390-
return `Module['${name}'] = ${exported};`;
375+
// If requested to be exported, export it. HEAP objects are exported
376+
// separately in updateMemoryViews
377+
if (EXPORTED_RUNTIME_METHODS_SET.has(name) && !name.startsWith('HEAP')) {
378+
return `Module['${name}'] = ${name};`;
391379
}
392380
}
393381

@@ -401,12 +389,6 @@ function exportRuntime() {
401389
'addOnPostRun',
402390
'addRunDependency',
403391
'removeRunDependency',
404-
'FS_createFolder',
405-
'FS_createPath',
406-
'FS_createLazyFile',
407-
'FS_createLink',
408-
'FS_createDevice',
409-
'FS_readFile',
410392
'out',
411393
'err',
412394
'callMain',
@@ -500,6 +482,8 @@ function exportRuntime() {
500482
const results = exports.filter((name) => name);
501483

502484
if (ASSERTIONS && !EXPORT_ALL) {
485+
// in ASSERTIONS mode we show a useful error if it is used without being
486+
// exported. See `unexportedRuntimeSymbol` in runtime_debug.js.
503487
const unusedLibSymbols = getUnusedLibrarySymbols();
504488
if (unusedLibSymbols.size) {
505489
results.push(addMissingLibraryStubs(unusedLibSymbols));

0 commit comments

Comments
 (0)