2022-07-20 08:28:22 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
Import("env")
|
|
|
|
|
2024-05-21 15:14:59 +02:00
|
|
|
import os
|
2023-12-11 19:50:44 +01:00
|
|
|
import shutil
|
2024-05-21 15:14:59 +02:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import platform_macos_builders
|
|
|
|
|
|
|
|
from platform_methods import get_build_version, lipo
|
2023-12-11 19:50:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
def generate_bundle(target, source, env):
|
|
|
|
bin_dir = Dir("#bin").abspath
|
|
|
|
|
|
|
|
if env.editor_build:
|
|
|
|
# Editor bundle.
|
|
|
|
prefix = "godot." + env["platform"] + "." + env["target"]
|
|
|
|
if env.dev_build:
|
|
|
|
prefix += ".dev"
|
|
|
|
if env["precision"] == "double":
|
|
|
|
prefix += ".double"
|
|
|
|
|
|
|
|
# Lipo editor executable.
|
|
|
|
target_bin = lipo(bin_dir + "/" + prefix, env.extra_suffix)
|
|
|
|
|
|
|
|
# Assemble .app bundle and update version info.
|
|
|
|
app_dir = Dir("#bin/" + (prefix + env.extra_suffix).replace(".", "_") + ".app").abspath
|
|
|
|
templ = Dir("#misc/dist/macos_tools.app").abspath
|
|
|
|
if os.path.exists(app_dir):
|
|
|
|
shutil.rmtree(app_dir)
|
|
|
|
shutil.copytree(templ, app_dir, ignore=shutil.ignore_patterns("Contents/Info.plist"))
|
|
|
|
if not os.path.isdir(app_dir + "/Contents/MacOS"):
|
|
|
|
os.mkdir(app_dir + "/Contents/MacOS")
|
|
|
|
if target_bin != "":
|
|
|
|
shutil.copy(target_bin, app_dir + "/Contents/MacOS/Godot")
|
|
|
|
version = get_build_version(False)
|
|
|
|
short_version = get_build_version(True)
|
2024-06-19 11:20:48 +02:00
|
|
|
with open(Dir("#misc/dist/macos").abspath + "/editor_info_plist.template", "rt", encoding="utf-8") as fin:
|
2024-03-09 21:29:24 +01:00
|
|
|
with open(app_dir + "/Contents/Info.plist", "wt", encoding="utf-8", newline="\n") as fout:
|
2023-12-11 19:50:44 +01:00
|
|
|
for line in fin:
|
|
|
|
line = line.replace("$version", version)
|
|
|
|
line = line.replace("$short_version", short_version)
|
|
|
|
fout.write(line)
|
|
|
|
|
|
|
|
# Sign .app bundle.
|
|
|
|
if env["bundle_sign_identity"] != "":
|
|
|
|
sign_command = [
|
|
|
|
"codesign",
|
|
|
|
"-s",
|
|
|
|
env["bundle_sign_identity"],
|
|
|
|
"--deep",
|
|
|
|
"--force",
|
|
|
|
"--options=runtime",
|
|
|
|
"--entitlements",
|
|
|
|
]
|
|
|
|
if env.dev_build:
|
|
|
|
sign_command += [Dir("#misc/dist/macos").abspath + "/editor_debug.entitlements"]
|
|
|
|
else:
|
|
|
|
sign_command += [Dir("#misc/dist/macos").abspath + "/editor.entitlements"]
|
|
|
|
sign_command += [app_dir]
|
|
|
|
subprocess.run(sign_command)
|
|
|
|
else:
|
|
|
|
# Template bundle.
|
|
|
|
app_prefix = "godot." + env["platform"]
|
|
|
|
rel_prefix = "godot." + env["platform"] + "." + "template_release"
|
|
|
|
dbg_prefix = "godot." + env["platform"] + "." + "template_debug"
|
|
|
|
if env.dev_build:
|
|
|
|
app_prefix += ".dev"
|
|
|
|
rel_prefix += ".dev"
|
|
|
|
dbg_prefix += ".dev"
|
|
|
|
if env["precision"] == "double":
|
|
|
|
app_prefix += ".double"
|
|
|
|
rel_prefix += ".double"
|
|
|
|
dbg_prefix += ".double"
|
|
|
|
|
|
|
|
# Lipo template executables.
|
|
|
|
rel_target_bin = lipo(bin_dir + "/" + rel_prefix, env.extra_suffix)
|
|
|
|
dbg_target_bin = lipo(bin_dir + "/" + dbg_prefix, env.extra_suffix)
|
|
|
|
|
|
|
|
# Assemble .app bundle.
|
|
|
|
app_dir = Dir("#bin/macos_template.app").abspath
|
|
|
|
templ = Dir("#misc/dist/macos_template.app").abspath
|
|
|
|
if os.path.exists(app_dir):
|
|
|
|
shutil.rmtree(app_dir)
|
|
|
|
shutil.copytree(templ, app_dir)
|
|
|
|
if not os.path.isdir(app_dir + "/Contents/MacOS"):
|
|
|
|
os.mkdir(app_dir + "/Contents/MacOS")
|
|
|
|
if rel_target_bin != "":
|
|
|
|
shutil.copy(rel_target_bin, app_dir + "/Contents/MacOS/godot_macos_release.universal")
|
|
|
|
if dbg_target_bin != "":
|
|
|
|
shutil.copy(dbg_target_bin, app_dir + "/Contents/MacOS/godot_macos_debug.universal")
|
|
|
|
|
|
|
|
# ZIP .app bundle.
|
|
|
|
zip_dir = Dir("#bin/" + (app_prefix + env.extra_suffix).replace(".", "_")).abspath
|
|
|
|
shutil.make_archive(zip_dir, "zip", root_dir=bin_dir, base_dir="macos_template.app")
|
|
|
|
shutil.rmtree(app_dir)
|
|
|
|
|
2022-07-20 08:28:22 +02:00
|
|
|
|
|
|
|
files = [
|
|
|
|
"os_macos.mm",
|
|
|
|
"godot_application.mm",
|
|
|
|
"godot_application_delegate.mm",
|
|
|
|
"crash_handler_macos.mm",
|
|
|
|
"macos_terminal_logger.mm",
|
|
|
|
"display_server_macos.mm",
|
2022-09-20 10:12:49 +02:00
|
|
|
"godot_button_view.mm",
|
2022-07-20 08:28:22 +02:00
|
|
|
"godot_content_view.mm",
|
2023-08-03 11:45:56 +02:00
|
|
|
"godot_status_item.mm",
|
2022-07-20 08:28:22 +02:00
|
|
|
"godot_window_delegate.mm",
|
|
|
|
"godot_window.mm",
|
|
|
|
"key_mapping_macos.mm",
|
|
|
|
"godot_main_macos.mm",
|
2022-08-31 10:11:52 +02:00
|
|
|
"godot_menu_delegate.mm",
|
|
|
|
"godot_menu_item.mm",
|
2023-10-13 11:37:46 +02:00
|
|
|
"godot_open_save_delegate.mm",
|
2024-01-19 18:41:01 +01:00
|
|
|
"native_menu_macos.mm",
|
2022-07-20 08:28:22 +02:00
|
|
|
"dir_access_macos.mm",
|
|
|
|
"tts_macos.mm",
|
2023-08-16 10:42:12 +02:00
|
|
|
"joypad_macos.mm",
|
2023-12-19 18:57:56 +01:00
|
|
|
"rendering_context_driver_vulkan_macos.mm",
|
2021-11-12 13:49:49 +01:00
|
|
|
"gl_manager_macos_angle.mm",
|
2022-07-20 08:28:22 +02:00
|
|
|
"gl_manager_macos_legacy.mm",
|
|
|
|
]
|
|
|
|
|
|
|
|
prog = env.add_program("#bin/godot", files)
|
|
|
|
|
|
|
|
if env["debug_symbols"] and env["separate_debug_symbols"]:
|
2024-03-10 20:01:23 +01:00
|
|
|
env.AddPostAction(prog, env.Run(platform_macos_builders.make_debug_macos))
|
2023-12-11 19:50:44 +01:00
|
|
|
|
|
|
|
if env["generate_bundle"]:
|
|
|
|
generate_bundle_command = env.Command("generate_bundle", [], generate_bundle)
|
|
|
|
command = env.AlwaysBuild(generate_bundle_command)
|
|
|
|
env.Depends(command, [prog])
|