-
-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract apple framework creation behind a tool, which will also gene…
…rate an appropriate Info.plist file.
- Loading branch information
Showing
5 changed files
with
107 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
test/project/bin/libgdexample.macos.template_debug.framework/Resources/Info.plist
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
test/project/bin/libgdexample.macos.template_release.framework/Resources/Info.plist
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import pathlib | ||
|
||
|
||
def exists(env): | ||
return True | ||
|
||
|
||
def options(opts): | ||
pass | ||
|
||
|
||
def generate(target, *, env, source, bundle_identifier: str, min_macos_version="10.12", min_ios_version="12.0"): | ||
""" | ||
Generates an Apple .framework folder, containing the binary. | ||
:param target: Folder name of the framework, usually ending in `.framework`. | ||
:param env: The environment. | ||
:param source: A list of sources to pass to SharedLibrary. | ||
:param bundle_identifier: A bundle identifier, like `org.godotengine.gdexample.macos.template_debug`. | ||
:param min_macos_version: The minimum macOS version supported by the framework, if the platform is macos. | ||
:param min_ios_version: The minimum iOS version supported by the framework, if the platform is iOS. | ||
:return: A list of files to be created, the first of which is the binary path. | ||
""" | ||
if env["platform"] == "macos": | ||
dt_platform_name = "macosx" | ||
min_os_part = f""" | ||
<key>LSMinimumSystemVersion</key> | ||
<string>{min_macos_version}</string>\ | ||
""" | ||
plist_subpath = pathlib.Path("Resources/Info.plist") | ||
elif env["platform"] == "ios": | ||
dt_platform_name = "iphoneos" | ||
min_os_part = f""" | ||
<key>MinimumOSVersion</key> | ||
<string>{min_ios_version}</string>\ | ||
""" | ||
plist_subpath = pathlib.Path("Info.plist") | ||
else: | ||
raise ValueError("Unsupported platform.") | ||
|
||
framework_path = pathlib.Path(target) | ||
framework_name = framework_path.name.removesuffix(".framework") | ||
|
||
# This is required because they affect the binary name, which we need to be equal to the framework name. | ||
env["SHLIBPREFIX"] = "" | ||
env["SHLIBSUFFIX"] = "" | ||
|
||
def create_info_plist(target, source, env): | ||
pathlib.Path(target[0].path).write_text(f"""\ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>{framework_name}</string> | ||
<key>CFBundleName</key> | ||
<string>NumDot</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>NumDot</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>{bundle_identifier}</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Unlicensed</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0.0</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0.0</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CSResourcesFileMapped</key> | ||
<true/> | ||
<key>DTPlatformName</key> | ||
<string>{dt_platform_name}</string>{min_os_part} | ||
</dict> | ||
</plist> | ||
""") | ||
|
||
return [ | ||
env.SharedLibrary(str(framework_path / framework_name), source=source), | ||
env.Command(str(framework_path / plist_subpath), [], action=create_info_plist), | ||
] |