Skip to content

[build-script] Build Foundation before XCTest [AsyncXCTest 4/6] #1556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all 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-script
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,12 @@ the number of parallel build jobs to use""",
if args.test_optimized:
args.test = True

# XCTest has a dependency on Foundation.
# On OS X, Foundation is built automatically using xcodebuild.
# On Linux, we must build ensure that it is built manually.
if args.build_xctest and platform.system() != "Darwin":
args.build_foundation = True

# --skip-test-ios is merely a shorthand for host and simulator tests.
if args.skip_test_ios:
args.skip_test_ios_host = True
Expand Down
29 changes: 19 additions & 10 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -947,15 +947,17 @@ fi
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
fi
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" xctest)
fi
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
fi
# XCTest has a dependency on Foundation, so Foundation must be added to the
# list of build products first.
if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" foundation)
fi
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" xctest)
fi

SWIFT_STDLIB_TARGETS=()
SWIFT_BENCHMARK_TARGETS=()
Expand Down Expand Up @@ -1343,7 +1345,8 @@ function set_swiftpm_bootstrap_command() {

SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
LLBUILD_BIN="$(build_directory_bin ${deployment_target} llbuild)/swift-build-tool"
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
if [[ ! "${SKIP_BUILD_FOUNDATION}" && ! "${SKIP_BUILD_XCTEST}" ]] ; then
FOUNDATION_BUILD_DIR=$(build_directory ${deployment_target} foundation)
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
fi
if [ ! -e "${LLBUILD_BIN}" ]; then
Expand All @@ -1357,8 +1360,8 @@ function set_swiftpm_bootstrap_command() {
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --swiftc="${SWIFTC_BIN}")
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --sbt="${LLBUILD_BIN}")
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --build="${build_dir}")
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --xctest="${XCTEST_BUILD_DIR}")
if [[ ! "${SKIP_BUILD_FOUNDATION}" && ! "${SKIP_BUILD_XCTEST}" ]] ; then
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --foundation="${FOUNDATION_BUILD_DIR}/Foundation" --xctest="${XCTEST_BUILD_DIR}")
fi
}

Expand Down Expand Up @@ -1859,7 +1862,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
if [[ "$(uname -s)" == "Darwin" ]] ; then
set -x
xcodebuild \
-project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj \
-workspace "${XCTEST_SOURCE_DIR}"/XCTest.xcworkspace \
-scheme SwiftXCTest \
SKIP_INSTALL=NO \
DEPLOYMENT_LOCATION=YES \
Expand All @@ -1868,20 +1871,24 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
{ set +x; } 2>/dev/null
else
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
FOUNDATION_BUILD_DIR=$(build_directory ${deployment_target} foundation)
set -x
# FIXME: Use XCTEST_BUILD_TYPE (which is never properly
# set) to build either --debug or --release.
"${XCTEST_SOURCE_DIR}"/build_script.py \
--swiftc="${SWIFTC_BIN}" \
--build-dir="${XCTEST_BUILD_DIR}"
--build-dir="${XCTEST_BUILD_DIR}" \
--foundation-build-dir="${FOUNDATION_BUILD_DIR}/Foundation"
{ set +x; } 2>/dev/null
fi

# XCTest builds itself and doesn't rely on cmake
continue
;;
foundation)
# the configuration script requires knowing about XCTest's location for building and running the tests
# The configuration script requires knowing about XCTest's
# location for building and running the tests. Note that XCTest
# is not yet built at this point.
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
SWIFT_BIN="$(build_directory_bin ${deployment_target} swift)/swift"
Expand Down Expand Up @@ -2122,15 +2129,17 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
if [[ "$(uname -s)" == "Darwin" ]] ; then
set -x
xcodebuild \
-project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj \
-workspace "${XCTEST_SOURCE_DIR}"/XCTest.xcworkspace \
-scheme SwiftXCTestFunctionalTests
{ set +x; } 2>/dev/null
else
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
FOUNDATION_BUILD_DIR=$(build_directory ${deployment_target} foundation)
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
set -x
"${XCTEST_SOURCE_DIR}"/build_script.py test \
--swiftc="${SWIFTC_BIN}" \
--foundation-build-dir="${FOUNDATION_BUILD_DIR}/Foundation" \
"${XCTEST_BUILD_DIR}"
{ set +x; } 2>/dev/null
fi
Expand Down