diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-07-17 12:04:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-17 12:04:18 +0200 |
commit | 80b2a47022de40b1e14aa7ef119006cb035dbc5d (patch) | |
tree | 14a84e6c299845016c0c8075925f6fe78d0e68db /platform | |
parent | 4366b7c8b0bf452236cdfd034d3a0e5d851576b9 (diff) | |
parent | 69e0dee983a9e018dcd5dd9d27c106b35ab9e3bf (diff) |
Merge pull request #9669 from eska014/html5-implicit-cache
Fix zipping HTML5 templates when using SCons' implicit cache
Diffstat (limited to 'platform')
-rw-r--r-- | platform/javascript/SCsub | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 02ff2090f9..ca9fcb54e4 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -22,26 +22,31 @@ for x in javascript_files: env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"']) -html_file = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")[0] +# output file name without file extension +basename = "godot" + env["PROGSUFFIX"] +target_dir = env.Dir("#bin") +js_file = target_dir.File(basename + ".js") +implicit_targets = [js_file] + +zip_dir = target_dir.Dir('.javascript_zip') +zip_files = env.InstallAs([zip_dir.File("godot.js"), zip_dir.File("godotfs.js")], [js_file, "#misc/dist/html_fs/godotfs.js"]) + +if env['wasm'] == 'yes': + wasm_file = target_dir.File(basename+'.wasm') + implicit_targets.append(wasm_file) + zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm_file)) +else: + asmjs_files = [target_dir.File(basename+'.asm.js'), target_dir.File(basename+'.html.mem')] + zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) + implicit_targets.extend(asmjs_files) + +# HTML file must be the first target in the list +html_file = env.Program(["#bin/godot"] + implicit_targets, javascript_objects, PROGSUFFIX=env["PROGSUFFIX"]+".html")[0] Depends(html_file, "godot_shell.html") -basename = "godot" + env["PROGSUFFIX"] # output file name without file extension # Emscripten hardcodes file names, so replace common base name with # placeholder while leaving extension; also change `.html.mem` to just `.mem` fixup_html = env.Substfile(html_file, SUBST_DICT=[(basename, '$$GODOT_BASE'), ('.html.mem', '.mem')], SUBSTFILESUFFIX='.fixup.html') -zip_dir = env.Dir('#bin/.javascript_zip') -zip_files = [] -js_file = env.SideEffect(html_file.File(basename+'.js'), html_file) -zip_files.append(env.InstallAs( - [zip_dir.File('godot.html'), zip_dir.File('godot.js'), zip_dir.File('godotfs.js')], - [fixup_html, js_file, '#misc/dist/html_fs/godotfs.js'])) - -if env['wasm'] == 'yes': - wasm_file = env.SideEffect(html_file.File(basename+'.wasm'), html_file) - zip_files.append(env.InstallAs(zip_dir.File('godot.wasm'), wasm_file)) -else: - asmjs_files = env.SideEffect([html_file.File(basename+'.asm.js'), html_file.File(basename+'.html.mem')], html_file) - zip_files.append(env.InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) - -Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir) +zip_files.append(InstallAs(zip_dir.File('godot.html'), fixup_html)) +Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET") |