Skip to content

Commit

Permalink
Rename system library files from library_foo.js to libfoo.js
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbc100 committed Jan 17, 2025
1 parent 186cae3 commit 31a7e36
Show file tree
Hide file tree
Showing 90 changed files with 212 additions and 155 deletions.
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ def consume_arg_file():
options.memory_profiler = True
newargs[i] = ''
settings_changes.append('EMSCRIPTEN_TRACING=1')
settings.JS_LIBRARIES.append('library_trace.js')
settings.JS_LIBRARIES.append('libtrace.js')
elif check_flag('--emit-symbol-map'):
options.emit_symbol_map = True
settings.EMIT_SYMBOL_MAP = 1
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default [{
'**/third_party/',
'**/test/',
'src/polyfill/',
'src/library*.js',
'src/lib/',
'src/runtime_*.js',
'src/shell*.js',
'src/preamble*.js',
Expand Down
2 changes: 1 addition & 1 deletion src/jsifier.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ function(${args}) {
return dep();
}
// $noExitRuntime is special since there are conditional usages of it
// in library.js and library_pthread.js. These happen before deps are
// in libcore.js and libpthread.js. These happen before deps are
// processed so depending on it via `__deps` doesn't work.
if (dep === '$noExitRuntime') {
error(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/library_bootstrap.js → src/lib/libbootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// it itself depends on the struct info information.

#if !BOOTSTRAPPING_STRUCT_INFO
assert(false, "library_bootstrap.js only designed for use with BOOTSTRAPPING_STRUCT_INFO")
assert(false, "libbootstrap.js only designed for use with BOOTSTRAPPING_STRUCT_INFO")
#endif

assert(Object.keys(LibraryManager.library).length === 0);
Expand Down
2 changes: 1 addition & 1 deletion src/library_browser.js → src/lib/libbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ var LibraryBrowser = {
alpha: false,
#if MIN_WEBGL_VERSION >= 2
majorVersion: 2,
#elif MAX_WEBGL_VERSION >= 2 // library_browser.js defaults: use the WebGL version chosen at compile time (unless overridden below)
#elif MAX_WEBGL_VERSION >= 2 // libbrowser.js defaults: use the WebGL version chosen at compile time (unless overridden below)
majorVersion: (typeof WebGL2RenderingContext != 'undefined') ? 2 : 1,
#else
majorVersion: 1,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/embind/embind.js → src/lib/libembind.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/*global throwInstanceAlreadyDeleted, shallowCopyInternalPointer*/
/*global RegisteredPointer_fromWireType, constNoSmartPtrRawPointerToWireType, nonConstNoSmartPtrRawPointerToWireType, genericPointerToWireType*/

#include "embind_shared.js"
#include "libembind_shared.js"

var LibraryEmbind = {
$UnboundTypeError__postset: "UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');",
Expand Down
2 changes: 1 addition & 1 deletion src/embind/embind_gen.js → src/lib/libembind_gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Emscripten is available under two separate licenses, the MIT license and the
// University of Illinois/NCSA Open Source License. Both these licenses can be
// found in the LICENSE file.
#include "embind_shared.js"
#include "libembind_shared.js"

var LibraryEmbind = {

Expand Down
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.
18 changes: 9 additions & 9 deletions src/library_fs.js → src/lib/libfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ addToLibrary({
'$intArrayFromString',
'$stringToUTF8Array',
'$lengthBytesUTF8',
#if LibraryManager.has('library_idbfs.js')
#if LibraryManager.has('libidbfs.js')
'$IDBFS',
#endif
#if LibraryManager.has('library_nodefs.js')
#if LibraryManager.has('libnodefs.js')
'$NODEFS',
#endif
#if LibraryManager.has('library_workerfs.js')
#if LibraryManager.has('libworkerfs.js')
'$WORKERFS',
#endif
#if LibraryManager.has('library_noderawfs.js')
#if LibraryManager.has('libnoderawfs.js')
'$NODERAWFS',
#endif
#if LibraryManager.has('library_proxyfs.js')
#if LibraryManager.has('libproxyfs.js')
'$PROXYFS',
#endif
#if ASSERTIONS
Expand Down Expand Up @@ -1510,16 +1510,16 @@ FS.staticInit();

FS.filesystems = {
'MEMFS': MEMFS,
#if LibraryManager.has('library_idbfs.js')
#if LibraryManager.has('libidbfs.js')
'IDBFS': IDBFS,
#endif
#if LibraryManager.has('library_nodefs.js')
#if LibraryManager.has('libnodefs.js')
'NODEFS': NODEFS,
#endif
#if LibraryManager.has('library_workerfs.js')
#if LibraryManager.has('libworkerfs.js')
'WORKERFS': WORKERFS,
#endif
#if LibraryManager.has('library_proxyfs.js')
#if LibraryManager.has('libproxyfs.js')
'PROXYFS': PROXYFS,
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion src/library_fs_shared.js → src/lib/libfs_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ addToLibrary({
$FS_handledByPreloadPlugin__internal: true,
$FS_handledByPreloadPlugin__deps: ['$preloadPlugins'],
$FS_handledByPreloadPlugin: (byteArray, fullname, finish, onerror) => {
#if LibraryManager.has('library_browser.js')
#if LibraryManager.has('libbrowser.js')
// Ensure plugins are ready.
if (typeof Browser != 'undefined') Browser.init();
#endif
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/library_html5_webgl.js → src/lib/libhtml5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function handleWebGLProxying(funcs) {

handleWebGLProxying(LibraryHtml5WebGL);

#if LibraryManager.has('library_webgl.js')
#if LibraryManager.has('libwebgl.js')
autoAddDeps(LibraryHtml5WebGL, '$GL');
#endif

Expand Down
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.
12 changes: 6 additions & 6 deletions src/library_wasmfs.js → src/lib/libwasmfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ FS.init();
'$FS_mkdirTree',
'$FS_writeFile',
'$FS_unlink',
#if LibraryManager.has('library_icasefs.js')
#if LibraryManager.has('libicasefs.js')
'$ICASEFS',
#endif
#if LibraryManager.has('library_nodefs.js')
#if LibraryManager.has('libnodefs.js')
'$NODEFS',
#endif
#if LibraryManager.has('library_opfs.js')
#if LibraryManager.has('libopfs.js')
'$OPFS',
#endif
#if LibraryManager.has('library_jsfilefs.js')
#if LibraryManager.has('libjsfilefs.js')
'$JSFILEFS',
#endif
#if LibraryManager.has('library_fetchfs.js')
#if LibraryManager.has('libfetchfs.js')
'$FETCHFS',
#endif
'malloc',
Expand Down Expand Up @@ -482,7 +482,7 @@ FS.init();
// need some specific FS_* operations. When the FS object is present, it calls
// into those FS_* methods as needed.
//
// In contrast, the old JS FS (library_fs.js) does the opposite: it puts all
// In contrast, the old JS FS (libfs.js) does the opposite: it puts all
// things on the FS object, and copies them to FS_* methods for use from JS
// library code. Given that the JS FS is implemented entirely in JS, that
// makes sense there (as almost all that FS object ends up needed anyhow all
Expand Down
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.
Loading

0 comments on commit 31a7e36

Please sign in to comment.