platform_ios_builders.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """Functions used to generate source files during build time"""
  2. import os
  3. import shutil
  4. from platform_methods import detect_mvk, lipo
  5. def combine_libs(target, source, env):
  6. lib_path = target[0].srcnode().abspath
  7. if "osxcross" in env:
  8. libtool = "$IOS_TOOLCHAIN_PATH/usr/bin/${ios_triple}libtool"
  9. else:
  10. libtool = "$IOS_TOOLCHAIN_PATH/usr/bin/libtool"
  11. env.Execute(
  12. libtool + ' -static -o "' + lib_path + '" ' + " ".join([('"' + lib.srcnode().abspath + '"') for lib in source])
  13. )
  14. def generate_bundle(target, source, env):
  15. bin_dir = env.Dir("#bin").abspath
  16. # Template bundle.
  17. app_prefix = "godot." + env["platform"]
  18. rel_prefix = "libgodot." + env["platform"] + "." + "template_release"
  19. dbg_prefix = "libgodot." + env["platform"] + "." + "template_debug"
  20. if env.dev_build:
  21. app_prefix += ".dev"
  22. rel_prefix += ".dev"
  23. dbg_prefix += ".dev"
  24. if env["precision"] == "double":
  25. app_prefix += ".double"
  26. rel_prefix += ".double"
  27. dbg_prefix += ".double"
  28. # Lipo template libraries.
  29. rel_target_bin = lipo(bin_dir + "/" + rel_prefix, env.extra_suffix + ".a")
  30. dbg_target_bin = lipo(bin_dir + "/" + dbg_prefix, env.extra_suffix + ".a")
  31. rel_target_bin_sim = lipo(bin_dir + "/" + rel_prefix, ".simulator" + env.extra_suffix + ".a")
  32. dbg_target_bin_sim = lipo(bin_dir + "/" + dbg_prefix, ".simulator" + env.extra_suffix + ".a")
  33. # Assemble Xcode project bundle.
  34. app_dir = env.Dir("#bin/ios_xcode").abspath
  35. templ = env.Dir("#misc/dist/ios_xcode").abspath
  36. if os.path.exists(app_dir):
  37. shutil.rmtree(app_dir)
  38. shutil.copytree(templ, app_dir)
  39. if rel_target_bin != "":
  40. shutil.copy(rel_target_bin, app_dir + "/libgodot.ios.release.xcframework/ios-arm64/libgodot.a")
  41. if dbg_target_bin != "":
  42. shutil.copy(dbg_target_bin, app_dir + "/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a")
  43. if rel_target_bin_sim != "":
  44. shutil.copy(
  45. rel_target_bin_sim, app_dir + "/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a"
  46. )
  47. if dbg_target_bin_sim != "":
  48. shutil.copy(
  49. dbg_target_bin_sim, app_dir + "/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a"
  50. )
  51. mvk_path = detect_mvk(env, "ios-arm64")
  52. if mvk_path != "":
  53. shutil.copytree(mvk_path, app_dir + "/MoltenVK.xcframework")
  54. # ZIP Xcode project bundle.
  55. zip_dir = env.Dir("#bin/" + (app_prefix + env.extra_suffix).replace(".", "_")).abspath
  56. shutil.make_archive(zip_dir, "zip", root_dir=app_dir)
  57. shutil.rmtree(app_dir)