Skip to content

Commit

Permalink
Add support to create xctoolchain with code sign
Browse files Browse the repository at this point in the history
  • Loading branch information
shahmishal committed Nov 23, 2015
1 parent cdacda9 commit 9e5e408
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,9 @@ installable-package=%(installable_package)s

# Path to the .tar.gz symbols package
symbols-package=%(symbols_package)s

# Info.plist
toolchain-bundle-identifier=%(toolchain_bundle_identifier)s
toolchain-display-name=%(toolchain_display_name)s
toolchain-name=%(toolchain_xctoolchain_name)s
toolchain-version=$(toolchain_version)s
30 changes: 30 additions & 0 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ KNOWN_SETTINGS=(
swift-runtime-enable-dtrace "0" "Enable runtime dtrace support"
swift-runtime-enable-leak-checker "0" "Enable leaks checking routines in the runtime"
use-gold-linker "" "Enable using the gold linker"
toolchain-bundle-identifier "" "CFBundleIdentifier for xctoolchain info plist"
toolchain-display-name "" "Display Name for xctoolcain info plist"
toolchain-name "" "File name for xctoolchain"
toolchain-version "" "Version for xctoolchain info plist and installer pkg"
toolchain-application-cert "" "Application Cert name to codesign xctoolchain"
toolchain-installer-cert "" "Installer Cert name to create installer pkg"
toolchain-installer-package "" "The path to installer pkg"

)

function toupper() {
Expand Down Expand Up @@ -2114,6 +2122,28 @@ if [[ "${INSTALLABLE_PACKAGE}" ]] ; then
echo "--- Copy swift-stdlib-tool ---"
cp "${SWIFT_SOURCE_DIR}/utils/swift-stdlib-tool-substitute" "${INSTALL_DESTDIR}/${INSTALL_PREFIX}/bin/swift-stdlib-tool"
fi

#Create plist for xctoolchain
echo "-- Create Info.plist --"
PLISTBUDDY_BIN="/usr/libexec/PlistBuddy"
TOOLCHAIN_INSTALL_LOCATION="/Library/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain/usr/lib"

${PLISTBUDDY_BIN} -c "Add DisplayName string '${TOOLCHAIN_DISPLAY_NAME}'" "${TOOLCHAIN_PREFIX}/Info.plist"
${PLISTBUDDY_BIN} -c "Add Version string '${TOOLCHAIN_VERSION}'" "${TOOLCHAIN_PREFIX}/Info.plist"
${PLISTBUDDY_BIN} -c "Add CFBundleIdentifier string '${TOOLCHAIN_BUNDLE_IDENTIFIER}'" "${TOOLCHAIN_PREFIX}/Info.plist"
${PLISTBUDDY_BIN} -c "Add ReportProblemURL string 'https://bugs.swift.com/'" "${TOOLCHAIN_PREFIX}/Info.plist"
${PLISTBUDDY_BIN} -c "Add OverrideEnvironment::DYLD_LIBRARY_PATH string '${TOOLCHAIN_INSTALL_LOCATION}/usr/lib'" "${TOOLCHAIN_PREFIX}/Info.plist"
chmod a+r "${TOOLCHAIN_PREFIX}/Info.plist"

if [[ "${APPLICATION_CERT}" ]] ; then
echo "-- Codesign xctoolchain --"
"${SWIFT_SOURCE_DIR}/utils/toolchain-codesign" "${TOOLCHAIN_APPLICATION_CERT}" "${TOOLCHAIN_PREFIX}"
fi
if [[ "${INSTALLER_PACKAGE}" ]] ; then
echo "-- Create Installer --"
"${SWIFT_SOURCE_DIR}/utils/toolchain-installer" "${TOOLCHAIN_PREFIX}" "${TOOLCHAIN_BUNDLE_IDENTIFIER}" "${TOOLCHAIN_INSTALLER_CERT}" "${TOOLCHAIN_INSTALLER_PACKAGE}" "${TOOLCHAIN_INSTALL_LOCATION}" "${TOOLCHAIN_VERSION}"
fi

(cd "${INSTALL_DESTDIR}" &&
tar -c -z -f "${INSTALLABLE_PACKAGE}" "${TOOLCHAIN_PREFIX/#\/}")
else
Expand Down
6 changes: 6 additions & 0 deletions utils/toolchain-codesign
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

TOOLCHAIN_APPLICATION_CERT=$1
TOOLCHAIN_PREFIX=$2

codesign -f --deep -s "${TOOLCHAIN_APPLICATION_CERT}" "${TOOLCHAIN_PREFIX}"
11 changes: 11 additions & 0 deletions utils/toolchain-installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

TOOLCHAIN_PREFIX=$1
BUNDLE_IDENTIFIER=$2
INSTALLER_CERT=$3
INSTALLER_PACKAGE=$4
TOOLCHAIN_INSTALL_LOCATION=$5
TOOLCHAIN_VERSION=$6

pkgbuild --root "${TOOLCHAIN_PREFIX}" --install-location "${TOOLCHAIN_INSTALL_LOCATION}" "${INSTALLER_PACKAGE}" \
--version "${TOOLCHAIN_VERSION}" --identifier "${BUNDLE_IDENTIFIER}" --sign "${INSTALLER_CERT}"

0 comments on commit 9e5e408

Please sign in to comment.