SCsub 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. Import('env')
  3. javascript_files = [
  4. "os_javascript.cpp",
  5. "audio_driver_javascript.cpp",
  6. "javascript_main.cpp",
  7. "audio_server_javascript.cpp",
  8. "javascript_eval.cpp"
  9. ]
  10. env_javascript = env.Clone()
  11. if env['target'] == "profile":
  12. env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
  13. javascript_objects = []
  14. for x in javascript_files:
  15. javascript_objects.append(env_javascript.Object(x))
  16. env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""])
  17. env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"'])
  18. build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")
  19. def make_html_shell(target, source, env):
  20. html_path = target[0].rstr()
  21. assert html_path[:4] == 'bin/'
  22. assert html_path[-5:] == '.html'
  23. basename = html_path[4:-5]
  24. with open(html_path, 'r+') as html_file:
  25. fixed_html = html_file.read().replace('.html.mem', '.mem').replace(basename, '$GODOT_BASE')
  26. html_file.seek(0)
  27. html_file.truncate()
  28. html_file.write(fixed_html)
  29. env.AddPostAction(build, Action(make_html_shell, "Creating HTML shell file"))