godot/platform/javascript/SCsub
Leon Krause 4db801aaea HTML5 start-up overhaul
- Implement promise-based JS interface for custom HTML page
   integration
 - Add download progress callback
 - Add progress bar and indeterminate spinner to default HTML page
 - Try downloading files multiple times when failing
 - Get rid of godotfs.js
 - Separate steps for engine initialization, game initialization and game
   start
 - Allow multiple games on one HTML page
 - Substitution placeholders only used in .html file
 - Placeholders renamed: $GODOT_BASE => $GODOT_BASENAME,
   $GODOT_TMEM -> $GODOT_TOTAL_MEMORY
 - Emscripten Module is now Engine.RuntimeEnvironment (no longer a global)
2017-09-11 20:56:29 +02:00

52 lines
1.8 KiB
Python

#!/usr/bin/env python
Import('env')
javascript_files = [
"os_javascript.cpp",
"audio_driver_javascript.cpp",
"javascript_main.cpp",
"audio_server_javascript.cpp",
"power_javascript.cpp",
"javascript_eval.cpp",
]
env_javascript = env.Clone()
if env['target'] == "profile":
env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
javascript_objects = []
for x in javascript_files:
javascript_objects.append(env_javascript.Object(x))
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync','_send_notification']\""])
# output file name without file extension
basename = "godot" + env["PROGSUFFIX"]
target_dir = env.Dir("#bin")
zip_dir = target_dir.Dir('.javascript_zip')
zip_files = env.InstallAs(zip_dir.File('godot.html'), '#misc/dist/html/default.html')
implicit_targets = []
if env['wasm'] == 'yes':
wasm = target_dir.File(basename + '.wasm')
implicit_targets.append(wasm)
zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm))
prejs = env.File('pre_wasm.js')
else:
asmjs_files = [target_dir.File(basename + '.asm.js'), target_dir.File(basename + '.js.mem')]
implicit_targets.extend(asmjs_files)
zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
prejs = env.File('pre_asmjs.js')
js = env.Program(['#bin/godot'] + implicit_targets, javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js')[0];
zip_files.append(InstallAs(zip_dir.File('godot.js'), js))
postjs = env.File('engine.js')
env.Depends(js, [prejs, postjs])
env.Append(LINKFLAGS=['--pre-js', prejs.path])
env.Append(LINKFLAGS=['--post-js', postjs.path])
Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")