2016-10-17 14:50:25 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
Import('env')
|
|
|
|
|
2017-02-20 20:36:54 +08:00
|
|
|
env.Tool('textfile')
|
|
|
|
env.Tool('zip')
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
javascript_files = [
|
2016-10-31 01:44:57 +08:00
|
|
|
"os_javascript.cpp",
|
|
|
|
"audio_driver_javascript.cpp",
|
|
|
|
"javascript_main.cpp",
|
|
|
|
"audio_server_javascript.cpp",
|
|
|
|
"javascript_eval.cpp"
|
2014-02-10 09:10:30 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
env_javascript = env.Clone()
|
|
|
|
if env['target'] == "profile":
|
2016-10-31 01:44:57 +08:00
|
|
|
env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2016-10-31 01:57:40 +08:00
|
|
|
javascript_objects = []
|
2014-02-10 09:10:30 +08:00
|
|
|
for x in javascript_files:
|
2016-10-31 01:57:40 +08:00
|
|
|
javascript_objects.append(env_javascript.Object(x))
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2016-10-31 01:57:40 +08:00
|
|
|
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"'])
|
2016-10-31 06:10:17 +08:00
|
|
|
|
2017-02-20 20:36:54 +08:00
|
|
|
html_file = env.Program('#bin/godot', 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')
|
|
|
|
|
2017-02-22 05:47:33 +08:00
|
|
|
zip_dir = env.Dir('#bin/.javascript_zip')
|
2017-02-20 20:36:54 +08:00
|
|
|
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)
|