Skip to content

Commit 47261ab

Browse files
committed
WIP: Create a unified build for (swift-)foundation-tests
We can’t add the tests to the general unified build because they use testable imports and building a package with testable imports also re-builds all of its dependencies with testable imports (swiftlang/swift-package-manager#8344) and is thus incompatible with the other package’s unified build. But we should still be able to share build products between corelibs-foundation tests and swift-foundation-tests.
1 parent 33eab01 commit 47261ab

File tree

14 files changed

+44
-33
lines changed

14 files changed

+44
-33
lines changed

utils/build_swift/resources/SwiftPM-Unified-Build.xcworkspace/contents.xcworkspacedata

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

utils/swift_build_support/swift_build_support/build_script_invocation.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,8 @@ def _execute_action(self, action_name):
893893
def execute_product_build_steps(self, product_class, host_target):
894894
product_source = product_class.product_source_name()
895895
product_name = product_class.product_name()
896-
if product_class.is_swiftpm_unified_build_product():
897-
build_dir = self.workspace.swiftpm_unified_build_dir(
898-
host_target)
896+
if arena := product_class.swiftpm_unified_build_product_arena():
897+
build_dir = self.workspace.swiftpm_unified_build_dir(arena, host_target)
899898
else:
900899
build_dir = self.workspace.build_dir(
901900
host_target, product_name)

utils/swift_build_support/swift_build_support/products/foundationtests.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import os
1414

15+
from build_swift.build_swift.constants import MULTIROOT_DATA_FILE_PATH
16+
1517
from . import cmark
1618
from . import foundation
1719
from . import libcxx
@@ -35,6 +37,10 @@ def is_build_script_impl_product(cls):
3537
def is_before_build_script_impl_product(cls):
3638
return False
3739

40+
@classmethod
41+
def swiftpm_unified_build_product_arena(cls):
42+
return 'foundationtests'
43+
3844
@classmethod
3945
def is_ignore_install_all_product(cls):
4046
return True
@@ -74,7 +80,9 @@ def test(self, host_target):
7480
'--toolchain', self.install_toolchain_path(host_target),
7581
'--configuration', self.configuration(),
7682
'--scratch-path', self.build_dir,
77-
'--package-path', package_path
83+
'--package-path', package_path,
84+
'--test-product', 'swift-corelibs-foundationPackageTests',
85+
'--multiroot-data-file', MULTIROOT_DATA_FILE_PATH
7886
]
7987
if self.args.verbose_build:
8088
cmd.append('--verbose')

utils/swift_build_support/swift_build_support/products/indexstoredb.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def is_before_build_script_impl_product(cls):
4242
return False
4343

4444
@classmethod
45-
def is_swiftpm_unified_build_product(cls):
46-
return True
45+
def swiftpm_unified_build_product_arena(cls):
46+
return 'unified'
4747

4848
def should_build(self, host_target):
4949
return True

utils/swift_build_support/swift_build_support/products/product.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,16 @@ def is_ignore_install_all_product(cls):
8989
return False
9090

9191
@classmethod
92-
def is_swiftpm_unified_build_product(cls):
93-
"""is_swiftpm_unified_build_product -> bool
92+
def swiftpm_unified_build_product_arena(cls):
93+
"""swiftpm_unified_build_product_arena -> Optional[str]
9494
95-
Whether this product should be built in the unified build of SwiftPM
96-
products.
95+
If this product should be built in the unified build of SwiftPM
96+
products, a name that identifies the build directory for the unified
97+
build. This should be 'unified' or 'foundationtests'. Foundation and
98+
the rest can't share a unified build because of
99+
https://github.com/swiftlang/swift-package-manager/issues/8344
97100
"""
98-
return False
101+
return None
99102

100103
@classmethod
101104
def is_nondarwin_only_build_product(cls):

utils/swift_build_support/swift_build_support/products/skstresstester.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def is_before_build_script_impl_product(cls):
4747
return False
4848

4949
@classmethod
50-
def is_swiftpm_unified_build_product(cls):
51-
return True
50+
def swiftpm_unified_build_product_arena(cls):
51+
return 'unified'
5252

5353
def package_name(self):
5454
return 'SourceKitStressTester'

utils/swift_build_support/swift_build_support/products/sourcekitlsp.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def is_before_build_script_impl_product(cls):
4242
return False
4343

4444
@classmethod
45-
def is_swiftpm_unified_build_product(cls):
46-
return True
45+
def swiftpm_unified_build_product_arena(cls):
46+
return 'unified'
4747

4848
def should_build(self, host_target):
4949
return True

utils/swift_build_support/swift_build_support/products/stdlib_docs.py

-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ def is_build_script_impl_product(cls):
2727
def is_before_build_script_impl_product(cls):
2828
return False
2929

30-
@classmethod
31-
def is_swiftpm_unified_build_product(cls):
32-
return False
33-
3430
def should_build(self, host_target):
3531
return self.args.build_stdlib_docs
3632

utils/swift_build_support/swift_build_support/products/swiftdocc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def is_before_build_script_impl_product(cls):
4646
return False
4747

4848
@classmethod
49-
def is_swiftpm_unified_build_product(cls):
50-
return True
49+
def swiftpm_unified_build_product_arena(cls):
50+
return 'unified'
5151

5252
def run_build_script_helper(self, action, host_target, additional_params=[]):
5353
script_path = os.path.join(

utils/swift_build_support/swift_build_support/products/swiftdoccrender.py

-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ def is_build_script_impl_product(cls):
3434
def is_before_build_script_impl_product(cls):
3535
return False
3636

37-
@classmethod
38-
def is_swiftpm_unified_build_product(cls):
39-
return False
40-
4137
def should_build(self, host_target):
4238
# Swift-DocC-Render is a pre-built, installable artifact.
4339
return False

utils/swift_build_support/swift_build_support/products/swiftformat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def is_before_build_script_impl_product(cls):
4747
return False
4848

4949
@classmethod
50-
def is_swiftpm_unified_build_product(cls):
51-
return True
50+
def swiftpm_unified_build_product_arena(cls):
51+
return 'unified'
5252

5353
def configuration(self):
5454
return 'release' if self.is_release() else 'debug'

utils/swift_build_support/swift_build_support/products/swiftfoundationtests.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import os
1414

15+
from build_swift.build_swift.constants import MULTIROOT_DATA_FILE_PATH
16+
1517
from . import cmark
1618
from . import foundation
1719
from . import libcxx
@@ -35,6 +37,10 @@ def is_build_script_impl_product(cls):
3537
def is_before_build_script_impl_product(cls):
3638
return False
3739

40+
@classmethod
41+
def swiftpm_unified_build_product_arena(cls):
42+
return 'foundationtests'
43+
3844
@classmethod
3945
def is_ignore_install_all_product(cls):
4046
return True
@@ -69,7 +75,9 @@ def test(self, host_target):
6975
'--toolchain', self.install_toolchain_path(host_target),
7076
'--configuration', self.configuration(),
7177
'--scratch-path', self.build_dir,
72-
'--package-path', package_path
78+
'--package-path', package_path,
79+
'--test-product', 'swift-foundationPackageTests',
80+
'--multiroot-data-file', MULTIROOT_DATA_FILE_PATH
7381
]
7482
if self.args.verbose_build:
7583
cmd.append('--verbose')

utils/swift_build_support/swift_build_support/products/swiftsyntax.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def is_before_build_script_impl_product(cls):
4646
return False
4747

4848
@classmethod
49-
def is_swiftpm_unified_build_product(cls):
50-
return True
49+
def swiftpm_unified_build_product_arena(cls):
50+
return 'unified'
5151

5252
def run_swiftsyntax_build_script(self, target, command, additional_params=[]):
5353
script_path = os.path.join(self.source_dir, 'SwiftSyntaxDevUtils')

utils/swift_build_support/swift_build_support/workspace.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ def build_dir(self, deployment_target, product):
2929
return os.path.join(self.build_root,
3030
'%s-%s' % (product, deployment_target))
3131

32-
def swiftpm_unified_build_dir(self, deployment_target):
32+
def swiftpm_unified_build_dir(self, arena, deployment_target):
3333
""" swiftpm_unified_build_dir() -> str
3434
3535
Build directory that all SwiftPM unified build products share.
3636
"""
3737
return os.path.join(self.build_root,
38-
'unified-swiftpm-build-%s' %
39-
deployment_target)
38+
f'{arena}-swiftpm-build-{deployment_target}')
4039

4140

4241
def compute_build_subdir(args):

0 commit comments

Comments
 (0)