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",
|
2017-03-10 05:09:54 +01:00
|
|
|
"power_javascript.cpp",
|
2017-10-26 03:39:41 +02:00
|
|
|
"http_client_javascript.cpp",
|
2017-03-10 05:09:54 +01:00
|
|
|
"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-11-04 20:24:06 +01:00
|
|
|
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_main_after_fs_sync','_send_notification']\""])
|
2016-10-30 23:10:17 +01:00
|
|
|
|
2017-07-09 17:18:59 +02:00
|
|
|
target_dir = env.Dir("#bin")
|
2017-11-28 21:27:57 +01:00
|
|
|
build = env.add_program(['#bin/godot', target_dir.File('godot' + env['PROGSUFFIX'] + '.wasm')], javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js');
|
2017-02-20 13:36:54 +01:00
|
|
|
|
2017-10-26 03:39:41 +02: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 05:50:26 +01:00
|
|
|
env.Depends(build, js_libraries)
|
2017-10-26 03:39:41 +02:00
|
|
|
|
2017-11-18 05:50:26 +01:00
|
|
|
prejs = env.File('pre.js')
|
2017-08-13 13:10:04 +02:00
|
|
|
postjs = env.File('engine.js')
|
|
|
|
env.Append(LINKFLAGS=['--pre-js', prejs.path])
|
|
|
|
env.Append(LINKFLAGS=['--post-js', postjs.path])
|
2017-11-18 05:50:26 +01:00
|
|
|
env.Depends(build, [prejs, postjs])
|
2017-02-20 13:36:54 +01:00
|
|
|
|
2017-11-18 05:50:26 +01:00
|
|
|
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'])
|
2017-08-13 13:10:04 +02:00
|
|
|
Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
|