Skip to content

Commit 8d32ee3

Browse files
authored
Merge pull request #29443 from compnerd/unsupported-playground-support
build: migrate playground support to post-build artifact
2 parents d5cb71a + f4086d8 commit 8d32ee3

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
@@ -217,6 +217,7 @@ def validate_arguments(toolchain, args):
217217

218218
targets_needing_toolchain = [
219219
'build_indexstoredb',
220+
'build_playgroundsupport',
220221
'build_pythonkit',
221222
'build_sourcekitlsp',
222223
'build_toolchainbenchmarks',
@@ -545,8 +546,6 @@ class BuildScriptInvocation(object):
545546
impl_args += ["--skip-build-libdispatch"]
546547
if not args.build_libicu:
547548
impl_args += ["--skip-build-libicu"]
548-
if not args.build_playgroundsupport:
549-
impl_args += ["--skip-build-playgroundsupport"]
550549
if args.build_swift_dynamic_stdlib:
551550
impl_args += ["--build-swift-dynamic-stdlib"]
552551
if args.build_swift_static_stdlib:
@@ -586,14 +585,15 @@ class BuildScriptInvocation(object):
586585
if not args.test and not args.long_test and not args.stress_test:
587586
impl_args += ["--skip-test-swift"]
588587
if not args.test:
589-
impl_args += ["--skip-test-cmark",
590-
"--skip-test-lldb",
591-
"--skip-test-llbuild",
592-
"--skip-test-xctest",
593-
"--skip-test-foundation",
594-
"--skip-test-libdispatch",
595-
"--skip-test-libicu",
596-
"--skip-test-playgroundsupport"]
588+
impl_args += [
589+
"--skip-test-cmark",
590+
"--skip-test-lldb",
591+
"--skip-test-llbuild",
592+
"--skip-test-xctest",
593+
"--skip-test-foundation",
594+
"--skip-test-libdispatch",
595+
"--skip-test-libicu",
596+
]
597597
if not args.test_linux:
598598
impl_args += ["--skip-test-linux"]
599599
if not args.test_freebsd:
@@ -816,6 +816,8 @@ class BuildScriptInvocation(object):
816816
product_classes.append(products.SwiftEvolve)
817817
if self.args.build_indexstoredb:
818818
product_classes.append(products.IndexStoreDB)
819+
if self.args.build_playgroundsupport:
820+
product_classes.append(products.PlaygroundSupport)
819821
if self.args.build_pythonkit:
820822
product_classes.append(products.PythonKit)
821823
if self.args.build_sourcekitlsp:

utils/build-script-impl

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ components=(
254254
llbuild
255255
lldb
256256
llvm
257-
playgroundsupport
258257
static-foundation
259258
static-libdispatch
260259
swift
@@ -1041,12 +1040,6 @@ LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
10411040
LIBDISPATCH_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
10421041
LIBICU_SOURCE_DIR="${WORKSPACE}/icu"
10431042
LIBCXX_SOURCE_DIR="${WORKSPACE}/llvm-project/libcxx"
1044-
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support"
1045-
1046-
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR} ]]; then
1047-
echo "Couldn't find PlaygroundSupport source directory."
1048-
exit 1
1049-
fi
10501043

10511044
[[ "${SKIP_BUILD_CMARK}" ]] || PRODUCTS+=(cmark)
10521045
[[ "${SKIP_BUILD_LIBCXX}" ]] || PRODUCTS+=(libcxx)
@@ -1062,7 +1055,6 @@ fi
10621055
[[ "${SKIP_BUILD_STATIC_FOUNDATION}" ]] || PRODUCTS+=(foundation_static)
10631056
[[ "${SKIP_BUILD_LLBUILD}" ]] || PRODUCTS+=(llbuild)
10641057
[[ "${SKIP_BUILD_XCTEST}" ]] || PRODUCTS+=(xctest)
1065-
[[ "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] || PRODUCTS+=(playgroundsupport)
10661058

10671059
# get_host_specific_variable(host, name)
10681060
#
@@ -2124,38 +2116,6 @@ for host in "${ALL_HOSTS[@]}"; do
21242116
# libicu builds itself and doesn't use cmake
21252117
continue
21262118
;;
2127-
playgroundsupport)
2128-
if [[ "$(uname -s)" != "Darwin" ]]; then
2129-
echo "error: unable to build PlaygroundLogger and PlaygroundSupport on this platform"
2130-
exit 1
2131-
fi
2132-
2133-
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2134-
SWIFT_LIB_DIR="$(build_directory ${host} swift)"/lib/swift/
2135-
2136-
set -x
2137-
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2138-
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
2139-
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
2140-
2141-
if [[ $(not ${SKIP_TEST_PLAYGROUNDSUPPORT}) ]]; then
2142-
# If we're going to end up testing PlaygroundLogger/PlaygroundSupport, then we need to build the tests too.
2143-
# Note that this *always* needs to run in Debug configuration.
2144-
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
2145-
fi
2146-
fi
2147-
2148-
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
2149-
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
2150-
fi
2151-
2152-
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
2153-
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
2154-
fi
2155-
popd
2156-
{ set +x; } 2>/dev/null
2157-
continue
2158-
;;
21592119
*)
21602120
echo "error: unknown product: ${product}"
21612121
exit 1
@@ -2538,26 +2498,6 @@ for host in "${ALL_HOSTS[@]}"; do
25382498
echo "--- Finished tests for ${product} ---"
25392499
continue
25402500
;;
2541-
playgroundsupport)
2542-
if [[ "${SKIP_TEST_PLAYGROUNDSUPPORT}" ]]; then
2543-
continue
2544-
fi
2545-
2546-
if [[ "${host}" != "macosx"* ]]; then
2547-
echo "Skipping PlaygroundLogger tests on non-macOS platform"
2548-
continue
2549-
fi
2550-
2551-
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
2552-
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"
2553-
SWIFT_LIB_DIR="$(build_directory ${host} swift)"/lib/swift/
2554-
2555-
set -x
2556-
with_pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}" \
2557-
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
2558-
{ set +x; } 2>/dev/null
2559-
continue
2560-
;;
25612501
*)
25622502
echo "error: unknown product: ${product}"
25632503
exit 1
@@ -2770,40 +2710,6 @@ for host in "${ALL_HOSTS[@]}"; do
27702710
call cp -a "${ICU_TMP_INSTALL_DIR}/share/icuswift" "${ICU_INSTALL_DIR}share"
27712711
continue
27722712
;;
2773-
playgroundsupport)
2774-
set -x
2775-
if [[ -z "${INSTALL_PLAYGROUNDSUPPORT}" ]] ; then
2776-
continue
2777-
fi
2778-
2779-
echo "--- Installing ${product} ---"
2780-
2781-
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
2782-
2783-
case "$(uname -s)" in
2784-
Darwin)
2785-
pushd "${PLAYGROUNDSUPPORT_SOURCE_DIR}"
2786-
if [[ $(not ${SKIP_BUILD_OSX}) ]]; then
2787-
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
2788-
fi
2789-
2790-
if [[ $(not ${SKIP_BUILD_IOS_SIMULATOR}) ]]; then
2791-
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
2792-
fi
2793-
2794-
if [[ $(not ${SKIP_BUILD_TVOS_SIMULATOR}) ]]; then
2795-
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
2796-
fi
2797-
popd
2798-
continue
2799-
;;
2800-
*)
2801-
echo "error: --install-playgroundsupport is not supported on this platform"
2802-
exit 1
2803-
;;
2804-
esac
2805-
{ set +x; } 2>/dev/null
2806-
;;
28072713
*)
28082714
echo "error: unknown product: ${product}"
28092715
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)