Skip to content

Commit 5a3327c

Browse files
committed
Rename system library files from library_foo.js to libfoo.js
At the same time, move all the library file into a separate `src/lib` directory. This helps distinguish library files from other files in the `lib` directory, which is currently very overcrowded/overloaded. These files were also includ-able via `-lfoo` and we previously had to use a special case for system libraries where `library_foo.js` could be used in addition to more standed `libfoo.js`. This change removes to special case. This only file that was not renamed using the simple pattern was `library.py` itself which becomes `libcore.py`. I also considered `libemscripten.js`. To some this may seem like needless churn, but for years now the `src` directory (IMHO) has been asking for cleanup. I think having files logically separated into directories helps a lot with understanding the project structure for both newcomers and old timers alike. As a followup, I am also considering moving all the runtime files into `src/include` (since these are all files that get `#included` into the generated code directly. That would leave the `src` directory containing only the JS compiler code itself which I think is another important distinction.
1 parent 6c05851 commit 5a3327c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+184
-150
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ def consume_arg_file():
13101310
options.memory_profiler = True
13111311
newargs[i] = ''
13121312
settings_changes.append('EMSCRIPTEN_TRACING=1')
1313-
settings.JS_LIBRARIES.append('library_trace.js')
1313+
settings.JS_LIBRARIES.append('libtrace.js')
13141314
elif check_flag('--emit-symbol-map'):
13151315
options.emit_symbol_map = True
13161316
settings.EMIT_SYMBOL_MAP = 1

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default [{
2626
'**/third_party/',
2727
'**/test/',
2828
'src/polyfill/',
29-
'src/library*.js',
29+
'src/lib/',
3030
'src/runtime_*.js',
3131
'src/shell*.js',
3232
'src/preamble*.js',

src/jsifier.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ function(${args}) {
585585
return dep();
586586
}
587587
// $noExitRuntime is special since there are conditional usages of it
588-
// in library.js and library_pthread.js. These happen before deps are
588+
// in libcore.js and libpthread.js. These happen before deps are
589589
// processed so depending on it via `__deps` doesn't work.
590590
if (dep === '$noExitRuntime') {
591591
error(
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/library_bootstrap.js renamed to src/lib/libbootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// it itself depends on the struct info information.
99

1010
#if !BOOTSTRAPPING_STRUCT_INFO
11-
assert(false, "library_bootstrap.js only designed for use with BOOTSTRAPPING_STRUCT_INFO")
11+
assert(false, "libbootstrap.js only designed for use with BOOTSTRAPPING_STRUCT_INFO")
1212
#endif
1313

1414
assert(Object.keys(LibraryManager.library).length === 0);

src/library_browser.js renamed to src/lib/libbrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ var LibraryBrowser = {
203203
alpha: false,
204204
#if MIN_WEBGL_VERSION >= 2
205205
majorVersion: 2,
206-
#elif MAX_WEBGL_VERSION >= 2 // library_browser.js defaults: use the WebGL version chosen at compile time (unless overridden below)
206+
#elif MAX_WEBGL_VERSION >= 2 // libbrowser.js defaults: use the WebGL version chosen at compile time (unless overridden below)
207207
majorVersion: (typeof WebGL2RenderingContext != 'undefined') ? 2 : 1,
208208
#else
209209
majorVersion: 1,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/embind/embind.js renamed to src/lib/libembind.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/*global throwInstanceAlreadyDeleted, shallowCopyInternalPointer*/
2626
/*global RegisteredPointer_fromWireType, constNoSmartPtrRawPointerToWireType, nonConstNoSmartPtrRawPointerToWireType, genericPointerToWireType*/
2727

28-
#include "embind_shared.js"
28+
#include "libembind_shared.js"
2929

3030
var LibraryEmbind = {
3131
$UnboundTypeError__postset: "UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');",

src/embind/embind_gen.js renamed to src/lib/libembind_gen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Emscripten is available under two separate licenses, the MIT license and the
33
// University of Illinois/NCSA Open Source License. Both these licenses can be
44
// found in the LICENSE file.
5-
#include "embind_shared.js"
5+
#include "libembind_shared.js"
66

77
var LibraryEmbind = {
88

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/library_fs.js renamed to src/lib/libfs.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ addToLibrary({
1212
'$intArrayFromString',
1313
'$stringToUTF8Array',
1414
'$lengthBytesUTF8',
15-
#if LibraryManager.has('library_idbfs.js')
15+
#if LibraryManager.has('libidbfs.js')
1616
'$IDBFS',
1717
#endif
18-
#if LibraryManager.has('library_nodefs.js')
18+
#if LibraryManager.has('libnodefs.js')
1919
'$NODEFS',
2020
#endif
21-
#if LibraryManager.has('library_workerfs.js')
21+
#if LibraryManager.has('libworkerfs.js')
2222
'$WORKERFS',
2323
#endif
24-
#if LibraryManager.has('library_noderawfs.js')
24+
#if LibraryManager.has('libnoderawfs.js')
2525
'$NODERAWFS',
2626
#endif
27-
#if LibraryManager.has('library_proxyfs.js')
27+
#if LibraryManager.has('libproxyfs.js')
2828
'$PROXYFS',
2929
#endif
3030
#if ASSERTIONS
@@ -1510,16 +1510,16 @@ FS.staticInit();
15101510

15111511
FS.filesystems = {
15121512
'MEMFS': MEMFS,
1513-
#if LibraryManager.has('library_idbfs.js')
1513+
#if LibraryManager.has('libidbfs.js')
15141514
'IDBFS': IDBFS,
15151515
#endif
1516-
#if LibraryManager.has('library_nodefs.js')
1516+
#if LibraryManager.has('libnodefs.js')
15171517
'NODEFS': NODEFS,
15181518
#endif
1519-
#if LibraryManager.has('library_workerfs.js')
1519+
#if LibraryManager.has('libworkerfs.js')
15201520
'WORKERFS': WORKERFS,
15211521
#endif
1522-
#if LibraryManager.has('library_proxyfs.js')
1522+
#if LibraryManager.has('libproxyfs.js')
15231523
'PROXYFS': PROXYFS,
15241524
#endif
15251525
};

src/library_fs_shared.js renamed to src/lib/libfs_shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ addToLibrary({
1313
$FS_handledByPreloadPlugin__internal: true,
1414
$FS_handledByPreloadPlugin__deps: ['$preloadPlugins'],
1515
$FS_handledByPreloadPlugin: (byteArray, fullname, finish, onerror) => {
16-
#if LibraryManager.has('library_browser.js')
16+
#if LibraryManager.has('libbrowser.js')
1717
// Ensure plugins are ready.
1818
if (typeof Browser != 'undefined') Browser.init();
1919
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/library_html5_webgl.js renamed to src/lib/libhtml5_webgl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ function handleWebGLProxying(funcs) {
626626

627627
handleWebGLProxying(LibraryHtml5WebGL);
628628

629-
#if LibraryManager.has('library_webgl.js')
629+
#if LibraryManager.has('libwebgl.js')
630630
autoAddDeps(LibraryHtml5WebGL, '$GL');
631631
#endif
632632

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/library_wasmfs.js renamed to src/lib/libwasmfs.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ FS.init();
5050
'$FS_mkdirTree',
5151
'$FS_writeFile',
5252
'$FS_unlink',
53-
#if LibraryManager.has('library_icasefs.js')
53+
#if LibraryManager.has('libicasefs.js')
5454
'$ICASEFS',
5555
#endif
56-
#if LibraryManager.has('library_nodefs.js')
56+
#if LibraryManager.has('libnodefs.js')
5757
'$NODEFS',
5858
#endif
59-
#if LibraryManager.has('library_opfs.js')
59+
#if LibraryManager.has('libopfs.js')
6060
'$OPFS',
6161
#endif
62-
#if LibraryManager.has('library_jsfilefs.js')
62+
#if LibraryManager.has('libjsfilefs.js')
6363
'$JSFILEFS',
6464
#endif
65-
#if LibraryManager.has('library_fetchfs.js')
65+
#if LibraryManager.has('libfetchfs.js')
6666
'$FETCHFS',
6767
#endif
6868
'malloc',
@@ -482,7 +482,7 @@ FS.init();
482482
// need some specific FS_* operations. When the FS object is present, it calls
483483
// into those FS_* methods as needed.
484484
//
485-
// In contrast, the old JS FS (library_fs.js) does the opposite: it puts all
485+
// In contrast, the old JS FS (libfs.js) does the opposite: it puts all
486486
// things on the FS object, and copies them to FS_* methods for use from JS
487487
// library code. Given that the JS FS is implemented entirely in JS, that
488488
// makes sense there (as almost all that FS object ends up needed anyhow all
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)