Skip to content

Commit 9e5e408

Browse files
committed
Add support to create xctoolchain with code sign
1 parent cdacda9 commit 9e5e408

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

utils/build-presets.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,9 @@ installable-package=%(installable_package)s
595595

596596
# Path to the .tar.gz symbols package
597597
symbols-package=%(symbols_package)s
598+
599+
# Info.plist
600+
toolchain-bundle-identifier=%(toolchain_bundle_identifier)s
601+
toolchain-display-name=%(toolchain_display_name)s
602+
toolchain-name=%(toolchain_xctoolchain_name)s
603+
toolchain-version=$(toolchain_version)s

utils/build-script-impl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ KNOWN_SETTINGS=(
175175
swift-runtime-enable-dtrace "0" "Enable runtime dtrace support"
176176
swift-runtime-enable-leak-checker "0" "Enable leaks checking routines in the runtime"
177177
use-gold-linker "" "Enable using the gold linker"
178+
toolchain-bundle-identifier "" "CFBundleIdentifier for xctoolchain info plist"
179+
toolchain-display-name "" "Display Name for xctoolcain info plist"
180+
toolchain-name "" "File name for xctoolchain"
181+
toolchain-version "" "Version for xctoolchain info plist and installer pkg"
182+
toolchain-application-cert "" "Application Cert name to codesign xctoolchain"
183+
toolchain-installer-cert "" "Installer Cert name to create installer pkg"
184+
toolchain-installer-package "" "The path to installer pkg"
185+
178186
)
179187

180188
function toupper() {
@@ -2114,6 +2122,28 @@ if [[ "${INSTALLABLE_PACKAGE}" ]] ; then
21142122
echo "--- Copy swift-stdlib-tool ---"
21152123
cp "${SWIFT_SOURCE_DIR}/utils/swift-stdlib-tool-substitute" "${INSTALL_DESTDIR}/${INSTALL_PREFIX}/bin/swift-stdlib-tool"
21162124
fi
2125+
2126+
#Create plist for xctoolchain
2127+
echo "-- Create Info.plist --"
2128+
PLISTBUDDY_BIN="/usr/libexec/PlistBuddy"
2129+
TOOLCHAIN_INSTALL_LOCATION="/Library/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain/usr/lib"
2130+
2131+
${PLISTBUDDY_BIN} -c "Add DisplayName string '${TOOLCHAIN_DISPLAY_NAME}'" "${TOOLCHAIN_PREFIX}/Info.plist"
2132+
${PLISTBUDDY_BIN} -c "Add Version string '${TOOLCHAIN_VERSION}'" "${TOOLCHAIN_PREFIX}/Info.plist"
2133+
${PLISTBUDDY_BIN} -c "Add CFBundleIdentifier string '${TOOLCHAIN_BUNDLE_IDENTIFIER}'" "${TOOLCHAIN_PREFIX}/Info.plist"
2134+
${PLISTBUDDY_BIN} -c "Add ReportProblemURL string 'https://bugs.swift.com/'" "${TOOLCHAIN_PREFIX}/Info.plist"
2135+
${PLISTBUDDY_BIN} -c "Add OverrideEnvironment::DYLD_LIBRARY_PATH string '${TOOLCHAIN_INSTALL_LOCATION}/usr/lib'" "${TOOLCHAIN_PREFIX}/Info.plist"
2136+
chmod a+r "${TOOLCHAIN_PREFIX}/Info.plist"
2137+
2138+
if [[ "${APPLICATION_CERT}" ]] ; then
2139+
echo "-- Codesign xctoolchain --"
2140+
"${SWIFT_SOURCE_DIR}/utils/toolchain-codesign" "${TOOLCHAIN_APPLICATION_CERT}" "${TOOLCHAIN_PREFIX}"
2141+
fi
2142+
if [[ "${INSTALLER_PACKAGE}" ]] ; then
2143+
echo "-- Create Installer --"
2144+
"${SWIFT_SOURCE_DIR}/utils/toolchain-installer" "${TOOLCHAIN_PREFIX}" "${TOOLCHAIN_BUNDLE_IDENTIFIER}" "${TOOLCHAIN_INSTALLER_CERT}" "${TOOLCHAIN_INSTALLER_PACKAGE}" "${TOOLCHAIN_INSTALL_LOCATION}" "${TOOLCHAIN_VERSION}"
2145+
fi
2146+
21172147
(cd "${INSTALL_DESTDIR}" &&
21182148
tar -c -z -f "${INSTALLABLE_PACKAGE}" "${TOOLCHAIN_PREFIX/#\/}")
21192149
else

utils/toolchain-codesign

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
TOOLCHAIN_APPLICATION_CERT=$1
4+
TOOLCHAIN_PREFIX=$2
5+
6+
codesign -f --deep -s "${TOOLCHAIN_APPLICATION_CERT}" "${TOOLCHAIN_PREFIX}"

utils/toolchain-installer

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
TOOLCHAIN_PREFIX=$1
4+
BUNDLE_IDENTIFIER=$2
5+
INSTALLER_CERT=$3
6+
INSTALLER_PACKAGE=$4
7+
TOOLCHAIN_INSTALL_LOCATION=$5
8+
TOOLCHAIN_VERSION=$6
9+
10+
pkgbuild --root "${TOOLCHAIN_PREFIX}" --install-location "${TOOLCHAIN_INSTALL_LOCATION}" "${INSTALLER_PACKAGE}" \
11+
--version "${TOOLCHAIN_VERSION}" --identifier "${BUNDLE_IDENTIFIER}" --sign "${INSTALLER_CERT}"

0 commit comments

Comments
 (0)