Skip to content

Commit 0ef3f2c

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>. (cherry picked from commit 3a0eaea)
1 parent a4f77de commit 0ef3f2c

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
@@ -486,7 +486,6 @@ function set_build_options_for_host() {
486486
swiftpm_bootstrap_options=(
487487
--sysroot="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
488488
)
489-
playgroundlogger_build_target=("PlaygroundLogger_TestDriver")
490489
;;
491490
iphonesimulator-i386)
492491
xcrun_sdk_name="iphonesimulator"
@@ -502,7 +501,6 @@ function set_build_options_for_host() {
502501
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
503502
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
504503
)
505-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
506504
;;
507505
iphonesimulator-x86_64)
508506
xcrun_sdk_name="iphonesimulator"
@@ -518,7 +516,6 @@ function set_build_options_for_host() {
518516
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
519517
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
520518
)
521-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
522519
;;
523520
iphoneos-armv7)
524521
xcrun_sdk_name="iphoneos"
@@ -534,7 +531,6 @@ function set_build_options_for_host() {
534531
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
535532
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
536533
)
537-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
538534
;;
539535
iphoneos-armv7s)
540536
xcrun_sdk_name="iphoneos"
@@ -550,7 +546,6 @@ function set_build_options_for_host() {
550546
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
551547
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
552548
)
553-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
554549
;;
555550
iphoneos-arm64)
556551
xcrun_sdk_name="iphoneos"
@@ -566,7 +561,6 @@ function set_build_options_for_host() {
566561
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
567562
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
568563
)
569-
playgroundlogger_build_target=("PlaygroundLogger_iOS")
570564
;;
571565
appletvsimulator-x86_64)
572566
xcrun_sdk_name="appletvsimulator"
@@ -582,7 +576,6 @@ function set_build_options_for_host() {
582576
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
583577
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
584578
)
585-
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
586579
;;
587580
appletvos-arm64)
588581
xcrun_sdk_name="appletvos"
@@ -598,7 +591,6 @@ function set_build_options_for_host() {
598591
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
599592
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
600593
)
601-
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
602594
;;
603595
watchsimulator-i386)
604596
xcrun_sdk_name="watchsimulator"
@@ -1186,13 +1178,7 @@ XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
11861178
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
11871179
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
11881180
LIBICU_SOURCE_DIR="${WORKSPACE}/icu"
1189-
PLAYGROUNDLOGGER_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundLogger"
1190-
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundSupport"
1191-
1192-
if [[ ! "${SKIP_BUILD_PLAYGROUNDLOGGER}" && ! -d ${PLAYGROUNDLOGGER_SOURCE_DIR} ]]; then
1193-
echo "Couldn't find PlaygroundLogger source directory."
1194-
exit 1
1195-
fi
1181+
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support"
11961182

11971183
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR} ]]; then
11981184
echo "Couldn't find PlaygroundSupport source directory."
@@ -2586,18 +2572,26 @@ for host in "${ALL_HOSTS[@]}"; do
25862572
exit 1
25872573
fi
25882574

2589-
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
25902575
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
25912576

25922577
set -x
25932578
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2594-
mkdir -p "${PLAYGROUNDSUPPORT_BUILD_DIR}"
2595-
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -target AllProducts SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT="$(get_host_install_destdir ${host})"
2596-
popd
2597-
2598-
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
2599-
mkdir -p "${PLAYGROUNDSUPPORT_BUILD_DIR}"
2600-
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -target "${playgroundlogger_build_target}" install SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT=${build_dir} INSTALL_PATH="/" SKIP_INSTALL=NO
2579+
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
2580+
"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
2581+
2582+
if [[ $(not ${SKIP_TEST_PLAYGROUNDSUPPORT}) ]]; then
2583+
# If we're going to end up testing PlaygroundLogger/PlaygroundSupport, then we need to build the tests too.
2584+
"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
2585+
fi
2586+
fi
2587+
2588+
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
2589+
"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
2590+
fi
2591+
2592+
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
2593+
"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
2594+
fi
26012595
popd
26022596
{ set +x; } 2>/dev/null
26032597
continue
@@ -2922,14 +2916,18 @@ for host in "${ALL_HOSTS[@]}"; do
29222916
continue
29232917
;;
29242918
playgroundsupport)
2919+
if [[ "${SKIP_TEST_PLAYGROUNDSUPPORT}" ]]; then
2920+
continue
2921+
fi
2922+
29252923
if [[ "${host}" != "macosx"* ]]; then
29262924
echo "Skipping PlaygroundLogger tests on non-macOS platform"
29272925
continue
29282926
fi
29292927

2930-
SWIFT_DYLIB_PATH=$(build_directory ${host} swift)/lib/swift/macosx/
2931-
PLAYGROUNDLOGGER_FRAMEWORK_PATH=$(build_directory ${host} ${product})
29322928
set -x
2929+
SWIFT_DYLIB_PATH=$(build_directory ${host} swift)/lib/swift/macosx/
2930+
PLAYGROUNDLOGGER_FRAMEWORK_PATH=$(build_directory ${host} ${product})/DerivedData/Build/Products/${PLAYGROUNDSUPPORT_BUILD_TYPE}
29332931
pushd "${PLAYGROUNDLOGGER_FRAMEWORK_PATH}"
29342932
DYLD_LIBRARY_PATH=$SWIFT_DYLIB_PATH DYLD_FRAMEWORK_PATH=$PLAYGROUNDLOGGER_FRAMEWORK_PATH ./PlaygroundLogger_TestDriver
29352933
popd
@@ -3243,14 +3241,22 @@ for host in "${ALL_HOSTS[@]}"; do
32433241

32443242
echo "--- Installing ${product} ---"
32453243

3244+
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
3245+
32463246
case "$(uname -s)" in
32473247
Darwin)
32483248
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
3249-
xcodebuild -target AllProducts -configuration ${PLAYGROUNDSUPPORT_BUILD_TYPE} install SWIFT_EXEC="${SWIFTC_BIN}" DT_TOOLCHAIN_DIR="${TOOLCHAIN_PREFIX}" DSTROOT="$(get_host_install_destdir ${host})"
3250-
popd
3251-
3252-
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
3253-
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})"
3249+
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
3250+
"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
3251+
fi
3252+
3253+
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
3254+
"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
3255+
fi
3256+
3257+
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
3258+
"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
3259+
fi
32543260
popd
32553261
continue
32563262
;;

0 commit comments

Comments
 (0)