Skip to content

Commit 159eab1

Browse files
committed
install Foundation via the ninja script and add the test phase for Foundation
The configuration script for Foundation respects debug and release builds so a new option for foundation-build-type has been added to control the build variant of Foundation. Resolve the FIXME for adding a mechanism for a custom invocation of running the Foundation unit tests Foundation now has an install target provided from the generated ninja script such that the potentially error prone install script is dramatically simplified into a single encapsulation of a ninja phony target of "install"; so adopt this new target for installation
1 parent cbf5495 commit 159eab1

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

utils/build-script

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ build the Debug variant of the Swift standard library and SDK overlay""",
349349
action="store_const",
350350
const="Debug",
351351
dest="cmark_build_variant")
352+
build_variant_override_group.add_argument("--debug-foundation",
353+
help="build the Debug variant of Foundation",
354+
action="store_const",
355+
const="Debug",
356+
dest="foundation_build_variant")
352357

353358
assertions_group = parser.add_mutually_exclusive_group(required=False)
354359
assertions_group.add_argument("--assertions",
@@ -513,6 +518,9 @@ placed""",
513518
if args.lldb_build_variant is None:
514519
args.lldb_build_variant = args.build_variant
515520

521+
if args.foundation_build_variant is None:
522+
args.foundation_build_variant = args.build_variant
523+
516524
# Assertions are enabled by default.
517525
if args.assertions is None:
518526
args.assertions = True
@@ -692,6 +700,10 @@ placed""",
692700
"--cmake-generator", args.cmake_generator,
693701
"--workspace", SWIFT_SOURCE_ROOT
694702
]
703+
if args.build_foundation:
704+
build_script_impl_args += [
705+
"--foundation-build-type", args.foundation_build_variant
706+
]
695707
build_script_impl_args += build_script_impl_inferred_args
696708

697709
# If we have extra_swift_args, combine all of them together and then add

utils/build-script-impl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ KNOWN_SETTINGS=(
7373
swift-stdlib-enable-assertions "1" "enable assertions in Swift"
7474
lldb-build-type "Debug" "the CMake build variant for LLDB"
7575
llbuild-build-type "Debug" "the CMake build variant for llbuild"
76+
foundation-build-type "Debug" "the build variant for Foundation"
7677
llbuild-enable-assertions "1" "enable assertions in llbuild"
7778
enable-asan "" "enable AddressSanitizer"
7879
cmake "" "path to the cmake binary"
@@ -1706,6 +1707,8 @@ for deployment_target in "${NATIVE_TOOLS_DEPLOYMENT_TARGETS[@]}" "${CROSS_TOOLS_
17061707
continue
17071708
;;
17081709
foundation)
1710+
# the configuration script requires knowing about XCTest's location for building and running the tests
1711+
XCTEST_BUILD_DIR=$(build_directory $deployment_target xctest)
17091712
SWIFTC_BIN="$(build_directory_bin $deployment_target swift)/swiftc"
17101713
SWIFT_BIN="$(build_directory_bin $deployment_target swift)/swift"
17111714
SWIFT_BUILD_PATH="$(build_directory $deployment_target swift)"
@@ -1720,7 +1723,7 @@ for deployment_target in "${NATIVE_TOOLS_DEPLOYMENT_TARGETS[@]}" "${CROSS_TOOLS_
17201723
set -x
17211724
pushd "${FOUNDATION_SOURCE_DIR}"
17221725
SWIFTC="${SWIFTC_BIN}" CLANG="${LLVM_BIN}"/clang SWIFT="${SWIFT_BIN}" \
1723-
SDKROOT="${SWIFT_BUILD_PATH}" BUILD_DIR="${build_dir}" ./configure
1726+
SDKROOT="${SWIFT_BUILD_PATH}" BUILD_DIR="${build_dir}" DSTROOT="${INSTALL_DESTDIR}" PREFIX="${INSTALL_PREFIX}" LDFLAGS="-L${XCTEST_BUILD_DIR}" ./configure "${FOUNDATION_BUILD_TYPE}"
17241727
$NINJA_BIN
17251728
popd
17261729
{ set +x; } 2>/dev/null
@@ -1900,7 +1903,12 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
19001903
if [[ "$SKIP_TEST_FOUNDATION" ]]; then
19011904
continue
19021905
fi
1903-
# FIXME: We don't test foundation, yet...
1906+
build_dir=$(build_directory $deployment_target $product)
1907+
XCTEST_BUILD_DIR=$(build_directory $deployment_target xctest)
1908+
pushd "${FOUNDATION_SOURCE_DIR}"
1909+
$NINJA_BIN TestFoundation
1910+
LD_LIBRARY_PATH="${INSTALL_DESTDIR}"/"${INSTALL_PREFIX}"/lib/swift/:"${build_dir}/Foundation":"${XCTEST_BUILD_DIR}":$LD_LIBRARY_PATH "${build_dir}"/TestFoundation/TestFoundation
1911+
popd
19041912
continue
19051913
;;
19061914
*)
@@ -2048,7 +2056,7 @@ for deployment_target in "${NATIVE_TOOLS_DEPLOYMENT_TARGETS[@]}" "${CROSS_TOOLS_
20482056
build_dir=$(build_directory $deployment_target $product)
20492057
set -x
20502058
pushd "${FOUNDATION_SOURCE_DIR}"
2051-
DSTROOT="${INSTALL_DESTDIR}" BUILD_DIR="${build_dir}" ./install
2059+
$NINJA_BIN install
20522060
popd
20532061
{ set +x; } 2>/dev/null
20542062

0 commit comments

Comments
 (0)