diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-13 17:23:10 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-13 17:23:10 +0100 |
commit | de77f0ac7fa928a5c58e7bf3a46c6edb19da4c6f (patch) | |
tree | 671e2e5713435da460a96736266957ec7e6aacb6 /platform/macos/SCsub | |
parent | 32b083460937b981ee7fe40a0d6d629f1c2af880 (diff) | |
parent | 94238d046228dcca57ec3d5eeb94b8c0110f6d01 (diff) | |
download | redot-engine-de77f0ac7fa928a5c58e7bf3a46c6edb19da4c6f.tar.gz |
Merge pull request #86255 from bruvzg/_bundle_build
[iOS/macOS] Add option to automatically build (and sign / archive) bundles.
Diffstat (limited to 'platform/macos/SCsub')
-rw-r--r-- | platform/macos/SCsub | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/platform/macos/SCsub b/platform/macos/SCsub index 4dfafc56f8..08783ee14a 100644 --- a/platform/macos/SCsub +++ b/platform/macos/SCsub @@ -2,8 +2,99 @@ Import("env") -from platform_methods import run_in_subprocess +import os, json +from platform_methods import run_in_subprocess, architectures, lipo, get_build_version import platform_macos_builders +import subprocess +import shutil + + +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) + with open(Dir("#misc/dist/macos").abspath + "/editor_info_plist.template", "rt") as fin: + with open(app_dir + "/Contents/Info.plist", "wt") as fout: + 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) + files = [ "os_macos.mm", @@ -34,3 +125,8 @@ prog = env.add_program("#bin/godot", files) if env["debug_symbols"] and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_macos_builders.make_debug_macos)) + +if env["generate_bundle"]: + generate_bundle_command = env.Command("generate_bundle", [], generate_bundle) + command = env.AlwaysBuild(generate_bundle_command) + env.Depends(command, [prog]) |