@@ -922,6 +922,8 @@ def detect_fixed_language_mode(args):
922
922
if separate_asm :
923
923
shared .Settings .SEPARATE_ASM = os .path .basename (asm_target )
924
924
925
+ system_js_libraries = []
926
+
925
927
# Find library files
926
928
for i , lib in libs :
927
929
logging .debug ('looking for library "%s"' , lib )
@@ -938,14 +940,39 @@ def detect_fixed_language_mode(args):
938
940
break
939
941
if found : break
940
942
if found : break
941
- if not found and lib not in ['GL' , 'GLU' , 'glut' , 'm' , 'c' , 'SDL' , 'stdc++' , 'pthread' ]: # whitelist our default libraries
942
- emscripten_strict_mode = (os .environ .get ('EMSCRIPTEN_STRICT' ) and int (os .environ .get ('EMSCRIPTEN_STRICT' )) != 0 ) or 'EMSCRIPTEN_STRICT=1' in settings_changes
943
- error_on_missing_libraries = (emscripten_strict_mode and not 'ERROR_ON_MISSING_LIBRARIES=0' in settings_changes ) or 'ERROR_ON_MISSING_LIBRARIES=1' in settings_changes
944
- if error_on_missing_libraries :
945
- logging .fatal ('emcc: cannot find library "%s"' , lib )
946
- exit (1 )
943
+ if not found :
944
+ # Some native libraries are implemented in Emscripten as system side JS libraries
945
+ js_system_libraries = {
946
+ 'c' : '' ,
947
+ 'EGL' : 'library_egl.js' ,
948
+ 'GL' : 'library_gl.js' ,
949
+ 'GLESv2' : 'library_gl.js' ,
950
+ 'GLEW' : 'library_glew.js' ,
951
+ 'glfw' : 'library_glfw.js' ,
952
+ 'glfw3' : 'library_glfw.js' ,
953
+ 'GLU' : '' ,
954
+ 'glut' : 'library_glut.js' ,
955
+ 'm' : '' ,
956
+ 'openal' : 'library_openal.js' ,
957
+ 'pthread' : '' ,
958
+ 'SDL' : 'library_sdl.js' ,
959
+ 'stdc++' : ''
960
+ }
961
+ if lib in js_system_libraries :
962
+ if len (js_system_libraries [lib ]) > 0 :
963
+ system_js_libraries += [js_system_libraries [lib ]]
964
+ elif lib .endswith ('.js' ) and os .path .isfile (shared .path_from_root ('src' , 'library_' + lib )):
965
+ system_js_libraries += ['library_' + lib ]
947
966
else :
948
- logging .warning ('emcc: cannot find library "%s"' , lib )
967
+ emscripten_strict_mode = (os .environ .get ('EMSCRIPTEN_STRICT' ) and int (os .environ .get ('EMSCRIPTEN_STRICT' )) != 0 ) or 'EMSCRIPTEN_STRICT=1' in settings_changes
968
+ error_on_missing_libraries = (emscripten_strict_mode and not 'ERROR_ON_MISSING_LIBRARIES=0' in settings_changes ) or 'ERROR_ON_MISSING_LIBRARIES=1' in settings_changes
969
+ if error_on_missing_libraries :
970
+ logging .fatal ('emcc: cannot find library "%s"' , lib )
971
+ exit (1 )
972
+ else :
973
+ logging .warning ('emcc: cannot find library "%s"' , lib )
974
+
975
+ settings_changes .append ('SYSTEM_JS_LIBRARIES="' + ',' .join (system_js_libraries ) + '"' )
949
976
950
977
# If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so
951
978
# ignore dynamic linking, since multiple dynamic linkings can interfere with each other
0 commit comments