Skip to content

Commit 34867c5

Browse files
committed
Add support for swift-xcode-playground-support project
1 parent 7aaa565 commit 34867c5

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"
@@ -184,6 +190,8 @@ KNOWN_SETTINGS=(
184190
install-xctest "" "whether to install xctest"
185191
install-foundation "" "whether to install foundation"
186192
install-libdispatch "" "whether to install libdispatch"
193+
install-playgroundlogger "" "whether to install PlaygroundLogger"
194+
install-playgroundsupport "" "whether to install PlaygroundSupport"
187195
darwin-install-extract-symbols "" "whether to extract symbols with dsymutil during installations"
188196
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**"
189197
stdlib-deployment-targets "" "space-separated list of targets to configure the Swift standard library to be compiled or cross-compiled for"
@@ -390,6 +398,14 @@ function set_build_options_for_host() {
390398
case ${host} in
391399
linux-x86_64)
392400
SWIFT_HOST_VARIANT_ARCH="x86_64"
401+
playgroundlogger_build_cmd="${PLAYGROUNDLOGGER_SOURCE_DIR}/build.py"
402+
playgroundlogger_build_options=(
403+
--swiftc "$(build_directory_bin ${host} swift)"
404+
--foundation "$(build_directory ${host} foundation)"
405+
--build-dir "$(build_directory ${host} playgroundlogger)"
406+
--swift-build-dir "$(build_directory ${host} swift)"
407+
--`python -c 'import sys; print sys.argv[1].lower()' ${PLAYGROUNDLOGGER_BUILD_TYPE}`
408+
)
393409
;;
394410
linux-armv6)
395411
SWIFT_HOST_VARIANT_ARCH="armv6"
@@ -437,6 +453,9 @@ function set_build_options_for_host() {
437453
swiftpm_bootstrap_options=(
438454
--sysroot="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
439455
)
456+
playgroundlogger_build_cmd="xcodebuild"
457+
playgroundlogger_build_target=("PlaygroundLogger_TestDriver")
458+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="MacOSX.platform"
440459
;;
441460
iphonesimulator-i386)
442461
xcrun_sdk_name="iphonesimulator"
@@ -452,6 +471,9 @@ function set_build_options_for_host() {
452471
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
453472
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
454473
)
474+
playgroundlogger_build_cmd="xcodebuild"
475+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
476+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneSimulator.platform"
455477
;;
456478
iphonesimulator-x86_64)
457479
xcrun_sdk_name="iphonesimulator"
@@ -467,6 +489,9 @@ function set_build_options_for_host() {
467489
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
468490
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
469491
)
492+
playgroundlogger_build_cmd="xcodebuild"
493+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
494+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneSimulator.platform"
470495
;;
471496
iphoneos-armv7)
472497
xcrun_sdk_name="iphoneos"
@@ -482,6 +507,9 @@ function set_build_options_for_host() {
482507
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
483508
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
484509
)
510+
playgroundlogger_build_cmd="xcodebuild"
511+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
512+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
485513
;;
486514
iphoneos-armv7s)
487515
xcrun_sdk_name="iphoneos"
@@ -497,6 +525,9 @@ function set_build_options_for_host() {
497525
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
498526
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
499527
)
528+
playgroundlogger_build_cmd="xcodebuild"
529+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
530+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
500531
;;
501532
iphoneos-arm64)
502533
xcrun_sdk_name="iphoneos"
@@ -512,6 +543,9 @@ function set_build_options_for_host() {
512543
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
513544
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
514545
)
546+
playgroundlogger_build_cmd="xcodebuild"
547+
playgroundlogger_build_target=("PlaygroundLogger_iOS")
548+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="iPhoneOS.platform"
515549
;;
516550
appletvsimulator-x86_64)
517551
xcrun_sdk_name="appletvsimulator"
@@ -527,6 +561,9 @@ function set_build_options_for_host() {
527561
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
528562
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
529563
)
564+
playgroundlogger_build_cmd="xcodebuild"
565+
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
566+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="AppleTVSimulator.platform"
530567
;;
531568
appletvos-arm64)
532569
xcrun_sdk_name="appletvos"
@@ -542,6 +579,9 @@ function set_build_options_for_host() {
542579
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
543580
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
544581
)
582+
playgroundlogger_build_cmd="xcodebuild"
583+
playgroundlogger_build_target=("PlaygroundLogger_tvOS")
584+
PLAYGROUNDLOGGER_INSTALL_PLATFORM="AppleTVOS.platform"
545585
;;
546586
watchsimulator-i386)
547587
xcrun_sdk_name="watchsimulator"
@@ -1086,6 +1126,8 @@ SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
10861126
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
10871127
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
10881128
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
1129+
PLAYGROUNDLOGGER_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundLogger"
1130+
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support/PlaygroundSupport"
10891131

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

1162+
if [[ ! "${SKIP_BUILD_PLAYGROUNDLOGGER}" && ! -d ${PLAYGROUNDLOGGER_SOURCE_DIR} ]]; then
1163+
echo "Couldn't find PlaygroundLogger source directory."
1164+
exit 1
1165+
fi
1166+
1167+
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR} ]]; then
1168+
echo "Couldn't find PlaygroundSupport source directory."
1169+
exit 1
1170+
fi
1171+
11201172
# Symlink clang into the llvm tree.
11211173
CLANG_SOURCE_DIR="${LLVM_SOURCE_DIR}/tools/clang"
11221174
if [ ! -e "${WORKSPACE}/clang" ] ; then
@@ -1153,6 +1205,12 @@ fi
11531205
if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
11541206
PRODUCTS=("${PRODUCTS[@]}" foundation)
11551207
fi
1208+
if [[ ! "${SKIP_BUILD_PLAYGROUNDLOGGER}" ]] ; then
1209+
PRODUCTS=("${PRODUCTS[@]}" playgroundlogger)
1210+
fi
1211+
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] ; then
1212+
PRODUCTS=("${PRODUCTS[@]}" playgroundsupport)
1213+
fi
11561214
# SwiftPM is dependent on XCTest, so XCTest must be added to the list of
11571215
# build products first.
11581216
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
@@ -1414,6 +1472,13 @@ function build_directory_bin() {
14141472
libdispatch)
14151473
echo "${root}/bin"
14161474
;;
1475+
playgroundlogger)
1476+
# FIXME: var name for build type
1477+
echo "${root}/${PLAYGROUNDLOGGER_BUILD_TYPE}/bin"
1478+
;;
1479+
playgroundsupport)
1480+
echo "${root}/${PLAYGROUNDSUPPORT_BUILD_TYPE}/bin"
1481+
;;
14171482
*)
14181483
echo "error: unknown product: ${product}"
14191484
exit 1
@@ -1525,6 +1590,13 @@ function cmake_config_opt() {
15251590
;;
15261591
libdispatch)
15271592
;;
1593+
playgroundlogger)
1594+
# FIXME: var name
1595+
echo "--config ${PLAYGROUNDLOGGER_BUILD_TYPE}"
1596+
;;
1597+
playgroundsupport)
1598+
echo "--config ${PLAYGROUNDSUPPORT_BUILD_TYPE}"
1599+
;;
15281600
*)
15291601
echo "error: unknown product: ${product}"
15301602
exit 1
@@ -2203,6 +2275,30 @@ for host in "${ALL_HOSTS[@]}"; do
22032275
# libdispatch builds itself and doesn't use cmake
22042276
continue
22052277
;;
2278+
playgroundlogger)
2279+
PLAYGROUNDLOGGER_BUILD_DIR=$(build_directory ${host} ${product})
2280+
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2281+
2282+
set -x
2283+
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
2284+
mkdir -p "${PLAYGROUNDLOGGER_BUILD_DIR}"
2285+
"${playgroundlogger_build_cmd}" -configuration "${PLAYGROUNDLOGGER_BUILD_TYPE}" -target "${playgroundlogger_build_target}" install SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT=${build_dir} INSTALL_PATH="/" SKIP_INSTALL=NO
2286+
popd
2287+
{ set +x; } 2>/dev/null
2288+
continue
2289+
;;
2290+
playgroundsupport)
2291+
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
2292+
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2293+
2294+
set -x
2295+
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2296+
mkdir -p "${PLAYGROUNDSUPPORT_BUILD_DIR}"
2297+
"xcodebuild" -configuration "${PLAYGROUNDSUPPORT_BUILD_TYPE}" -target AllProducts SWIFT_EXEC="${SWIFTC_BIN}" DSTROOT="$(get_host_install_destdir ${host})"
2298+
popd
2299+
{ set +x; } 2>/dev/null
2300+
continue
2301+
;;
22062302
*)
22072303
echo "error: unknown product: ${product}"
22082304
exit 1
@@ -2472,6 +2568,19 @@ for host in "${ALL_HOSTS[@]}"; do
24722568
echo "--- Finished tests for ${product} ---"
24732569
continue
24742570
;;
2571+
playgroundlogger)
2572+
SWIFT_DYLIB_PATH=$(build_directory ${host} swift)/lib/swift/macosx/
2573+
PLAYGROUNDLOGGER_FRAMEWORK_PATH=$(build_directory ${host} ${product})
2574+
set -x
2575+
pushd "${PLAYGROUNDLOGGER_FRAMEWORK_PATH}"
2576+
DYLD_LIBRARY_PATH=$SWIFT_DYLIB_PATH DYLD_FRAMEWORK_PATH=$PLAYGROUNDLOGGER_FRAMEWORK_PATH ./PlaygroundLogger_TestDriver
2577+
popd
2578+
{ set +x; } 2>/dev/null
2579+
continue
2580+
;;
2581+
playgroundsupport)
2582+
continue
2583+
;;
24752584
*)
24762585
echo "error: unknown product: ${product}"
24772586
exit 1
@@ -2689,6 +2798,64 @@ for host in "${ALL_HOSTS[@]}"; do
26892798
# As libdispatch installation is self-contained, we break early here.
26902799
continue
26912800
;;
2801+
playgroundlogger)
2802+
if [[ -z "${INSTALL_PLAYGROUNDLOGGER}" ]] ; then
2803+
continue
2804+
fi
2805+
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
2806+
echo "--install-destdir is required to install products."
2807+
exit 1
2808+
fi
2809+
2810+
echo "--- Installing ${product} ---"
2811+
PLAYGROUNDLOGGER_BUILD_DIR=$(build_directory ${host} playgroundlogger)
2812+
PLAYGROUNDLOGGER_INSTALL_PREFIX="${INSTALL_DESTDIR}"
2813+
# Note that installing directly to /usr/lib/swift usually
2814+
# requires root permissions.
2815+
set -x
2816+
case "$(uname -s)" in
2817+
Linux)
2818+
PLAYGROUNDLOGGER_INSTALL_DIR="$(get_host_install_destdir ${host})/$(get_host_install_prefix ${host})/lib/swift/linux"
2819+
mkdir -p "${PLAYGROUNDLOGGER_INSTALL_DIR}"
2820+
cp -R "${PLAYGROUNDLOGGER_BUILD_DIR}"/libPlaygroundLogger.so "${PLAYGROUNDLOGGER_INSTALL_DIR}"
2821+
;;
2822+
Darwin)
2823+
pushd "${PLAYGROUNDLOGGER_SOURCE_DIR}"
2824+
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})"
2825+
popd
2826+
continue
2827+
;;
2828+
*)
2829+
echo "error: --install-playgroundlogger is not supported on this platform"
2830+
exit 1
2831+
;;
2832+
esac
2833+
{ set +x; } 2>/dev/null
2834+
2835+
# As XCTest installation is self-contained, we break early here.
2836+
continue
2837+
;;
2838+
playgroundsupport)
2839+
set -x
2840+
if [[ -z "${INSTALL_PLAYGROUNDSUPPORT}" ]] ; then
2841+
continue
2842+
fi
2843+
case "$(uname -s)" in
2844+
Linux)
2845+
;;
2846+
FreeBSD)
2847+
;;
2848+
CYGWIN_NT-10.0)
2849+
;;
2850+
Darwin)
2851+
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2852+
xcodebuild -target AllProducts -configuration ${PLAYGROUNDSUPPORT_BUILD_TYPE} install SWIFT_EXEC="${SWIFTC_BIN}" DT_TOOLCHAIN_DIR="${TOOLCHAIN_PREFIX}" DSTROOT="$(get_host_install_destdir ${host})"
2853+
popd
2854+
continue
2855+
;;
2856+
esac
2857+
{ set +x; } 2>/dev/null
2858+
;;
26922859
*)
26932860
echo "error: unknown product: ${product}"
26942861
exit 1

0 commit comments

Comments
 (0)