2016-10-17 06:50:25 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Import('env')
|
|
|
|
|
|
|
|
javascript_files = [
|
2016-10-30 17:44:57 +00:00
|
|
|
"os_javascript.cpp",
|
|
|
|
"audio_driver_javascript.cpp",
|
|
|
|
"javascript_main.cpp",
|
|
|
|
"audio_server_javascript.cpp",
|
2017-03-10 04:09:54 +00:00
|
|
|
"power_javascript.cpp",
|
|
|
|
"javascript_eval.cpp",
|
2014-02-10 01:10:30 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
env_javascript = env.Clone()
|
|
|
|
if env['target'] == "profile":
|
2016-10-30 17:44:57 +00:00
|
|
|
env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
javascript_objects = []
|
2014-02-10 01:10:30 +00:00
|
|
|
for x in javascript_files:
|
2016-10-30 17:57:40 +00:00
|
|
|
javascript_objects.append(env_javascript.Object(x))
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-07-22 13:43:05 +00:00
|
|
|
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync','_send_notification']\""])
|
2016-10-30 22:10:17 +00:00
|
|
|
|
2017-07-09 15:18:59 +00:00
|
|
|
# output file name without file extension
|
|
|
|
basename = "godot" + env["PROGSUFFIX"]
|
|
|
|
target_dir = env.Dir("#bin")
|
|
|
|
|
|
|
|
zip_dir = target_dir.Dir('.javascript_zip')
|
2017-08-13 11:10:04 +00:00
|
|
|
zip_files = env.InstallAs(zip_dir.File('godot.html'), '#misc/dist/html/default.html')
|
2017-07-09 15:18:59 +00:00
|
|
|
|
2017-08-13 11:10:04 +00:00
|
|
|
implicit_targets = []
|
2017-07-09 15:18:59 +00:00
|
|
|
if env['wasm'] == 'yes':
|
2017-08-13 11:10:04 +00:00
|
|
|
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')
|
2017-07-09 15:18:59 +00:00
|
|
|
else:
|
2017-08-13 11:10:04 +00:00
|
|
|
asmjs_files = [target_dir.File(basename + '.asm.js'), target_dir.File(basename + '.js.mem')]
|
2017-07-09 15:18:59 +00:00
|
|
|
implicit_targets.extend(asmjs_files)
|
2017-08-13 11:10:04 +00:00
|
|
|
zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
|
|
|
|
prejs = env.File('pre_asmjs.js')
|
2017-07-09 15:18:59 +00:00
|
|
|
|
2017-08-13 11:10:04 +00:00
|
|
|
js = env.Program(['#bin/godot'] + implicit_targets, javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js')[0];
|
|
|
|
zip_files.append(InstallAs(zip_dir.File('godot.js'), js))
|
2017-02-20 12:36:54 +00:00
|
|
|
|
2017-08-13 11:10:04 +00:00
|
|
|
postjs = env.File('engine.js')
|
|
|
|
env.Depends(js, [prejs, postjs])
|
|
|
|
env.Append(LINKFLAGS=['--pre-js', prejs.path])
|
|
|
|
env.Append(LINKFLAGS=['--post-js', postjs.path])
|
2017-02-20 12:36:54 +00:00
|
|
|
|
2017-08-13 11:10:04 +00:00
|
|
|
Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
|