ddf21ca016
Since WebGL 2.0 is required, requiring WebAssembly support as well has little impact on compatibility.
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
#!/usr/bin/env python
|
|
|
|
Import('env')
|
|
|
|
javascript_files = [
|
|
"os_javascript.cpp",
|
|
"audio_driver_javascript.cpp",
|
|
"javascript_main.cpp",
|
|
"power_javascript.cpp",
|
|
"http_client_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','_main_after_fs_sync','_send_notification']\""])
|
|
|
|
target_dir = env.Dir("#bin")
|
|
build = env.Program(['#bin/godot', target_dir.File('godot' + env['PROGSUFFIX'] + '.wasm')], javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js');
|
|
|
|
js_libraries = []
|
|
js_libraries.append(env.File('http_request.js'))
|
|
for lib in js_libraries:
|
|
env.Append(LINKFLAGS=['--js-library', lib.path])
|
|
env.Depends(build, js_libraries)
|
|
|
|
prejs = env.File('pre.js')
|
|
postjs = env.File('engine.js')
|
|
env.Append(LINKFLAGS=['--pre-js', prejs.path])
|
|
env.Append(LINKFLAGS=['--post-js', postjs.path])
|
|
env.Depends(build, [prejs, postjs])
|
|
|
|
zip_dir = target_dir.Dir('.javascript_zip')
|
|
zip_files = env.InstallAs([zip_dir.File('godot.js'), zip_dir.File('godot.wasm'), zip_dir.File('godot.html')], build + ['#misc/dist/html/default.html'])
|
|
Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
|