Skip to content

Commit b7973a9

Browse files
committed
Merge pull request #1556 from modocache/build-script-xctest-on-foundation
[build-script] Build Foundation before XCTest [AsyncXCTest 4/6]
2 parents c9d665e + 453f8e6 commit b7973a9

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

utils/build-script

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,12 @@ the number of parallel build jobs to use""",
730730
if args.test_optimized:
731731
args.test = True
732732

733+
# XCTest has a dependency on Foundation.
734+
# On OS X, Foundation is built automatically using xcodebuild.
735+
# On Linux, we must build ensure that it is built manually.
736+
if args.build_xctest and platform.system() != "Darwin":
737+
args.build_foundation = True
738+
733739
# --skip-test-ios is merely a shorthand for host and simulator tests.
734740
if args.skip_test_ios:
735741
args.skip_test_ios_host = True

utils/build-script-impl

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -947,15 +947,17 @@ fi
947947
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
948948
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
949949
fi
950-
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
951-
PRODUCTS=("${PRODUCTS[@]}" xctest)
952-
fi
953950
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
954951
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
955952
fi
953+
# XCTest has a dependency on Foundation, so Foundation must be added to the
954+
# list of build products first.
956955
if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
957956
PRODUCTS=("${PRODUCTS[@]}" foundation)
958957
fi
958+
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
959+
PRODUCTS=("${PRODUCTS[@]}" xctest)
960+
fi
959961

960962
SWIFT_STDLIB_TARGETS=()
961963
SWIFT_BENCHMARK_TARGETS=()
@@ -1343,7 +1345,8 @@ function set_swiftpm_bootstrap_command() {
13431345

13441346
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
13451347
LLBUILD_BIN="$(build_directory_bin ${deployment_target} llbuild)/swift-build-tool"
1346-
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
1348+
if [[ ! "${SKIP_BUILD_FOUNDATION}" && ! "${SKIP_BUILD_XCTEST}" ]] ; then
1349+
FOUNDATION_BUILD_DIR=$(build_directory ${deployment_target} foundation)
13471350
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
13481351
fi
13491352
if [ ! -e "${LLBUILD_BIN}" ]; then
@@ -1357,8 +1360,8 @@ function set_swiftpm_bootstrap_command() {
13571360
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --swiftc="${SWIFTC_BIN}")
13581361
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --sbt="${LLBUILD_BIN}")
13591362
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --build="${build_dir}")
1360-
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
1361-
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --xctest="${XCTEST_BUILD_DIR}")
1363+
if [[ ! "${SKIP_BUILD_FOUNDATION}" && ! "${SKIP_BUILD_XCTEST}" ]] ; then
1364+
swiftpm_bootstrap_command=("${swiftpm_bootstrap_command[@]}" --foundation="${FOUNDATION_BUILD_DIR}/Foundation" --xctest="${XCTEST_BUILD_DIR}")
13621365
fi
13631366
}
13641367

@@ -1859,7 +1862,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
18591862
if [[ "$(uname -s)" == "Darwin" ]] ; then
18601863
set -x
18611864
xcodebuild \
1862-
-project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj \
1865+
-workspace "${XCTEST_SOURCE_DIR}"/XCTest.xcworkspace \
18631866
-scheme SwiftXCTest \
18641867
SKIP_INSTALL=NO \
18651868
DEPLOYMENT_LOCATION=YES \
@@ -1868,20 +1871,24 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
18681871
{ set +x; } 2>/dev/null
18691872
else
18701873
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
1874+
FOUNDATION_BUILD_DIR=$(build_directory ${deployment_target} foundation)
18711875
set -x
18721876
# FIXME: Use XCTEST_BUILD_TYPE (which is never properly
18731877
# set) to build either --debug or --release.
18741878
"${XCTEST_SOURCE_DIR}"/build_script.py \
18751879
--swiftc="${SWIFTC_BIN}" \
1876-
--build-dir="${XCTEST_BUILD_DIR}"
1880+
--build-dir="${XCTEST_BUILD_DIR}" \
1881+
--foundation-build-dir="${FOUNDATION_BUILD_DIR}/Foundation"
18771882
{ set +x; } 2>/dev/null
18781883
fi
18791884

18801885
# XCTest builds itself and doesn't rely on cmake
18811886
continue
18821887
;;
18831888
foundation)
1884-
# the configuration script requires knowing about XCTest's location for building and running the tests
1889+
# The configuration script requires knowing about XCTest's
1890+
# location for building and running the tests. Note that XCTest
1891+
# is not yet built at this point.
18851892
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
18861893
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
18871894
SWIFT_BIN="$(build_directory_bin ${deployment_target} swift)/swift"
@@ -2122,15 +2129,17 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
21222129
if [[ "$(uname -s)" == "Darwin" ]] ; then
21232130
set -x
21242131
xcodebuild \
2125-
-project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj \
2132+
-workspace "${XCTEST_SOURCE_DIR}"/XCTest.xcworkspace \
21262133
-scheme SwiftXCTestFunctionalTests
21272134
{ set +x; } 2>/dev/null
21282135
else
21292136
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
2137+
FOUNDATION_BUILD_DIR=$(build_directory ${deployment_target} foundation)
21302138
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
21312139
set -x
21322140
"${XCTEST_SOURCE_DIR}"/build_script.py test \
21332141
--swiftc="${SWIFTC_BIN}" \
2142+
--foundation-build-dir="${FOUNDATION_BUILD_DIR}/Foundation" \
21342143
"${XCTEST_BUILD_DIR}"
21352144
{ set +x; } 2>/dev/null
21362145
fi

0 commit comments

Comments
 (0)