Skip to content

Commit f4086d8

Browse files
committed
build: migrate playground support to post-build artifact
This migrates the playground support out of the build-script-impl and into the python based build system. This makes it build more similarly to the Swift Package Manager and SourceKit-LSP. More importantly, it reduces the dependency on build-script-impl.
1 parent 7b88f71 commit f4086d8

File tree

7 files changed

+139
-108
lines changed

7 files changed

+139
-108
lines changed

utils/build-presets.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ swift-primary-variant-arch=x86_64
371371
skip-build-llbuild
372372
skip-test-llbuild
373373
skip-test-swiftpm
374-
skip-build-playgroundsupport
375374
skip-test-playgroundsupport
376375

377376
# This preset is used by CI to test swift-corelibs-xctest.
@@ -870,7 +869,6 @@ install-libcxx
870869

871870
skip-test-linux
872871
skip-build-benchmarks
873-
skip-build-playgroundsupport
874872

875873
reconfigure
876874

@@ -1174,7 +1172,6 @@ lldb-build-type=Release
11741172
verbose-build
11751173
build-ninja
11761174
build-swift-stdlib-unittest-extra
1177-
playgroundsupport-build-type=Release
11781175

11791176
install-swift
11801177
install-lldb

utils/build-script

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def validate_arguments(toolchain, args):
220220

221221
targets_needing_toolchain = [
222222
'build_indexstoredb',
223+
'build_playgroundsupport',
223224
'build_pythonkit',
224225
'build_sourcekitlsp',
225226
'build_toolchainbenchmarks',
@@ -548,8 +549,6 @@ class BuildScriptInvocation(object):
548549
impl_args += ["--skip-build-libdispatch"]
549550
if not args.build_libicu:
550551
impl_args += ["--skip-build-libicu"]
551-
if not args.build_playgroundsupport:
552-
impl_args += ["--skip-build-playgroundsupport"]
553552
if args.build_swift_dynamic_stdlib:
554553
impl_args += ["--build-swift-dynamic-stdlib"]
555554
if args.build_swift_static_stdlib:
@@ -589,14 +588,15 @@ class BuildScriptInvocation(object):
589588
if not args.test and not args.long_test and not args.stress_test:
590589
impl_args += ["--skip-test-swift"]
591590
if not args.test:
592-
impl_args += ["--skip-test-cmark",
593-
"--skip-test-lldb",
594-
"--skip-test-llbuild",
595-
"--skip-test-xctest",
596-
"--skip-test-foundation",
597-
"--skip-test-libdispatch",
598-
"--skip-test-libicu",
599-
"--skip-test-playgroundsupport"]
591+
impl_args += [
592+
"--skip-test-cmark",
593+
"--skip-test-lldb",
594+
"--skip-test-llbuild",
595+
"--skip-test-xctest",
596+
"--skip-test-foundation",
597+
"--skip-test-libdispatch",
598+
"--skip-test-libicu",
599+
]
600600
if not args.test_linux:
601601
impl_args += ["--skip-test-linux"]
602602
if not args.test_freebsd:
@@ -819,6 +819,8 @@ class BuildScriptInvocation(object):
819819
product_classes.append(products.SwiftEvolve)
820820
if self.args.build_indexstoredb:
821821
product_classes.append(products.IndexStoreDB)
822+
if self.args.build_playgroundsupport:
823+
product_classes.append(products.PlaygroundSupport)
822824
if self.args.build_pythonkit:
823825
product_classes.append(products.PythonKit)
824826
if self.args.build_sourcekitlsp:

utils/build-script-impl

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ components=(
253253
llbuild
254254
lldb
255255
llvm
256-
playgroundsupport
257256
static-foundation
258257
static-libdispatch
259258
swift
@@ -1036,12 +1035,6 @@ LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
10361035
LIBDISPATCH_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
10371036
LIBICU_SOURCE_DIR="${WORKSPACE}/icu"
10381037
LIBCXX_SOURCE_DIR="${WORKSPACE}/llvm-project/libcxx"
1039-
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support"
1040-
1041-
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR} ]]; then
1042-
echo "Couldn't find PlaygroundSupport source directory."
1043-
exit 1
1044-
fi
10451038

10461039
[[ "${SKIP_BUILD_CMARK}" ]] || PRODUCTS+=(cmark)
10471040
[[ "${SKIP_BUILD_LIBCXX}" ]] || PRODUCTS+=(libcxx)
@@ -1057,7 +1050,6 @@ fi
10571050
[[ "${SKIP_BUILD_STATIC_FOUNDATION}" ]] || PRODUCTS+=(foundation_static)
10581051
[[ "${SKIP_BUILD_LLBUILD}" ]] || PRODUCTS+=(llbuild)
10591052
[[ "${SKIP_BUILD_XCTEST}" ]] || PRODUCTS+=(xctest)
1060-
[[ "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] || PRODUCTS+=(playgroundsupport)
10611053

10621054
# get_host_specific_variable(host, name)
10631055
#
@@ -2114,38 +2106,6 @@ for host in "${ALL_HOSTS[@]}"; do
21142106
# libicu builds itself and doesn't use cmake
21152107
continue
21162108
;;
2117-
playgroundsupport)
2118-
if [[ "$(uname -s)" != "Darwin" ]]; then
2119-
echo "error: unable to build PlaygroundLogger and PlaygroundSupport on this platform"
2120-
exit 1
2121-
fi
2122-
2123-
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2124-
SWIFT_LIB_DIR="$(build_directory ${host} swift)"/lib/swift/
2125-
2126-
set -x
2127-
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2128-
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
2129-
call "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}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO
2130-
2131-
if [[ $(not ${SKIP_TEST_PLAYGROUNDSUPPORT}) ]]; then
2132-
# If we're going to end up testing PlaygroundLogger/PlaygroundSupport, then we need to build the tests too.
2133-
# Note that this *always* needs to run in Debug configuration.
2134-
call "xcodebuild" build-for-testing -configuration Debug -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-Test-PlaygroundLogger-macOS -sdk macosx -arch x86_64 -derivedDataPath "${build_dir}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO
2135-
fi
2136-
fi
2137-
2138-
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
2139-
call "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}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO
2140-
fi
2141-
2142-
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
2143-
call "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}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO
2144-
fi
2145-
popd
2146-
{ set +x; } 2>/dev/null
2147-
continue
2148-
;;
21492109
*)
21502110
echo "error: unknown product: ${product}"
21512111
exit 1
@@ -2528,26 +2488,6 @@ for host in "${ALL_HOSTS[@]}"; do
25282488
echo "--- Finished tests for ${product} ---"
25292489
continue
25302490
;;
2531-
playgroundsupport)
2532-
if [[ "${SKIP_TEST_PLAYGROUNDSUPPORT}" ]]; then
2533-
continue
2534-
fi
2535-
2536-
if [[ "${host}" != "macosx"* ]]; then
2537-
echo "Skipping PlaygroundLogger tests on non-macOS platform"
2538-
continue
2539-
fi
2540-
2541-
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
2542-
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2543-
SWIFT_LIB_DIR="$(build_directory ${host} swift)"/lib/swift/
2544-
2545-
set -x
2546-
with_pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}" \
2547-
call "xcodebuild" test-without-building -configuration Debug -workspace swift-xcode-playground-support.xcworkspace -scheme BuildScript-Test-PlaygroundLogger-macOS -sdk macosx -arch x86_64 -derivedDataPath "${PLAYGROUNDSUPPORT_BUILD_DIR}"/DerivedData SWIFT_EXEC="${SWIFTC_BIN}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO
2548-
{ set +x; } 2>/dev/null
2549-
continue
2550-
;;
25512491
*)
25522492
echo "error: unknown product: ${product}"
25532493
exit 1
@@ -2760,40 +2700,6 @@ for host in "${ALL_HOSTS[@]}"; do
27602700
call cp -a "${ICU_TMP_INSTALL_DIR}/share/icuswift" "${ICU_INSTALL_DIR}share"
27612701
continue
27622702
;;
2763-
playgroundsupport)
2764-
set -x
2765-
if [[ -z "${INSTALL_PLAYGROUNDSUPPORT}" ]] ; then
2766-
continue
2767-
fi
2768-
2769-
echo "--- Installing ${product} ---"
2770-
2771-
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
2772-
2773-
case "$(uname -s)" in
2774-
Darwin)
2775-
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2776-
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
2777-
call "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}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO DSTROOT="$(get_host_install_destdir ${host})" TOOLCHAIN_INSTALL_DIR="${TOOLCHAIN_PREFIX}" BUILD_PLAYGROUNDLOGGER_TESTS=NO
2778-
fi
2779-
2780-
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
2781-
call "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}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO DSTROOT="$(get_host_install_destdir ${host})" TOOLCHAIN_INSTALL_DIR="${TOOLCHAIN_PREFIX}" BUILD_PLAYGROUNDLOGGER_TESTS=NO
2782-
fi
2783-
2784-
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
2785-
call "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}" SWIFT_LIBRARY_PATH="${SWIFT_LIB_DIR}/\$(PLATFORM_NAME)" ONLY_ACTIVE_ARCH=NO DSTROOT="$(get_host_install_destdir ${host})" TOOLCHAIN_INSTALL_DIR="${TOOLCHAIN_PREFIX}" BUILD_PLAYGROUNDLOGGER_TESTS=NO
2786-
fi
2787-
popd
2788-
continue
2789-
;;
2790-
*)
2791-
echo "error: --install-playgroundsupport is not supported on this platform"
2792-
exit 1
2793-
;;
2794-
esac
2795-
{ set +x; } 2>/dev/null
2796-
;;
27972703
*)
27982704
echo "error: unknown product: ${product}"
27992705
exit 1

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,11 @@ def create_argument_parser():
596596
option('--libicu', toggle_true('build_libicu'),
597597
help='build libicu')
598598

599-
option('--playgroundsupport', store_true('build_playgroundsupport'),
599+
option('--playgroundsupport', toggle_true('build_playgroundsupport'),
600600
help='build PlaygroundSupport')
601+
option('--install-playgroundsupport',
602+
store_true('install_playgroundsupport'),
603+
help='install playground support')
601604

602605
option('--pythonkit', store_true('build_pythonkit'),
603606
help='build PythonKit')
@@ -981,6 +984,9 @@ def create_argument_parser():
981984
help='skip testing indexstore-db')
982985
option('--skip-test-sourcekit-lsp', toggle_false('test_sourcekitlsp'),
983986
help='skip testing sourcekit-lsp')
987+
option('--skip-test-playgroundsupport',
988+
toggle_false('test_playgroundsupport'),
989+
help='skip testing PlaygroundSupport')
984990
option('--skip-test-skstresstester', toggle_false('test_skstresstester'),
985991
help='skip testing the SourceKit Stress tester')
986992
option('--skip-test-swiftevolve', toggle_false('test_swiftevolve'),

utils/build_swift/tests/expected_options.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
'install_swiftpm': False,
9595
'install_swiftsyntax': False,
9696
'swiftsyntax_verify_generated_files': False,
97+
'install_playgroundsupport': False,
9798
'install_pythonkit': False,
9899
'install_sourcekitlsp': False,
99100
'install_skstresstester': False,
@@ -215,6 +216,7 @@
215216
'test_watchos': False,
216217
'test_watchos_host': False,
217218
'test_watchos_simulator': False,
219+
'test_playgroundsupport': True,
218220
'test_swiftpm': False,
219221
'test_swiftsyntax': False,
220222
'test_indexstoredb': False,
@@ -449,6 +451,8 @@ class BuildScriptImplOption(_BaseOption):
449451
SetTrueOption('--maccatalyst-ios-tests', dest='maccatalyst_ios_tests'),
450452
SetTrueOption('--playgroundsupport', dest='build_playgroundsupport'),
451453
SetTrueOption('--pythonkit', dest='build_pythonkit'),
454+
SetTrueOption('--install-playgroundsupport',
455+
dest='install_playgroundsupport'),
452456
SetTrueOption('--install-pythonkit', dest='install_pythonkit'),
453457
SetTrueOption('--test-pythonkit', dest='test_pythonkit'),
454458
SetTrueOption('--skip-build'),
@@ -554,6 +558,8 @@ class BuildScriptImplOption(_BaseOption):
554558
DisableOption('--skip-test-watchos-host', dest='test_watchos_host'),
555559
DisableOption('--skip-test-watchos-simulator',
556560
dest='test_watchos_simulator'),
561+
DisableOption('--skip-test-playgroundsupport',
562+
dest='test_playgroundsupport'),
557563
DisableOption('--skip-test-swiftpm', dest='test_swiftpm'),
558564
DisableOption('--skip-test-swiftsyntax', dest='test_swiftsyntax'),
559565
DisableOption('--skip-test-indexstore-db', dest='test_indexstoredb'),

utils/swift_build_support/swift_build_support/products/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .lldb import LLDB
2222
from .llvm import LLVM
2323
from .ninja import Ninja
24+
from .playgroundsupport import PlaygroundSupport
2425
from .pythonkit import PythonKit
2526
from .skstresstester import SKStressTester
2627
from .sourcekitlsp import SourceKitLSP
@@ -42,6 +43,7 @@
4243
'LLDB',
4344
'LLVM',
4445
'Ninja',
46+
'PlaygroundSupport',
4547
'PythonKit',
4648
'Swift',
4749
'SwiftPM',
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# swift_build_support/products/playgroundsupport.py -------------*- python -*-
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ----------------------------------------------------------------------------
12+
13+
import os
14+
import re
15+
16+
from . import product
17+
from .. import shell
18+
from .. import targets
19+
20+
21+
def get_os_spelling(os):
22+
return {
23+
'macosx': 'macOS',
24+
'iphonesimulator': 'iOS',
25+
'appletvsimulator': 'tvOS',
26+
}[os]
27+
28+
29+
class PlaygroundSupport(product.Product):
30+
@classmethod
31+
def product_source_name(cls):
32+
return "swift-xcode-playground-support"
33+
34+
@classmethod
35+
def is_build_script_impl_product(cls):
36+
return False
37+
38+
def should_build(self, host_target):
39+
return self.args.build_playgroundsupport
40+
41+
def build(self, host_target):
42+
root = os.path.dirname(os.path.dirname(self.toolchain.swiftc))
43+
swift_lib_dir = os.path.join(root, 'lib', 'swift')
44+
(host_os, host_arch) = host_target.split('-')
45+
46+
with shell.pushd(self.source_dir):
47+
shell.call([
48+
"xcodebuild",
49+
"-configuration", self.args.build_variant,
50+
"-workspace", "swift-xcode-playground-support.xcworkspace",
51+
"-scheme", "BuildScript-{}".format(get_os_spelling(host_os)),
52+
"-sdk", host_os,
53+
"-arch", host_arch,
54+
"-derivedDataPath", os.path.join(self.build_dir, "DerivedData"),
55+
"SWIFT_EXEC={}".format(self.toolchain.swiftc),
56+
"SWIFT_LIBRARY_PATH={}/$(PLATFORM_NAME)".format(swift_lib_dir),
57+
"ONLY_ACTIVE_ARCH=NO",
58+
])
59+
60+
def should_test(self, host_target):
61+
return re.match('macosx', host_target) and \
62+
self.args.test_playgroundsupport
63+
64+
def test(self, host_target):
65+
root = os.path.dirname(os.path.dirname(self.toolchain.swiftc))
66+
swift_lib_dir = os.path.join(root, 'lib', 'swift')
67+
(host_os, host_arch) = host_target.split('-')
68+
69+
with shell.pushd(self.source_dir):
70+
shell.call([
71+
"xcodebuild",
72+
"test",
73+
# NOTE: this *always* needs to run in Debug configuration
74+
"-configuration", "Debug",
75+
"-workspace", "swift-xcode-playground-support.xcworkspace",
76+
"-scheme", "BuildScript-Test-PlaygroundLogger-{}".format(
77+
get_os_spelling(host_os)),
78+
"-sdk", host_os,
79+
"-arch", host_arch,
80+
"-derivedDataPath", os.path.join(self.build_dir, "DerivedData"),
81+
"SWIFT_EXEC={}".format(self.toolchain.swiftc),
82+
"SWIFT_LIBRARY_PATH={}/$(PLATFORM_NAME)".format(swift_lib_dir),
83+
"ONLY_ACTIVE_ARCH=NO",
84+
])
85+
86+
def should_install(self, host_target):
87+
return self.args.install_playgroundsupport
88+
89+
def install(self, host_target):
90+
root = os.path.dirname(os.path.dirname(self.toolchain.swiftc))
91+
swift_lib_dir = os.path.join(root, 'lib', 'swift')
92+
(host_os, host_arch) = host_target.split('-')
93+
toolchain_prefix = \
94+
targets.darwin_toolchain_prefix(self.args.install_prefix)
95+
96+
with shell.pushd(self.source_dir):
97+
shell.call([
98+
"xcodebuild",
99+
"install",
100+
"-configuration", self.args.build_variant,
101+
"-workspace", "swift-xcode-playground-support.xcworkspace",
102+
"-scheme", "BuildScript-{}".format(get_os_spelling(host_os)),
103+
"-sdk", host_os,
104+
"-arch", host_arch,
105+
"-derivedDataPath", os.path.join(self.build_dir, "DerivedData"),
106+
"SWIFT_EXEC={}".format(self.toolchain.swiftc),
107+
"SWIFT_LIBRARY_PATH={}/$(PLATFORM_NAME)".format(swift_lib_dir),
108+
"ONLY_ACTIVE_ARCH=NO",
109+
"DSTROOT={}".format(self.args.install_destdir),
110+
"TOOLCHAIN_INSTALL_DIR={}".format(toolchain_prefix),
111+
"BUILD_PLAYGROUND_LOGGER_TESTS=NO",
112+
])

0 commit comments

Comments
 (0)