32
32
from .shared import LLVM_DWARFDUMP , demangle_c_symbol_name
33
33
from .shared import get_emscripten_temp_dir , exe_suffix , is_c_symbol
34
34
from .utils import WINDOWS
35
- from .settings import settings , default_setting
35
+ from .settings import settings
36
36
from .feature_matrix import UNSUPPORTED
37
37
38
38
logger = logging .getLogger ('building' )
46
46
user_requested_exports : Set [str ] = set ()
47
47
48
48
49
- # .. but for Popen, we cannot have doublequotes, so provide functionality to
50
- # remove them when needed.
51
- def remove_quotes (arg ):
52
- if isinstance (arg , list ):
53
- return [remove_quotes (a ) for a in arg ]
54
-
55
- if arg .startswith ('"' ) and arg .endswith ('"' ):
56
- return arg [1 :- 1 ].replace ('\\ "' , '"' )
57
- elif arg .startswith ("'" ) and arg .endswith ("'" ):
58
- return arg [1 :- 1 ].replace ("\\ '" , "'" )
59
- else :
60
- return arg
61
-
62
-
63
49
def get_building_env ():
64
50
cache .ensure ()
65
51
env = os .environ .copy ()
@@ -1063,34 +1049,15 @@ def handle_final_wasm_symbols(wasm_file, symbols_file, debug_info):
1063
1049
1064
1050
1065
1051
def is_ar (filename ):
1052
+ """Return True if a the given filename is an ar archive, False otherwise.
1053
+ """
1066
1054
try :
1067
- if _is_ar_cache .get (filename ):
1068
- return _is_ar_cache [filename ]
1069
1055
header = open (filename , 'rb' ).read (8 )
1070
- sigcheck = header in (b'!<arch>\n ' , b'!<thin>\n ' )
1071
- _is_ar_cache [filename ] = sigcheck
1072
- return sigcheck
1073
1056
except Exception as e :
1074
1057
logger .debug ('is_ar failed to test whether file \' %s\' is a llvm archive file! Failed on exception: %s' % (filename , e ))
1075
1058
return False
1076
1059
1077
-
1078
- def is_bitcode (filename ):
1079
- try :
1080
- # look for magic signature
1081
- b = open (filename , 'rb' ).read (4 )
1082
- if b [:2 ] == b'BC' :
1083
- return True
1084
- # on macOS, there is a 20-byte prefix which starts with little endian
1085
- # encoding of 0x0B17C0DE
1086
- elif b == b'\xDE \xC0 \x17 \x0B ' :
1087
- b = bytearray (open (filename , 'rb' ).read (22 ))
1088
- return b [20 :] == b'BC'
1089
- except IndexError :
1090
- # not enough characters in the input
1091
- # note that logging will be done on the caller function
1092
- pass
1093
- return False
1060
+ return header in (b'!<arch>\n ' , b'!<thin>\n ' )
1094
1061
1095
1062
1096
1063
def is_wasm (filename ):
@@ -1113,85 +1080,6 @@ def is_wasm_dylib(filename):
1113
1080
return False
1114
1081
1115
1082
1116
- def map_to_js_libs (library_name ):
1117
- """Given the name of a special Emscripten-implemented system library, returns an
1118
- pair containing
1119
- 1. Array of absolute paths to JS library files, inside emscripten/src/ that corresponds to the
1120
- library name. `None` means there is no mapping and the library will be processed by the linker
1121
- as a require for normal native library.
1122
- 2. Optional name of a corresponding native library to link in.
1123
- """
1124
- # Some native libraries are implemented in Emscripten as system side JS libraries
1125
- library_map = {
1126
- 'embind' : ['embind/embind.js' , 'embind/emval.js' ],
1127
- 'EGL' : ['library_egl.js' ],
1128
- 'GL' : ['library_webgl.js' , 'library_html5_webgl.js' ],
1129
- 'webgl.js' : ['library_webgl.js' , 'library_html5_webgl.js' ],
1130
- 'GLESv2' : ['library_webgl.js' ],
1131
- # N.b. there is no GLESv3 to link to (note [f] in https://www.khronos.org/registry/implementers_guide.html)
1132
- 'GLEW' : ['library_glew.js' ],
1133
- 'glfw' : ['library_glfw.js' ],
1134
- 'glfw3' : ['library_glfw.js' ],
1135
- 'GLU' : [],
1136
- 'glut' : ['library_glut.js' ],
1137
- 'openal' : ['library_openal.js' ],
1138
- 'X11' : ['library_xlib.js' ],
1139
- 'SDL' : ['library_sdl.js' ],
1140
- 'uuid' : ['library_uuid.js' ],
1141
- 'fetch' : ['library_fetch.js' ],
1142
- 'websocket' : ['library_websocket.js' ],
1143
- # These 4 libraries are separate under glibc but are all rolled into
1144
- # libc with musl. For compatibility with glibc we just ignore them
1145
- # completely.
1146
- 'dl' : [],
1147
- 'm' : [],
1148
- 'rt' : [],
1149
- 'pthread' : [],
1150
- # This is the name of GNU's C++ standard library. We ignore it here
1151
- # for compatibility with GNU toolchains.
1152
- 'stdc++' : [],
1153
- }
1154
- settings_map = {
1155
- 'glfw' : {'USE_GLFW' : 2 },
1156
- 'glfw3' : {'USE_GLFW' : 3 },
1157
- 'SDL' : {'USE_SDL' : 1 },
1158
- }
1159
-
1160
- if library_name in settings_map :
1161
- for key , value in settings_map [library_name ].items ():
1162
- default_setting (key , value )
1163
-
1164
- if library_name in library_map :
1165
- libs = library_map [library_name ]
1166
- logger .debug ('Mapping library `%s` to JS libraries: %s' % (library_name , libs ))
1167
- return libs
1168
-
1169
- if library_name .endswith ('.js' ) and os .path .isfile (path_from_root ('src' , f'library_{ library_name } ' )):
1170
- return [f'library_{ library_name } ' ]
1171
-
1172
- return None
1173
-
1174
-
1175
- # Map a linker flag to a settings. This lets a user write -lSDL2 and it will
1176
- # have the same effect as -sUSE_SDL=2.
1177
- def map_and_apply_to_settings (library_name ):
1178
- # most libraries just work, because the -l name matches the name of the
1179
- # library we build. however, if a library has variations, which cause us to
1180
- # build multiple versions with multiple names, then we need this mechanism.
1181
- library_map = {
1182
- # SDL2_mixer's built library name contains the specific codecs built in.
1183
- 'SDL2_mixer' : [('USE_SDL_MIXER' , 2 )],
1184
- }
1185
-
1186
- if library_name in library_map :
1187
- for key , value in library_map [library_name ]:
1188
- logger .debug ('Mapping library `%s` to settings changes: %s = %s' % (library_name , key , value ))
1189
- setattr (settings , key , value )
1190
- return True
1191
-
1192
- return False
1193
-
1194
-
1195
1083
def emit_wasm_source_map (wasm_file , map_file , final_wasm ):
1196
1084
# source file paths must be relative to the location of the map (which is
1197
1085
# emitted alongside the wasm)
0 commit comments