Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ arch = env["arch"]
# Register tools
env.Tool("copy")
env.Tool("separate_debug_symbols")
env.Tool("plist")

# Restore original ARGUMENTS and add custom options to environment
ARGUMENTS.clear()
Expand Down Expand Up @@ -227,6 +228,17 @@ elif platform == "macos":
library = env.SharedLibrary(lib_path, source=sources)
Default(library)

# Create Info.plist
plist_path = f"{out_dir}/{lib_name}.framework/Resources/Info.plist"
plist = env.FrameworkPlist(File(plist_path), File("SConstruct"),
bundle_executable=lib_name,
bundle_identifier=f"io.sentry.libsentry.{build_type}",
bundle_version=VERSION,
bundle_platforms=["MacOSX"]
)
Depends(plist, library)
Default(plist)

else:
# *** Build shared library on other platforms.

Expand Down
60 changes: 60 additions & 0 deletions site_scons/site_tools/plist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""
Tool to generate Info.plist.
"""

import os
from SCons.Script import Builder, Action


def generate_framework_plist(target, source, env):
bundle_executable = env.get("bundle_executable", "MyFramework")
bundle_identifier = env.get("bundle_identifier", "com.example.MyFramework")
bundle_name = env.get("bundle_name", bundle_executable)
bundle_version_string = env.get("bundle_version", "1.0")
bundle_version = bundle_version_string.split("-", 1)[0]
bundle_platforms = env.get("bundle_platforms", ["MacOSX"])
bundle_package_type = env.get("bundle_package_type", "FMWK") # FMWK or BNDL
bundle_min_system = env.get("bundle_min_system", env.get("macos_deployment_target", "10.13"))

platforms_content = "\n".join(f" <string>{p}</string>" for p in bundle_platforms)

content = f"""<?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>CFBundleExecutable</key>
<string>{bundle_executable}</string>
<key>CFBundleIdentifier</key>
<string>{bundle_identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>{bundle_name}</string>
<key>CFBundlePackageType</key>
<string>{bundle_package_type}</string>
<key>CFBundleShortVersionString</key>
<string>{bundle_version_string}</string>
<key>CFBundleSupportedPlatforms</key>
<array>
{platforms_content}
</array>
<key>CFBundleVersion</key>
<string>{bundle_version}</string>
<key>LSMinimumSystemVersion</key>
<string>{bundle_min_system}</string>
</dict>
</plist>"""

with open(str(target[0]), "w") as f:
f.write(content)

return None


def generate(env):
plist_builder = Builder(action=Action(generate_framework_plist, cmdstr="Generating Info.plist for $TARGET"))
env.Append(BUILDERS={"FrameworkPlist": plist_builder})


def exists(env):
return True
Loading