Skip to content

Commit

Permalink
Merge pull request #86255 from bruvzg/_bundle_build
Browse files Browse the repository at this point in the history
[iOS/macOS] Add option to automatically build (and sign / archive) bundles.
  • Loading branch information
akien-mga committed Feb 13, 2024
2 parents 32b0834 + 94238d0 commit de77f0a
Show file tree
Hide file tree
Showing 9 changed files with 498 additions and 69 deletions.
1 change: 0 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", False))
opts.Add(BoolVariable("separate_debug_symbols", "Extract debugging symbols to a separate file", False))
opts.Add(EnumVariable("lto", "Link-time optimization (production builds)", "none", ("none", "auto", "thin", "full")))
opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False))
opts.Add(BoolVariable("generate_apk", "Generate an APK/AAB after building Android library by calling Gradle", False))
opts.Add(BoolVariable("threads", "Enable threading support", True))

# Components
Expand Down
22 changes: 22 additions & 0 deletions misc/dist/macos/editor_debug.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
199 changes: 199 additions & 0 deletions misc/dist/macos/editor_info_plist.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Godot</string>
<key>CFBundleName</key>
<string>Godot</string>
<key>CFBundleIconFile</key>
<string>Godot.icns</string>
<key>CFBundleIdentifier</key>
<string>org.godotengine.godot</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$short_version</string>
<key>CFBundleSignature</key>
<string>godot</string>
<key>CFBundleVersion</key>
<string>$version</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required to capture audio.</string>
<key>NSCameraUsageDescription</key>
<string>Camera access is required to capture video.</string>
<key>NSRequiresAquaSystemAppearance</key>
<false/>
<key>NSHumanReadableCopyright</key>
<string>© 2007-present Juan Linietsky, Ariel Manzur &amp; Godot Engine contributors</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
<key>x86_64</key>
<string>10.12</string>
</dict>
<key>NSHighResolutionCapable</key>
<true/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>public.tscn</string>
</array>
<key>NSExportableTypes</key>
<array>
<string>public.tscn</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>public.godot</string>
</array>
<key>NSExportableTypes</key>
<array>
<string>public.godot</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>public.tscn</string>
<key>UTTypeReferenceURL</key>
<string></string>
<key>UTTypeDescription</key>
<string>Godot Engine scene</string>
<key>UTTypeIconFile</key>
<string>Scene.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>scn</string>
<string>tscn</string>
<string>escn</string>
</array>
<key>public.mime-type</key>
<string>application/x-godot-scene</string>
</dict>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>public.gd</string>
<key>UTTypeReferenceURL</key>
<string></string>
<key>UTTypeDescription</key>
<string>GDScript script</string>
<key>UTTypeIconFile</key>
<string>GDScript.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.script</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gd</string>
</array>
<key>public.mime-type</key>
<string>application/x-gdscript</string>
</dict>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>public.res</string>
<key>UTTypeReferenceURL</key>
<string></string>
<key>UTTypeDescription</key>
<string>Godot Engine resource</string>
<key>UTTypeIconFile</key>
<string>Resource.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>res</string>
<string>tres</string>
</array>
<key>public.mime-type</key>
<string>application/x-godot-resource</string>
</dict>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>public.gdshader</string>
<key>UTTypeReferenceURL</key>
<string></string>
<key>UTTypeDescription</key>
<string>Godot Engine shader</string>
<key>UTTypeIconFile</key>
<string>Shader.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.script</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gdshader</string>
</array>
<key>public.mime-type</key>
<string>application/x-godot-shader</string>
</dict>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>public.godot</string>
<key>UTTypeReferenceURL</key>
<string></string>
<key>UTTypeDescription</key>
<string>Godot Engine project</string>
<key>UTTypeIconFile</key>
<string>Project.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>godot</string>
</array>
<key>public.mime-type</key>
<string>application/x-godot-project</string>
</dict>
</dict>
</array>
</dict>
</plist>
1 change: 1 addition & 0 deletions platform/android/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def get_opts():
"android-" + str(get_min_target_api()),
),
BoolVariable("store_release", "Editor build for Google Play Store (for official builds only)", False),
BoolVariable("generate_apk", "Generate an APK/AAB after building Android library by calling Gradle", False),
]


Expand Down
61 changes: 61 additions & 0 deletions platform/ios/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@

Import("env")

import os, json
from platform_methods import run_in_subprocess, architectures, lipo, get_build_version, detect_mvk
import subprocess
import shutil


def generate_bundle(target, source, env):
bin_dir = Dir("#bin").abspath

# Template bundle.
app_prefix = "godot." + env["platform"]
rel_prefix = "libgodot." + env["platform"] + "." + "template_release"
dbg_prefix = "libgodot." + 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 libraries.
rel_target_bin = lipo(bin_dir + "/" + rel_prefix, env.extra_suffix + ".a")
dbg_target_bin = lipo(bin_dir + "/" + dbg_prefix, env.extra_suffix + ".a")
rel_target_bin_sim = lipo(bin_dir + "/" + rel_prefix, ".simulator" + env.extra_suffix + ".a")
dbg_target_bin_sim = lipo(bin_dir + "/" + dbg_prefix, ".simulator" + env.extra_suffix + ".a")

# Assemble Xcode project bundle.
app_dir = Dir("#bin/ios_xcode").abspath
templ = Dir("#misc/dist/ios_xcode").abspath
if os.path.exists(app_dir):
shutil.rmtree(app_dir)
shutil.copytree(templ, app_dir)
if rel_target_bin != "":
shutil.copy(rel_target_bin, app_dir + "/libgodot.ios.release.xcframework/ios-arm64/libgodot.a")
if dbg_target_bin != "":
shutil.copy(dbg_target_bin, app_dir + "/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a")
if rel_target_bin_sim != "":
shutil.copy(
rel_target_bin_sim, app_dir + "/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a"
)
if dbg_target_bin_sim != "":
shutil.copy(
dbg_target_bin_sim, app_dir + "/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a"
)
mvk_path = detect_mvk(env, "ios-arm64")
if mvk_path != "":
shutil.copytree(mvk_path, app_dir + "/MoltenVK.xcframework")

# ZIP Xcode project bundle.
zip_dir = Dir("#bin/" + (app_prefix + env.extra_suffix).replace(".", "_")).abspath
shutil.make_archive(zip_dir, "zip", root_dir=app_dir)
shutil.rmtree(app_dir)


ios_lib = [
"godot_ios.mm",
"os_ios.mm",
Expand Down Expand Up @@ -42,3 +98,8 @@ def combine_libs(target=None, source=None, env=None):


combine_command = env_ios.Command("#bin/libgodot" + env_ios["LIBSUFFIX"], [ios_lib] + env_ios["LIBS"], combine_libs)

if env["generate_bundle"]:
generate_bundle_command = env.Command("generate_bundle", [], generate_bundle)
command = env.AlwaysBuild(generate_bundle_command)
env.Depends(command, [combine_command])
2 changes: 2 additions & 0 deletions platform/ios/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_opts():
from SCons.Variables import BoolVariable

return [
("vulkan_sdk_path", "Path to the Vulkan SDK", ""),
(
"IOS_TOOLCHAIN_PATH",
"Path to iOS toolchain",
Expand All @@ -31,6 +32,7 @@ def get_opts():
("IOS_SDK_PATH", "Path to the iOS SDK", ""),
BoolVariable("ios_simulator", "Build for iOS Simulator", False),
("ios_triple", "Triple for ios toolchain", ""),
BoolVariable("generate_bundle", "Generate an APP bundle after building iOS/macOS binaries", False),
]


Expand Down
Loading

0 comments on commit de77f0a

Please sign in to comment.