Skip to content

Commit 3a0eaea

Browse files
committed
[build-script] Adjust how PlaygroundLogger and PlaygroundSupport are built.
Instead of building separately, they are now built together using a new workspace with new schemes. As a result, xcodebuild is now invoked once per-platform, allowing for platform-specific build setting and architecture overrides. This addresses <rdar://problem/36512531>.
1 parent 806c01d commit 3a0eaea

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

utils/build-script-impl

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ function set_build_options_for_host() {
488488
swiftpm_bootstrap_options=(
489489
--sysroot="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
490490
)
491-
playgroundlogger_build_target=("PlaygroundLogger_TestDriver")
492491
;;
493492
iphonesimulator-i386)
494493
xcrun_sdk_name="iphonesimulator"
@@ -504,7 +503,6 @@ function set_build_options_for_host() {
504503
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
505504
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
506505
)
507-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
508506
;;
509507
iphonesimulator-x86_64)
510508
xcrun_sdk_name="iphonesimulator"
@@ -520,7 +518,6 @@ function set_build_options_for_host() {
520518
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
521519
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
522520
)
523-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
524521
;;
525522
iphoneos-armv7)
526523
xcrun_sdk_name="iphoneos"
@@ -536,7 +533,6 @@ function set_build_options_for_host() {
536533
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
537534
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
538535
)
539-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
540536
;;
541537
iphoneos-armv7s)
542538
xcrun_sdk_name="iphoneos"
@@ -552,7 +548,6 @@ function set_build_options_for_host() {
552548
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
553549
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
554550
)
555-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
556551
;;
557552
iphoneos-arm64)
558553
xcrun_sdk_name="iphoneos"
@@ -568,7 +563,6 @@ function set_build_options_for_host() {
568563
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
569564
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
570565
)
571-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
572566
;;
573567
appletvsimulator-x86_64)
574568
xcrun_sdk_name="appletvsimulator"
@@ -584,7 +578,6 @@ function set_build_options_for_host() {
584578
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
585579
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
586580
)
587-
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
588581
;;
589582
appletvos-arm64)
590583
xcrun_sdk_name="appletvos"
@@ -600,7 +593,6 @@ function set_build_options_for_host() {
600593
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
601594
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
602595
)
603-
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
604596
;;
605597
watchsimulator-i386)
606598
xcrun_sdk_name="watchsimulator"
@@ -1188,13 +1180,7 @@ XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
11881180
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
11891181
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
11901182
LIBICU_SOURCE_DIR="${WORKSPACE}/icu"
1191-
PLAYGROUNDLOGGER_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundLogger"
1192-
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundSupport"
1193-
1194-
if [[ ! "${SKIP_BUILD_PLAYGROUNDLOGGER}" && ! -d ${PLAYGROUNDLOGGER_SOURCE_DIR} ]]; then
1195-
echo "Couldn't find PlaygroundLogger source directory."
1196-
exit 1
1197-
fi
1183+
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support"
11981184

11991185
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR} ]]; then
12001186
echo "Couldn't find PlaygroundSupport source directory."
@@ -2622,18 +2608,26 @@ for host in "${ALL_HOSTS[@]}"; do
26222608
exit 1
26232609
fi
26242610

2625-
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
26262611
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
26272612

26282613
set -x
26292614
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2630-
mkdir -p "${PLAYGROUNDSUPPORT_BUILD_DIR}"
2631-
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -target AllProducts SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT="$(get_host_install_destdir ${host})"
2632-
popd
2633-
2634-
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
2635-
mkdir -p "${PLAYGROUNDSUPPORT_BUILD_DIR}"
2636-
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -target "${playgroundlogger_build_target}" install SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT=${build_dir} INSTALL_PATH="/" SKIP_INSTALL=NO
2615+
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
2616+
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-macOS -sdk macosx -arch x86_64 -derivedDataPath "${build_dir}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" ONLY_ACTIVE_ARCH=NO
2617+
2618+
if [[ $(not ${SKIP_TEST_PLAYGROUNDSUPPORT}) ]]; then
2619+
# If we're going to end up testing PlaygroundLogger/PlaygroundSupport, then we need to build the tests too.
2620+
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-Test-PlaygroundLogger-macOS -sdk macosx -arch x86_64 -derivedDataPath "${build_dir}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" ONLY_ACTIVE_ARCH=NO BUILD_PLAYGROUNDLOGGER_TESTS=YES
2621+
fi
2622+
fi
2623+
2624+
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
2625+
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-iOS -sdk iphonesimulator -arch x86_64 -derivedDataPath "${build_dir}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" ONLY_ACTIVE_ARCH=NO
2626+
fi
2627+
2628+
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
2629+
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-tvOS -sdk appletvsimulator -arch x86_64 -derivedDataPath "${build_dir}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" ONLY_ACTIVE_ARCH=NO
2630+
fi
26372631
popd
26382632
{ set +x; } 2>/dev/null
26392633
continue
@@ -2957,14 +2951,18 @@ for host in "${ALL_HOSTS[@]}"; do
29572951
continue
29582952
;;
29592953
playgroundsupport)
2954+
if [[ "${SKIP_TEST_PLAYGROUNDSUPPORT}" ]]; then
2955+
continue
2956+
fi
2957+
29602958
if [[ "${host}" != "macosx"* ]]; then
29612959
echo "Skipping PlaygroundLogger tests on non-macOS platform"
29622960
continue
29632961
fi
29642962

2965-
SWIFT_DYLIB_PATH=$(build_directory ${host} swift)/lib/swift/macosx/
2966-
PLAYGROUNDLOGGER_FRAMEWORK_PATH=$(build_directory ${host} ${product})
29672963
set -x
2964+
SWIFT_DYLIB_PATH=$(build_directory ${host} swift)/lib/swift/macosx/
2965+
PLAYGROUNDLOGGER_FRAMEWORK_PATH=$(build_directory ${host} ${product})/DerivedData/Build/Products/${PLAYGROUNDSUPPORT_BUILD_TYPE}
29682966
pushd "${PLAYGROUNDLOGGER_FRAMEWORK_PATH}"
29692967
DYLD_LIBRARY_PATH=$SWIFT_DYLIB_PATH DYLD_FRAMEWORK_PATH=$PLAYGROUNDLOGGER_FRAMEWORK_PATH ./PlaygroundLogger_TestDriver
29702968
popd
@@ -3278,14 +3276,22 @@ for host in "${ALL_HOSTS[@]}"; do
32783276

32793277
echo "--- Installing ${product} ---"
32803278

3279+
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
3280+
32813281
case "$(uname -s)" in
32823282
Darwin)
32833283
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
3284-
xcodebuild -target AllProducts -configuration ${PLAYGROUNDSUPPORT_BUILD_TYPE} install SWIFT_EXEC="${SWIFTC_BIN}" DT_TOOLCHAIN_DIR="${TOOLCHAIN_PREFIX}" DSTROOT="$(get_host_install_destdir ${host})"
3285-
popd
3286-
3287-
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
3288-
xcodebuild -target "All Platforms Logger" -configuration Toolchain_${PLAYGROUNDSUPPORT_BUILD_TYPE} install SWIFT_EXEC="${SWIFTC_BIN}" DT_TOOLCHAIN_DIR="${TOOLCHAIN_PREFIX}" DSTROOT="$(get_host_install_destdir ${host})"
3284+
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
3285+
"xcodebuild" install -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-macOS -sdk macosx -arch x86_64 -derivedDataPath "${PLAYGROUNDSUPPORT_BUILD_DIR}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" ONLY_ACTIVE_ARCH=NO DSTROOT="$(get_host_install_destdir ${host})" TOOLCHAIN_INSTALL_DIR="${TOOLCHAIN_PREFIX}" BUILD_PLAYGROUNDLOGGER_TESTS=NO
3286+
fi
3287+
3288+
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
3289+
"xcodebuild" install -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-iOS -sdk iphonesimulator -arch x86_64 -derivedDataPath "${PLAYGROUNDSUPPORT_BUILD_DIR}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" ONLY_ACTIVE_ARCH=NO DSTROOT="$(get_host_install_destdir ${host})" TOOLCHAIN_INSTALL_DIR="${TOOLCHAIN_PREFIX}" BUILD_PLAYGROUNDLOGGER_TESTS=NO
3290+
fi
3291+
3292+
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
3293+
"xcodebuild" install -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-tvOS -sdk appletvsimulator -arch x86_64 -derivedDataPath "${PLAYGROUNDSUPPORT_BUILD_DIR}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" ONLY_ACTIVE_ARCH=NO DSTROOT="$(get_host_install_destdir ${host})" TOOLCHAIN_INSTALL_DIR="${TOOLCHAIN_PREFIX}" BUILD_PLAYGROUNDLOGGER_TESTS=NO
3294+
fi
32893295
popd
32903296
continue
32913297
;;

0 commit comments

Comments
 (0)