2016-10-17 14:50:25 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
Import('env')
|
|
|
|
|
|
|
|
javascript_files = [
|
2016-10-31 01:44:57 +08:00
|
|
|
"os_javascript.cpp",
|
|
|
|
"audio_driver_javascript.cpp",
|
|
|
|
"javascript_main.cpp",
|
2017-03-10 12:09:54 +08:00
|
|
|
"power_javascript.cpp",
|
2017-10-26 09:39:41 +08:00
|
|
|
"http_client_javascript.cpp",
|
2017-03-10 12:09:54 +08:00
|
|
|
"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
|
|
|
|
2017-11-05 03:24:06 +08:00
|
|
|
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_main_after_fs_sync','_send_notification']\""])
|
2016-10-31 06:10:17 +08:00
|
|
|
|
2017-07-09 23:18:59 +08:00
|
|
|
target_dir = env.Dir("#bin")
|
2017-11-29 04:27:57 +08:00
|
|
|
build = env.add_program(['#bin/godot', target_dir.File('godot' + env['PROGSUFFIX'] + '.wasm')], javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js');
|
2018-01-14 01:47:28 +08:00
|
|
|
js, wasm = build
|
2017-02-20 20:36:54 +08:00
|
|
|
|
2017-10-26 09:39:41 +08:00
|
|
|
js_libraries = []
|
|
|
|
js_libraries.append(env.File('http_request.js'))
|
|
|
|
for lib in js_libraries:
|
|
|
|
env.Append(LINKFLAGS=['--js-library', lib.path])
|
2017-11-18 12:50:26 +08:00
|
|
|
env.Depends(build, js_libraries)
|
2017-10-26 09:39:41 +08:00
|
|
|
|
2018-01-14 01:47:28 +08:00
|
|
|
wrapper_start = env.File('pre.js')
|
|
|
|
wrapper_end = env.File('engine.js')
|
|
|
|
js_final = env.Textfile('#bin/godot', [wrapper_start, js, wrapper_end], TEXTFILESUFFIX=env['PROGSUFFIX'] + '.wrapped.js')
|
2017-02-20 20:36:54 +08:00
|
|
|
|
2017-11-18 12:50:26 +08:00
|
|
|
zip_dir = target_dir.Dir('.javascript_zip')
|
2018-01-14 01:47:28 +08:00
|
|
|
zip_files = env.InstallAs([zip_dir.File('godot.js'), zip_dir.File('godot.wasm'), zip_dir.File('godot.html')], [js_final, wasm, '#misc/dist/html/default.html'])
|
2017-08-13 19:10:04 +08:00
|
|
|
Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
|