Skip to content

Commit c8b8838

Browse files
authored
Merge pull request #3407 from shahmishal/playground-support
Add support for swift-xcode-playground-support project
2 parents 78e2c8e + 34867c5 commit c8b8838

File tree

3 files changed

+193
-5
lines changed

3 files changed

+193
-5
lines changed

utils/build-script

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ class BuildScriptInvocation(object):
328328
args.build_xctest = False
329329
args.build_foundation = False
330330
args.build_libdispatch = False
331+
args.build_playgroundlogger = False
332+
args.build_playgroundsupport = False
331333

332334
# --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are
333335
# merely shorthands for --skip-build-{**os}-{device,simulator}
@@ -658,6 +660,10 @@ class BuildScriptInvocation(object):
658660
impl_args += ["--skip-build-libdispatch"]
659661
if not args.build_swiftpm:
660662
impl_args += ["--skip-build-swiftpm"]
663+
if not args.build_playgroundlogger:
664+
impl_args += ["--skip-build-playgroundlogger"]
665+
if not args.build_playgroundsupport:
666+
impl_args += ["--skip-build-playgroundsupport"]
661667
if args.build_swift_dynamic_stdlib:
662668
impl_args += ["--build-swift-dynamic-stdlib"]
663669
if args.build_swift_static_stdlib:
@@ -701,7 +707,9 @@ class BuildScriptInvocation(object):
701707
"--skip-test-swiftpm",
702708
"--skip-test-xctest",
703709
"--skip-test-foundation",
704-
"--skip-test-libdispatch"]
710+
"--skip-test-libdispatch",
711+
"--skip-test-playgroundlogger",
712+
"--skip-test-playgroundsupport"]
705713
if args.skip_test_linux:
706714
impl_args += ["--skip-test-linux"]
707715
if args.skip_test_freebsd:
@@ -1290,6 +1298,14 @@ details of the setups of other systems or automated environments.""")
12901298
help="build libdispatch",
12911299
action=arguments.action.optional_bool,
12921300
dest="build_libdispatch")
1301+
projects_group.add_argument("--playgroundlogger",
1302+
help="build playgroundlogger",
1303+
action="store_true",
1304+
dest="build_playgroundlogger")
1305+
projects_group.add_argument("--playgroundsupport",
1306+
help="build PlaygroundSupport",
1307+
action="store_true",
1308+
dest="build_playgroundsupport")
12931309
projects_group.add_argument(
12941310
"--build-ninja",
12951311
help="build the Ninja tool",

utils/build-script-impl

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ KNOWN_SETTINGS=(
8585
lldb-build-type "Debug" "the CMake build variant for LLDB"
8686
llbuild-build-type "Debug" "the CMake build variant for llbuild"
8787
foundation-build-type "Debug" "the build variant for Foundation"
88+
playgroundlogger-build-type "Debug" "the build variant for PlaygroundLogger"
89+
playgroundsupport-build-type "Debug" "the build variant for PlaygroundSupport"
8890
xctest-build-type "Debug" "the build variant for xctest"
8991
llbuild-enable-assertions "1" "enable assertions in llbuild"
9092
enable-asan "" "enable Address Sanitizer"
@@ -127,6 +129,8 @@ KNOWN_SETTINGS=(
127129
skip-build-foundation "" "set to skip building foundation"
128130
skip-build-libdispatch "" "set to skip building libdispatch"
129131
skip-build-benchmarks "" "set to skip building Swift Benchmark Suite"
132+
skip-build-playgroundlogger "" "set to skip building PlaygroundLogger"
133+
skip-build-playgroundsupport "" "set to skip building PlaygroundSupport"
130134
skip-test-cmark "" "set to skip testing CommonMark"
131135
skip-test-lldb "" "set to skip testing lldb"
132136
skip-test-swift "" "set to skip testing Swift"
@@ -135,6 +139,8 @@ KNOWN_SETTINGS=(
135139
skip-test-xctest "" "set to skip testing xctest"
136140
skip-test-foundation "" "set to skip testing foundation"
137141
skip-test-libdispatch "" "set to skip testing libdispatch"
142+
skip-test-playgroundlogger "" "set to skip testing PlaygroundLogger"
143+
skip-test-playgroundsupport "" "set to skip testing PlaygroundSupport"
138144
skip-test-linux "" "set to skip testing Swift stdlibs for Linux"
139145
skip-test-freebsd "" "set to skip testing Swift stdlibs for FreeBSD"
140146
skip-test-cygwin "" "set to skip testing Swift stdlibs for Cygwin"
@@ -185,6 +191,8 @@ KNOWN_SETTINGS=(
185191
install-xctest "" "whether to install xctest"
186192
install-foundation "" "whether to install foundation"
187193
install-libdispatch "" "whether to install libdispatch"
194+
install-playgroundlogger "" "whether to install PlaygroundLogger"
195+
install-playgroundsupport "" "whether to install PlaygroundSupport"
188196
darwin-install-extract-symbols "" "whether to extract symbols with dsymutil during installations"
189197
host-target "" "The host target. LLVM, Clang, and Swift will be built for this target. The built LLVM and Clang will be used to compile Swift for the cross-compilation targets. **This argument is required**"
190198
stdlib-deployment-targets "" "space-separated list of targets to configure the Swift standard library to be compiled or cross-compiled for"
@@ -391,6 +399,14 @@ function set_build_options_for_host() {
391399
case ${host} in
392400
linux-x86_64)
393401
SWIFT_HOST_VARIANT_ARCH="x86_64"
402+
playgroundlogger_build_cmd="${PLAYGROUNDLOGGER_SOURCE_DIR}/build.py"
403+
playgroundlogger_build_options=(
404+
--swiftc "$(build_directory_bin ${host} swift)"
405+
--foundation "$(build_directory ${host} foundation)"
406+
--build-dir "$(build_directory ${host} playgroundlogger)"
407+
--swift-build-dir "$(build_directory ${host} swift)"
408+
--`python -c 'import sys; print sys.argv[1].lower()' ${PLAYGROUNDLOGGER_BUILD_TYPE}`
409+
)
394410
;;
395411
linux-armv6)
396412
SWIFT_HOST_VARIANT_ARCH="armv6"
@@ -438,6 +454,9 @@ function set_build_options_for_host() {
438454
swiftpm_bootstrap_options=(
439455
--sysroot="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
440456
)
457+
playgroundlogger_build_cmd="xcodebuild"
458+
playgroundlogger_build_target=("PlaygroundLogger_TestDriver")
459+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="MacOSX.platform"
441460
;;
442461
iphonesimulator-i386)
443462
xcrun_sdk_name="iphonesimulator"
@@ -453,6 +472,9 @@ function set_build_options_for_host() {
453472
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
454473
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
455474
)
475+
playgroundlogger_build_cmd="xcodebuild"
476+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
477+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneSimulator.platform"
456478
;;
457479
iphonesimulator-x86_64)
458480
xcrun_sdk_name="iphonesimulator"
@@ -468,6 +490,9 @@ function set_build_options_for_host() {
468490
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
469491
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
470492
)
493+
playgroundlogger_build_cmd="xcodebuild"
494+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
495+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneSimulator.platform"
471496
;;
472497
iphoneos-armv7)
473498
xcrun_sdk_name="iphoneos"
@@ -483,6 +508,9 @@ function set_build_options_for_host() {
483508
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
484509
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
485510
)
511+
playgroundlogger_build_cmd="xcodebuild"
512+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
513+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
486514
;;
487515
iphoneos-armv7s)
488516
xcrun_sdk_name="iphoneos"
@@ -498,6 +526,9 @@ function set_build_options_for_host() {
498526
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
499527
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
500528
)
529+
playgroundlogger_build_cmd="xcodebuild"
530+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
531+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
501532
;;
502533
iphoneos-arm64)
503534
xcrun_sdk_name="iphoneos"
@@ -513,6 +544,9 @@ function set_build_options_for_host() {
513544
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
514545
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
515546
)
547+
playgroundlogger_build_cmd="xcodebuild"
548+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
549+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
516550
;;
517551
appletvsimulator-x86_64)
518552
xcrun_sdk_name="appletvsimulator"
@@ -528,6 +562,9 @@ function set_build_options_for_host() {
528562
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
529563
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
530564
)
565+
playgroundlogger_build_cmd="xcodebuild"
566+
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
567+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="AppleTVSimulator.platform"
531568
;;
532569
appletvos-arm64)
533570
xcrun_sdk_name="appletvos"
@@ -543,6 +580,9 @@ function set_build_options_for_host() {
543580
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
544581
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
545582
)
583+
playgroundlogger_build_cmd="xcodebuild"
584+
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
585+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="AppleTVOS.platform"
546586
;;
547587
watchsimulator-i386)
548588
xcrun_sdk_name="watchsimulator"
@@ -1087,6 +1127,8 @@ SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
10871127
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
10881128
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
10891129
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
1130+
PLAYGROUNDLOGGER_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundLogger"
1131+
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundSupport"
10901132

10911133
if [[ ! -d ${CMARK_SOURCE_DIR} ]]; then
10921134
echo "Couldn't find cmark source directory."
@@ -1118,6 +1160,16 @@ if [[ ! "${SKIP_BUILD_LIBDISPATCH}" && ! -d ${LIBDISPATCH_SOURCE_DIR} ]]; then
11181160
exit 1
11191161
fi
11201162

1163+
if [[ ! "${SKIP_BUILD_PLAYGROUNDLOGGER}" && ! -d ${PLAYGROUNDLOGGER_SOURCE_DIR} ]]; then
1164+
echo "Couldn't find PlaygroundLogger source directory."
1165+
exit 1
1166+
fi
1167+
1168+
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR} ]]; then
1169+
echo "Couldn't find PlaygroundSupport source directory."
1170+
exit 1
1171+
fi
1172+
11211173
# Symlink clang into the llvm tree.
11221174
CLANG_SOURCE_DIR="${LLVM_SOURCE_DIR}/tools/clang"
11231175
if [ ! -e "${WORKSPACE}/clang" ] ; then
@@ -1154,6 +1206,12 @@ fi
11541206
if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
11551207
PRODUCTS=("${PRODUCTS[@]}" foundation)
11561208
fi
1209+
if [[ ! "${SKIP_BUILD_PLAYGROUNDLOGGER}" ]] ; then
1210+
PRODUCTS=("${PRODUCTS[@]}" playgroundlogger)
1211+
fi
1212+
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] ; then
1213+
PRODUCTS=("${PRODUCTS[@]}" playgroundsupport)
1214+
fi
11571215
# SwiftPM is dependent on XCTest, so XCTest must be added to the list of
11581216
# build products first.
11591217
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
@@ -1415,6 +1473,13 @@ function build_directory_bin() {
14151473
libdispatch)
14161474
echo "${root}/bin"
14171475
;;
1476+
playgroundlogger)
1477+
# FIXME: var name for build type
1478+
echo "${root}/${PLAYGROUNDLOGGER_BUILD_TYPE}/bin"
1479+
;;
1480+
playgroundsupport)
1481+
echo "${root}/${PLAYGROUNDSUPPORT_BUILD_TYPE}/bin"
1482+
;;
14181483
*)
14191484
echo "error: unknown product: ${product}"
14201485
exit 1
@@ -1526,6 +1591,13 @@ function cmake_config_opt() {
15261591
;;
15271592
libdispatch)
15281593
;;
1594+
playgroundlogger)
1595+
# FIXME: var name
1596+
echo "--config ${PLAYGROUNDLOGGER_BUILD_TYPE}"
1597+
;;
1598+
playgroundsupport)
1599+
echo "--config ${PLAYGROUNDSUPPORT_BUILD_TYPE}"
1600+
;;
15291601
*)
15301602
echo "error: unknown product: ${product}"
15311603
exit 1
@@ -2205,6 +2277,30 @@ for host in "${ALL_HOSTS[@]}"; do
22052277
# libdispatch builds itself and doesn't use cmake
22062278
continue
22072279
;;
2280+
playgroundlogger)
2281+
PLAYGROUNDLOGGER_BUILD_DIR=$(build_directory ${host} ${product})
2282+
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2283+
2284+
set -x
2285+
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
2286+
mkdir -p "${PLAYGROUNDLOGGER_BUILD_DIR}"
2287+
"${playgroundlogger_build_cmd}" -configuration "${PLAYGROUNDLOGGER_BUILD_TYPE}" -target "${playgroundlogger_build_target}" install SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT=${build_dir} INSTALL_PATH="/" SKIP_INSTALL=NO
2288+
popd
2289+
{ set +x; } 2>/dev/null
2290+
continue
2291+
;;
2292+
playgroundsupport)
2293+
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
2294+
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2295+
2296+
set -x
2297+
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2298+
mkdir -p "${PLAYGROUNDSUPPORT_BUILD_DIR}"
2299+
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -target AllProducts SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT="$(get_host_install_destdir ${host})"
2300+
popd
2301+
{ set +x; } 2>/dev/null
2302+
continue
2303+
;;
22082304
*)
22092305
echo "error: unknown product: ${product}"
22102306
exit 1
@@ -2474,6 +2570,19 @@ for host in "${ALL_HOSTS[@]}"; do
24742570
echo "--- Finished tests for ${product} ---"
24752571
continue
24762572
;;
2573+
playgroundlogger)
2574+
SWIFT_DYLIB_PATH=$(build_directory ${host} swift)/lib/swift/macosx/
2575+
PLAYGROUNDLOGGER_FRAMEWORK_PATH=$(build_directory ${host} ${product})
2576+
set -x
2577+
pushd "${PLAYGROUNDLOGGER_FRAMEWORK_PATH}"
2578+
DYLD_LIBRARY_PATH=$SWIFT_DYLIB_PATH DYLD_FRAMEWORK_PATH=$PLAYGROUNDLOGGER_FRAMEWORK_PATH ./PlaygroundLogger_TestDriver
2579+
popd
2580+
{ set +x; } 2>/dev/null
2581+
continue
2582+
;;
2583+
playgroundsupport)
2584+
continue
2585+
;;
24772586
*)
24782587
echo "error: unknown product: ${product}"
24792588
exit 1
@@ -2691,6 +2800,64 @@ for host in "${ALL_HOSTS[@]}"; do
26912800
# As libdispatch installation is self-contained, we break early here.
26922801
continue
26932802
;;
2803+
playgroundlogger)
2804+
if [[ -z "${INSTALL_PLAYGROUNDLOGGER}" ]] ; then
2805+
continue
2806+
fi
2807+
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
2808+
echo "--install-destdir is required to install products."
2809+
exit 1
2810+
fi
2811+
2812+
echo "--- Installing ${product} ---"
2813+
PLAYGROUNDLOGGER_BUILD_DIR=$(build_directory ${host} playgroundlogger)
2814+
PLAYGROUNDLOGGER_INSTALL_PREFIX="${INSTALL_DESTDIR}"
2815+
# Note that installing directly to /usr/lib/swift usually
2816+
# requires root permissions.
2817+
set -x
2818+
case "$(uname -s)" in
2819+
Linux)
2820+
PLAYGROUNDLOGGER_INSTALL_DIR="$(get_host_install_destdir ${host})/$(get_host_install_prefix ${host})/lib/swift/linux"
2821+
mkdir -p "${PLAYGROUNDLOGGER_INSTALL_DIR}"
2822+
cp -R "${PLAYGROUNDLOGGER_BUILD_DIR}"/libPlaygroundLogger.so "${PLAYGROUNDLOGGER_INSTALL_DIR}"
2823+
;;
2824+
Darwin)
2825+
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
2826+
xcodebuild -target "All Platforms Logger" -configuration Toolchain_${PLAYGROUNDLOGGER_BUILD_TYPE} install SWIFT_EXEC="${SWIFTC_BIN}" DT_TOOLCHAIN_DIR="${TOOLCHAIN_PREFIX}" DSTROOT="$(get_host_install_destdir ${host})"
2827+
popd
2828+
continue
2829+
;;
2830+
*)
2831+
echo "error: --install-playgroundlogger is not supported on this platform"
2832+
exit 1
2833+
;;
2834+
esac
2835+
{ set +x; } 2>/dev/null
2836+
2837+
# As XCTest installation is self-contained, we break early here.
2838+
continue
2839+
;;
2840+
playgroundsupport)
2841+
set -x
2842+
if [[ -z "${INSTALL_PLAYGROUNDSUPPORT}" ]] ; then
2843+
continue
2844+
fi
2845+
case "$(uname -s)" in
2846+
Linux)
2847+
;;
2848+
FreeBSD)
2849+
;;
2850+
CYGWIN_NT-10.0)
2851+
;;
2852+
Darwin)
2853+
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2854+
xcodebuild -target AllProducts -configuration ${PLAYGROUNDSUPPORT_BUILD_TYPE} install SWIFT_EXEC="${SWIFTC_BIN}" DT_TOOLCHAIN_DIR="${TOOLCHAIN_PREFIX}" DSTROOT="$(get_host_install_destdir ${host})"
2855+
popd
2856+
continue
2857+
;;
2858+
esac
2859+
{ set +x; } 2>/dev/null
2860+
;;
26942861
*)
26952862
echo "error: unknown product: ${product}"
26962863
exit 1

0 commit comments

Comments
 (0)