SCsub 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. Import("env")
  3. javascript_files = [
  4. "audio_driver_javascript.cpp",
  5. "http_client_javascript.cpp",
  6. "javascript_eval.cpp",
  7. "javascript_main.cpp",
  8. "os_javascript.cpp",
  9. ]
  10. build_targets = ["#bin/godot${PROGSUFFIX}.js", "#bin/godot${PROGSUFFIX}.wasm"]
  11. if env["threads_enabled"]:
  12. build_targets.append("#bin/godot${PROGSUFFIX}.worker.js")
  13. build = env.add_program(build_targets, javascript_files)
  14. js_libraries = [
  15. "native/http_request.js",
  16. ]
  17. for lib in js_libraries:
  18. env.Append(LINKFLAGS=["--js-library", env.File(lib).path])
  19. env.Depends(build, js_libraries)
  20. js_pre = [
  21. "native/id_handler.js",
  22. "native/utils.js",
  23. ]
  24. for js in js_pre:
  25. env.Append(LINKFLAGS=["--pre-js", env.File(js).path])
  26. env.Depends(build, js_pre)
  27. engine = [
  28. "engine/preloader.js",
  29. "engine/utils.js",
  30. "engine/engine.js",
  31. ]
  32. externs = [env.File("#platform/javascript/engine/externs.js")]
  33. js_engine = env.CreateEngineFile("#bin/godot${PROGSUFFIX}.engine.js", engine, externs)
  34. env.Depends(js_engine, externs)
  35. wrap_list = [
  36. build[0],
  37. js_engine,
  38. ]
  39. js_wrapped = env.Textfile("#bin/godot", [env.File(f) for f in wrap_list], TEXTFILESUFFIX="${PROGSUFFIX}.wrapped.js")
  40. zip_dir = env.Dir("#bin/.javascript_zip")
  41. binary_name = "godot.tools" if env["tools"] else "godot"
  42. out_files = [
  43. zip_dir.File(binary_name + ".js"),
  44. zip_dir.File(binary_name + ".wasm"),
  45. zip_dir.File(binary_name + ".html"),
  46. ]
  47. html_file = "#misc/dist/html/full-size.html"
  48. in_files = [js_wrapped, build[1], html_file]
  49. if env["threads_enabled"]:
  50. in_files.append(build[2])
  51. out_files.append(zip_dir.File(binary_name + ".worker.js"))
  52. zip_files = env.InstallAs(out_files, in_files)
  53. env.Zip(
  54. "#bin/godot",
  55. zip_files,
  56. ZIPROOT=zip_dir,
  57. ZIPSUFFIX="${PROGSUFFIX}${ZIPSUFFIX}",
  58. ZIPCOMSTR="Archving $SOURCES as $TARGET",
  59. )