@@ -30,25 +30,46 @@ def create_engine_file(env, target, source, externs, threads_enabled):
3030 return env .Substfile (target = target , source = [env .File (s ) for s in source ], SUBST_DICT = subst_dict )
3131
3232
33- def create_template_zip (env , js , wasm , side ):
33+ def create_template_zip (
34+ env ,
35+ js ,
36+ main_wasm ,
37+ side_wasm = None ,
38+ main_wasm_dwarf = None ,
39+ main_wasm_dwarf_package = None ,
40+ side_wasm_dwarf = None ,
41+ side_wasm_dwarf_package = None ,
42+ ):
3443 binary_name = "godot.editor" if env .editor_build else "godot"
3544 zip_dir = env .Dir (env .GetTemplateZipPath ())
36- in_files = [
37- js ,
38- wasm ,
39- "#platform/web/js/libs/audio.worklet.js" ,
40- "#platform/web/js/libs/audio.position.worklet.js" ,
41- ]
42- out_files = [
43- zip_dir .File (binary_name + ".js" ),
44- zip_dir .File (binary_name + ".wasm" ),
45- zip_dir .File (binary_name + ".audio.worklet.js" ),
46- zip_dir .File (binary_name + ".audio.position.worklet.js" ),
47- ]
45+
46+ in_files = []
47+ out_files = []
48+
49+ def add_to_template (in_file , zip_file ):
50+ out_file = zip_dir .File (zip_file )
51+ in_files .append (in_file )
52+ out_files .append (out_file )
53+
54+ add_to_template (js , binary_name + ".js" )
55+ add_to_template (main_wasm , binary_name + ".wasm" )
56+ add_to_template ("#platform/web/js/libs/audio.worklet.js" , binary_name + ".audio.worklet.js" )
57+ add_to_template ("#platform/web/js/libs/audio.position.worklet.js" , binary_name + ".audio.position.worklet.js" )
58+
4859 # Dynamic linking (extensions) specific.
49- if env ["dlink_enabled" ]:
50- in_files .append (side ) # Side wasm (contains the actual Godot code).
51- out_files .append (zip_dir .File (binary_name + ".side.wasm" ))
60+ if side_wasm is not None :
61+ add_to_template (side_wasm , binary_name + ".side.wasm" )
62+
63+ # Those files cannot be renamed, as their relative .wasm file has their name baked in the binary.
64+ # They must also reside besides their original .wasm files.
65+ if main_wasm_dwarf is not None :
66+ add_to_template (main_wasm_dwarf , main_wasm_dwarf .name )
67+ if main_wasm_dwarf_package is not None :
68+ add_to_template (main_wasm_dwarf_package , main_wasm_dwarf_package .name )
69+ if side_wasm_dwarf is not None :
70+ add_to_template (side_wasm_dwarf , side_wasm_dwarf .name )
71+ if side_wasm_dwarf_package is not None :
72+ add_to_template (side_wasm_dwarf_package , side_wasm_dwarf_package .name )
5273
5374 service_worker = "#misc/dist/html/service-worker.js"
5475 if env .editor_build :
@@ -74,33 +95,24 @@ def create_template_zip(env, js, wasm, side):
7495 "___GODOT_ENSURE_CROSSORIGIN_ISOLATION_HEADERS___" : "true" ,
7596 }
7697 html = env .Substfile (target = "#bin/godot${PROGSUFFIX}.html" , source = html , SUBST_DICT = subst_dict )
77- in_files .append (html )
78- out_files .append (zip_dir .File (binary_name + ".html" ))
98+ add_to_template (html , binary_name + ".html" )
7999 # And logo/favicon
80- in_files .append ("#misc/dist/html/logo.svg" )
81- out_files .append (zip_dir .File ("logo.svg" ))
82- in_files .append ("#icon.png" )
83- out_files .append (zip_dir .File ("favicon.png" ))
100+ add_to_template ("#misc/dist/html/logo.svg" , "logo.svg" )
101+ add_to_template ("#icon.png" , "favicon.svg" )
84102 # PWA
85103 service_worker = env .Substfile (
86104 target = "#bin/godot${PROGSUFFIX}.service.worker.js" ,
87105 source = service_worker ,
88106 SUBST_DICT = subst_dict ,
89107 )
90- in_files .append (service_worker )
91- out_files .append (zip_dir .File ("service.worker.js" ))
92- in_files .append ("#misc/dist/html/manifest.json" )
93- out_files .append (zip_dir .File ("manifest.json" ))
94- in_files .append ("#misc/dist/html/offline.html" )
95- out_files .append (zip_dir .File ("offline.html" ))
108+ add_to_template (service_worker , "service.worker.js" )
109+ add_to_template ("#misc/dist/html/manifest.json" , "manifest.json" )
110+ add_to_template ("#misc/dist/html/offline.html" , "offline.html" )
96111 else :
97112 # HTML
98- in_files .append ("#misc/dist/html/full-size.html" )
99- out_files .append (zip_dir .File (binary_name + ".html" ))
100- in_files .append (service_worker )
101- out_files .append (zip_dir .File (binary_name + ".service.worker.js" ))
102- in_files .append ("#misc/dist/html/offline-export.html" )
103- out_files .append (zip_dir .File ("godot.offline.html" ))
113+ add_to_template ("#misc/dist/html/full-size.html" , binary_name + ".html" )
114+ add_to_template (service_worker , binary_name + ".service.worker.js" )
115+ add_to_template ("#misc/dist/html/offline-export.html" , binary_name + ".offline.html" )
104116
105117 zip_files = env .NoCache (env .InstallAs (out_files , in_files ))
106118 env .NoCache (
0 commit comments