Skip to content

Commit

Permalink
Revert "Move all js library decisions to a single location (emscripte…
Browse files Browse the repository at this point in the history
…n-core#8428)"

This reverts commit fb9b1dd.
  • Loading branch information
VirtualTim authored May 23, 2019
1 parent 8fd4463 commit bbaa38f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
6 changes: 4 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ def get_last_setting_change(setting):
if error_on_missing_libraries_cmdline:
shared.Settings.ERROR_ON_MISSING_LIBRARIES = int(error_on_missing_libraries_cmdline[len('ERROR_ON_MISSING_LIBRARIES='):])

settings_changes.append(process_libraries(libs, lib_dirs, input_files))
settings_changes.append(process_libraries(libs, lib_dirs, settings_changes, input_files))

# If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so
# ignore dynamic linking, since multiple dynamic linkings can interfere with each other
Expand Down Expand Up @@ -3138,7 +3138,7 @@ def worker_js_script(proxy_worker_filename):
return web_gl_client_src + '\n' + proxy_client_src


def process_libraries(libs, lib_dirs, input_files):
def process_libraries(libs, lib_dirs, settings_changes, input_files):
libraries = []

# Find library files
Expand All @@ -3162,6 +3162,8 @@ def process_libraries(libs, lib_dirs, input_files):
if not found:
libraries += shared.Building.path_to_system_js_libraries(lib)

# Certain linker flags imply some link libraries to be pulled in by default.
libraries += shared.Building.path_to_system_js_libraries_for_settings(settings_changes)
return 'SYSTEM_JS_LIBRARIES="' + ','.join(libraries) + '"'


Expand Down
19 changes: 3 additions & 16 deletions src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ var LibraryManager = {

// Additional filesystem libraries (in strict mode, link to these explicitly via -lxxx.js)
if (!STRICT && !MINIMAL_RUNTIME) {
libraries = libraries.concat([
'library_lz4.js',
]);
if (ENVIRONMENT_MAY_BE_WEB || ENVIRONMENT_MAY_BE_WORKER) {
libraries = libraries.concat([
'library_idbfs.js',
Expand Down Expand Up @@ -118,27 +121,13 @@ var LibraryManager = {
'library_idbstore.js',
'library_async.js'
]);
} else {
if (EMTERPRETIFY_ASYNC || ASYNCIFY) {
libraries.push('library_async.js');
}
if (USE_SDL == 1) {
libraries.push('library_sdl.js');
}
if (USE_SDL == 2) {
libraries.push('library_egl.js', 'library_webgl.js');
}
}

// If there are any explicitly specified system JS libraries to link to, add those to link.
if (SYSTEM_JS_LIBRARIES) {
libraries = libraries.concat(SYSTEM_JS_LIBRARIES.split(','));
}

if (LZ4) {
libraries.push('library_lz4.js');
}

if (USE_WEBGL2) {
libraries.push('library_webgl2.js');
}
Expand All @@ -155,8 +144,6 @@ var LibraryManager = {
LibraryManager.library = {};
}

// TODO: deduplicate libraries (not needed for correctness, but avoids unnecessary work)

// Save the list for has() queries later.
this.libraries = libraries;

Expand Down
19 changes: 19 additions & 0 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,25 @@ def path_to_system_js_libraries(library_name):

return library_files

@staticmethod
# Given a list of Emscripten link settings, returns a list of paths to system JS libraries
# that should get linked automatically in to the build when those link settings are present.
def path_to_system_js_libraries_for_settings(link_settings):
system_js_libraries = []
if 'EMTERPRETIFY_ASYNC=1' in link_settings:
system_js_libraries += ['library_async.js']
if 'ASYNCIFY=1' in link_settings:
system_js_libraries += ['library_async.js']
if 'LZ4=1' in link_settings:
system_js_libraries += ['library_lz4.js']
if 'USE_SDL=1' in link_settings:
system_js_libraries += ['library_sdl.js']
if 'USE_SDL=2' in link_settings:
system_js_libraries += ['library_egl.js', 'library_webgl.js']
if 'USE_WEBGL2=1' in link_settings:
system_js_libraries += ['library_webgl2.js']
return [path_from_root('src', x) for x in system_js_libraries]

@staticmethod
def get_binaryen_feature_flags():
# start with the MVP features, add the rest as needed
Expand Down

0 comments on commit bbaa38f

Please sign in to comment.