Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ build the Debug variant of the Swift standard library and SDK overlay""",
action="store_const",
const="Debug",
dest="cmark_build_variant")
build_variant_override_group.add_argument("--debug-foundation",
help="build the Debug variant of Foundation",
action="store_const",
const="Debug",
dest="foundation_build_variant")

assertions_group = parser.add_mutually_exclusive_group(required=False)
assertions_group.add_argument("--assertions",
Expand Down Expand Up @@ -513,6 +518,9 @@ placed""",
if args.lldb_build_variant is None:
args.lldb_build_variant = args.build_variant

if args.foundation_build_variant is None:
args.foundation_build_variant = args.build_variant

# Assertions are enabled by default.
if args.assertions is None:
args.assertions = True
Expand Down Expand Up @@ -692,6 +700,10 @@ placed""",
"--cmake-generator", args.cmake_generator,
"--workspace", SWIFT_SOURCE_ROOT
]
if args.build_foundation:
build_script_impl_args += [
"--foundation-build-type", args.foundation_build_variant
]
build_script_impl_args += build_script_impl_inferred_args

# If we have extra_swift_args, combine all of them together and then add
Expand Down
14 changes: 11 additions & 3 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ KNOWN_SETTINGS=(
swift-stdlib-enable-assertions "1" "enable assertions in Swift"
lldb-build-type "Debug" "the CMake build variant for LLDB"
llbuild-build-type "Debug" "the CMake build variant for llbuild"
foundation-build-type "Debug" "the build variant for Foundation"
llbuild-enable-assertions "1" "enable assertions in llbuild"
enable-asan "" "enable AddressSanitizer"
cmake "" "path to the cmake binary"
Expand Down Expand Up @@ -1706,6 +1707,8 @@ for deployment_target in "${NATIVE_TOOLS_DEPLOYMENT_TARGETS[@]}" "${CROSS_TOOLS_
continue
;;
foundation)
# the configuration script requires knowing about XCTest's location for building and running the tests
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"
SWIFT_BUILD_PATH="$(build_directory $deployment_target swift)"
Expand All @@ -1720,7 +1723,7 @@ for deployment_target in "${NATIVE_TOOLS_DEPLOYMENT_TARGETS[@]}" "${CROSS_TOOLS_
set -x
pushd "${FOUNDATION_SOURCE_DIR}"
SWIFTC="${SWIFTC_BIN}" CLANG="${LLVM_BIN}"/clang SWIFT="${SWIFT_BIN}" \
SDKROOT="${SWIFT_BUILD_PATH}" BUILD_DIR="${build_dir}" ./configure
SDKROOT="${SWIFT_BUILD_PATH}" BUILD_DIR="${build_dir}" DSTROOT="${INSTALL_DESTDIR}" PREFIX="${INSTALL_PREFIX}" LDFLAGS="-L${XCTEST_BUILD_DIR}" ./configure "${FOUNDATION_BUILD_TYPE}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Also need to pass -I ${XCTEST_BUILD_DIR}, is there a LDFLAGS equivalent for -I flags?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you're thinking of -L? Looks like that's already there.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it actually needs a -I to include the module search path, since the test target is compiling files that import XCTest.

This is the invocation that worked after I added -I :
mawadah@rad:~/src/Foundation$ /home/mawadah/src/build/buildbot_linux/swift-linux-x86_64/bin/swiftc -I/home/mawadah/src/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux -L/home/mawadah/src/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux -L/home/mawadah/src/build/buildbot_linux/xctest-linux-x86_64 -I../build/buildbot_linux/foundation-linux-x86_64/Foundation/usr/lib/swift -I../build/buildbot_linux/foundation-linux-x86_64/Foundation -L../build/buildbot_linux/foundation-linux-x86_64/Foundation -I /home/mawadah/src/build/buildbot_linux/xctest-linux-x86_64 TestFoundation/main.swift TestFoundation/TestNSArray.swift TestFoundation/TestNSIndexSet.swift TestFoundation/TestNSDictionary.swift TestFoundation/TestNSNumber.swift TestFoundation/TestNSPropertyList.swift TestFoundation/TestNSSet.swift TestFoundation/TestNSString.swift TestFoundation/TestNSURL.swift TestFoundation/TestNSFileManager.swift TestFoundation/TestNSCharacterSet.swift -o ../build/buildbot_linux/foundation-linux-x86_64/TestFoundation/TestFoundation

$NINJA_BIN
popd
{ set +x; } 2>/dev/null
Expand Down Expand Up @@ -1900,7 +1903,12 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
if [[ "$SKIP_TEST_FOUNDATION" ]]; then
continue
fi
# FIXME: We don't test foundation, yet...
build_dir=$(build_directory $deployment_target $product)
XCTEST_BUILD_DIR=$(build_directory $deployment_target xctest)
pushd "${FOUNDATION_SOURCE_DIR}"
$NINJA_BIN TestFoundation
LD_LIBRARY_PATH="${INSTALL_DESTDIR}"/"${INSTALL_PREFIX}"/lib/swift/:"${build_dir}/Foundation":"${XCTEST_BUILD_DIR}":$LD_LIBRARY_PATH "${build_dir}"/TestFoundation/TestFoundation
popd
continue
;;
*)
Expand Down Expand Up @@ -2048,7 +2056,7 @@ for deployment_target in "${NATIVE_TOOLS_DEPLOYMENT_TARGETS[@]}" "${CROSS_TOOLS_
build_dir=$(build_directory $deployment_target $product)
set -x
pushd "${FOUNDATION_SOURCE_DIR}"
DSTROOT="${INSTALL_DESTDIR}" BUILD_DIR="${build_dir}" ./install
$NINJA_BIN install
popd
{ set +x; } 2>/dev/null

Expand Down