You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Process --pre-js and --post-js files in jsifier.js
This teats pre and post JS files more like normal runtime and
library files which simplifies the code and avoids the special case
processing in emcc.py.
This also means that pre and post JS also now go through macro
preprocessor which should be useful in some cases.
Copy file name to clipboardExpand all lines: tools/js_manipulation.py
+15-6Lines changed: 15 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
importre
7
7
8
8
from .settingsimportsettings
9
-
from . importutils
9
+
from . importutils, shared
10
10
11
11
emscripten_license='''\
12
12
/**
@@ -28,25 +28,34 @@
28
28
emscripten_license_regex=r'\/\*\*?(\s*\*?\s*@license)?(\s*\*?\s*Copyright \d+ The Emscripten Authors\s*\*?\s*SPDX-License-Identifier: MIT)+\s*\*\/\s*'
29
29
30
30
31
-
defadd_files_pre_js(user_pre_js, files_pre_js):
31
+
defadd_files_pre_js(pre_js_list, files_pre_js):
32
32
# the normal thing is to just combine the pre-js content
33
+
filename=shared.get_temp_files().get('.js').name
34
+
utils.write_file(filename, files_pre_js)
35
+
pre_js_list.insert(0, filename)
33
36
ifnotsettings.ASSERTIONS:
34
-
returnfiles_pre_js+user_pre_js
37
+
return
35
38
36
39
# if a user pre-js tramples the file code's changes to Module.preRun
37
40
# that could be confusing. show a clear error at runtime if assertions are
38
41
# enabled
39
-
returnfiles_pre_js+'''
42
+
pre=shared.get_temp_files().get('.js').name
43
+
post=shared.get_temp_files().get('.js').name
44
+
utils.write_file(pre, '''
40
45
// All the pre-js content up to here must remain later on, we need to run
41
46
// it.
42
47
if (Module['ENVIRONMENT_IS_PTHREAD']) Module['preRun'] = [];
43
48
var necessaryPreJSTasks = Module['preRun'].slice();
44
-
'''+user_pre_js+'''
49
+
''')
50
+
utils.write_file(post, '''
45
51
if (!Module['preRun']) throw 'Module.preRun should exist because file support used it; did a pre-js delete it?';
46
52
necessaryPreJSTasks.forEach(function(task) {
47
53
if (Module['preRun'].indexOf(task) < 0) throw 'All preRun tasks that exist before user pre-js code should remain after; did you replace Module or modify Module.preRun?';
0 commit comments