Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
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
darwin-toolchain-bundle-identifier=%(toolchain_bundle_identifier)s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you prefix the %() variables with darwin_ as well?

darwin-toolchain-display-name=%(toolchain_display_name)s
darwin-toolchain-name=%(toolchain_xctoolchain_name)s
darwin-toolchain-version=%(toolchain_version)s
35 changes: 35 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"
darwin-toolchain-bundle-identifier "" "CFBundleIdentifier for xctoolchain info plist"
darwin-toolchain-display-name "" "Display Name for xctoolcain info plist"
darwin-toolchain-name "" "Directory name for xctoolchain"
darwin-toolchain-version "" "Version for xctoolchain info plist and installer pkg"
darwin-toolchain-application-cert "" "Application Cert name to codesign xctoolchain"
darwin-toolchain-installer-cert "" "Installer Cert name to create installer pkg"
darwin-toolchain-installer-package "" "The path to installer pkg"

)

function toupper() {
Expand Down Expand Up @@ -2114,6 +2122,33 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after #, period at the end.

echo "-- Create Info.plist --"
PLISTBUDDY_BIN="/usr/libexec/PlistBuddy"
DARWIN_TOOLCHAIN_INSTALL_LOCATION="/Library/Developer/Toolchains/${DARWIN_TOOLCHAIN_NAME}.xctoolchain"
if [[ -f "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist" ]] ; then
echo "-- Removing: ${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"
rm "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can unconditionally rm -f the file, and rm would exit with success even if the file does not exist. This will simplify the logic.

fi
${PLISTBUDDY_BIN} -c "Add DisplayName string '${DARWIN_TOOLCHAIN_DISPLAY_NAME}'" "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best to factor out the plist name into a variable to avoid repetition.

${PLISTBUDDY_BIN} -c "Add Version string '${DARWIN_TOOLCHAIN_VERSION}'" "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"
${PLISTBUDDY_BIN} -c "Add CFBundleIdentifier string '${DARWIN_TOOLCHAIN_BUNDLE_IDENTIFIER}'" "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"
${PLISTBUDDY_BIN} -c "Add ReportProblemURL string 'https://bugs.swift.org/'" "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"
${PLISTBUDDY_BIN} -c "Add OverrideEnvironment::DYLD_LIBRARY_PATH string '${DARWIN_TOOLCHAIN_INSTALL_LOCATION}/usr/lib'" "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"
chmod a+r "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}/Info.plist"

if [[ "${DARWIN_TOOLCHAIN_APPLICATION_CERT}" ]] ; then
echo "-- Codesign xctoolchain --"
"${SWIFT_SOURCE_DIR}/utils/toolchain-codesign" "${DARWIN_TOOLCHAIN_APPLICATION_CERT}" "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}"
fi
if [[ "${DARWIN_TOOLCHAIN_INSTALLER_PACKAGE}" ]] ; then
echo "-- Create Installer --"
"${SWIFT_SOURCE_DIR}/utils/toolchain-installer" "${INSTALL_DESTDIR}/${TOOLCHAIN_PREFIX}" "${DARWIN_TOOLCHAIN_BUNDLE_IDENTIFIER}" \
"${DARWIN_TOOLCHAIN_INSTALLER_CERT}" "${DARWIN_TOOLCHAIN_INSTALLER_PACKAGE}" "${DARWIN_TOOLCHAIN_INSTALL_LOCATION}" \
"${DARWIN_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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the license header (copy from utils/build-script-impl).


DARWIN_TOOLCHAIN_APPLICATION_CERT=$1
TOOLCHAIN_PREFIX=$2

codesign -f --deep -s "${DARWIN_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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the license header (copy from utils/build-script-impl).


TOOLCHAIN_PREFIX=$1
DARWIN_BUNDLE_IDENTIFIER=$2
DARWIN_INSTALLER_CERT=$3
DARWIN_INSTALLER_PACKAGE=$4
DARWIN_TOOLCHAIN_INSTALL_LOCATION=$5
DARWIN_TOOLCHAIN_VERSION=$6

pkgbuild --root "${TOOLCHAIN_PREFIX}" --install-location "${DARWIN_TOOLCHAIN_INSTALL_LOCATION}" "${DARWIN_INSTALLER_PACKAGE}" \
--version "${DARWIN_TOOLCHAIN_VERSION}" --identifier "${DARWIN_BUNDLE_IDENTIFIER}" --sign "${DARWIN_INSTALLER_CERT}"