2016-10-17 08:50:25 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Import('env')
|
|
|
|
|
|
|
|
javascript_files = [
|
2016-10-30 18:44:57 +01:00
|
|
|
"os_javascript.cpp",
|
|
|
|
"audio_driver_javascript.cpp",
|
|
|
|
"javascript_main.cpp",
|
|
|
|
"audio_server_javascript.cpp",
|
2017-03-10 05:09:54 +01:00
|
|
|
"power_javascript.cpp",
|
|
|
|
"javascript_eval.cpp",
|
2014-02-10 02:10:30 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
env_javascript = env.Clone()
|
|
|
|
if env['target'] == "profile":
|
2016-10-30 18:44:57 +01:00
|
|
|
env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-30 18:57:40 +01:00
|
|
|
javascript_objects = []
|
2014-02-10 02:10:30 +01:00
|
|
|
for x in javascript_files:
|
2016-10-30 18:57:40 +01:00
|
|
|
javascript_objects.append(env_javascript.Object(x))
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-07-22 15:43:05 +02:00
|
|
|
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync','_send_notification']\""])
|
2016-10-30 18:57:40 +01:00
|
|
|
env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"'])
|
2016-10-30 23:10:17 +01:00
|
|
|
|
2017-07-09 17:18:59 +02:00
|
|
|
# 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]
|
2017-02-20 13:36:54 +01:00
|
|
|
Depends(html_file, "godot_shell.html")
|
|
|
|
|
|
|
|
# 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-07-09 17:18:59 +02:00
|
|
|
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")
|