Skip to content

Commit 32730fa

Browse files
committed
[build-script] XCTest CI builds on OS X
Fix the OS X XCTest CI preset: 1. Installation of XCTest isn't supported on OS X. After all, the library is meant to be used on Linux, and not intended to be used or installed on OS X. Therefore, no longer pass an `INSTALL_PATH` to the `xcodebuild` invocation on OS X. 2. `xcodebuild` expects `swift-stdlib-tool` to be present in the same directory as the `SWIFT_EXEC` it's given. Re-use some shellscript from the toolchain installation script to copy the stdlib-tool substitute. This allows the XCTest CI to work on all platforms.
1 parent fc86f6e commit 32730fa

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

utils/build-script-impl

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,15 @@ function cmake_needs_to_specify_standard_computed_defaults() {
837837
fi
838838
}
839839

840+
function copy_swift_stdlib_tool_substitute() {
841+
if [ ! -f "$1" ] ; then
842+
echo "--- Copy swift-stdlib-tool ---"
843+
set -x
844+
cp "${SWIFT_SOURCE_DIR}/utils/swift-stdlib-tool-substitute" "$1"
845+
{ set +x; } 2>/dev/null
846+
fi
847+
}
848+
840849
# A list of deployment targets to cross-compile the Swift host tools for.
841850
# We can't run the resulting binaries on the build machine.
842851
CROSS_TOOLS_DEPLOYMENT_TARGETS=()
@@ -1931,16 +1940,23 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
19311940
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
19321941
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
19331942
if [[ "$(uname -s)" == "Darwin" ]] ; then
1943+
# xcodebuild requires swift-stdlib-tool to build a Swift
1944+
# framework. This is normally present when building XCTest
1945+
# via a packaged .xctoolchain, but here we are using the
1946+
# swiftc that was just built--no toolchain exists yet. As a
1947+
# result, we must copy swift-stdlib-tool ourselves.
1948+
copy_swift_stdlib_tool_substitute "$(build_directory_bin ${deployment_target} swift)/swift-stdlib-tool"
1949+
1950+
# The Linux build places build products in the
1951+
# XCTEST_BUILD_DIR. This, and installation of XCTest in
1952+
# general, is not supported on OS X.
19341953
set -x
19351954
xcodebuild \
19361955
-workspace "${XCTEST_SOURCE_DIR}"/XCTest.xcworkspace \
19371956
-scheme SwiftXCTest \
19381957
SWIFT_EXEC="${SWIFTC_BIN}" \
19391958
SWIFT_LINK_OBJC_RUNTIME=YES \
1940-
SKIP_INSTALL=NO \
1941-
DEPLOYMENT_LOCATION=YES \
1942-
DSTROOT="${XCTEST_BUILD_DIR}" \
1943-
INSTALL_PATH="/"
1959+
DSTROOT="${XCTEST_BUILD_DIR}"
19441960
{ set +x; } 2>/dev/null
19451961
else
19461962
FOUNDATION_BUILD_DIR=$(build_directory ${deployment_target} foundation)
@@ -2529,10 +2545,7 @@ if [[ "${INSTALLABLE_PACKAGE}" ]] ; then
25292545
echo "--- Creating installable package ---"
25302546
echo "-- Package file: ${INSTALLABLE_PACKAGE} --"
25312547
if [[ "$(uname -s)" == "Darwin" ]] ; then
2532-
if [ ! -f "${INSTALL_DESTDIR}/${INSTALL_PREFIX}/bin/swift-stdlib-tool" ] ; then
2533-
echo "--- Copy swift-stdlib-tool ---"
2534-
cp "${SWIFT_SOURCE_DIR}/utils/swift-stdlib-tool-substitute" "${INSTALL_DESTDIR}/${INSTALL_PREFIX}/bin/swift-stdlib-tool"
2535-
fi
2548+
copy_swift_stdlib_tool_substitute "${INSTALL_DESTDIR}/${INSTALL_PREFIX}/bin/swift-stdlib-tool"
25362549

25372550
# Create plist for xctoolchain.
25382551
echo "-- Create Info.plist --"

0 commit comments

Comments
 (0)