Skip to content

Commit 97e85a6

Browse files
stmontgomeryrintaro
authored andcommitted
Build script changes to begin building and installing swift-testing into toolchains (on Darwin, so far)
1 parent 19910c6 commit 97e85a6

File tree

7 files changed

+83
-1
lines changed

7 files changed

+83
-1
lines changed

utils/build-presets.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ swift-driver
13191319
# Failing to build in CI: rdar://78408440
13201320
# swift-inspect
13211321
swiftsyntax
1322+
swift-testing
13221323
swiftformat
13231324
playgroundsupport
13241325
indexstore-db
@@ -1363,6 +1364,7 @@ install-llbuild
13631364
install-swiftpm
13641365
install-swift-driver
13651366
install-swiftsyntax
1367+
install-swift-testing
13661368
install-playgroundsupport
13671369
install-sourcekit-lsp
13681370
install-swiftformat

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,11 @@ def create_argument_parser():
809809
option(['--wasmkit'], toggle_true('build_wasmkit'),
810810
help='build WasmKit')
811811

812+
option('--swift-testing', toggle_true('build_swift_testing'),
813+
help='build swift-testing')
814+
option('--install-swift-testing', toggle_true('install_swift_testing'),
815+
help='install swift-testing')
816+
812817
option('--xctest', toggle_true('build_xctest'),
813818
help='build xctest')
814819

utils/build_swift/tests/expected_options.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
'build_swiftpm': False,
9696
'build_swift_driver': False,
9797
'build_swift_libexec': True,
98+
'build_swift_testing': False,
9899
'build_early_swift_driver': True,
99100
'build_early_swiftsyntax': True,
100101
'build_swiftsyntax': False,
@@ -111,6 +112,7 @@
111112
'install_static_linux_config': False,
112113
'install_swiftpm': False,
113114
'install_swiftsyntax': False,
115+
'install_swift_testing': False,
114116
'install_swift_driver': False,
115117
'install_swiftdocc': False,
116118
'swiftsyntax_verify_generated_files': False,
@@ -566,6 +568,7 @@ class BuildScriptImplOption(_BaseOption):
566568
SetTrueOption('--swiftpm', dest='build_swiftpm'),
567569
SetTrueOption('--swift-driver', dest='build_swift_driver'),
568570
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
571+
SetTrueOption('--swift-testing', dest='build_swift_testing'),
569572
SetTrueOption('--skstresstester', dest='build_skstresstester'),
570573
SetTrueOption('--swiftformat', dest='build_swiftformat'),
571574
SetTrueOption('--swiftdocc', dest='build_swiftdocc'),
@@ -646,6 +649,7 @@ class BuildScriptImplOption(_BaseOption):
646649
EnableOption('--install-llvm', dest='install_llvm'),
647650
EnableOption('--install-static-linux-config', dest='install_static_linux_config'),
648651
EnableOption('--install-swiftsyntax', dest='install_swiftsyntax'),
652+
EnableOption('--install-swift-testing', dest='install_swift_testing'),
649653
EnableOption('--swiftsyntax-verify-generated-files',
650654
dest='swiftsyntax_verify_generated_files'),
651655
EnableOption('--swiftsyntax-enable-rawsyntax-validation',

utils/swift_build_support/swift_build_support/build_script_invocation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ def compute_product_pipelines(self):
678678
is_enabled=self.args.build_foundation)
679679
builder.add_product(products.SwiftSyntax,
680680
is_enabled=self.args.build_swiftsyntax)
681+
builder.add_product(products.SwiftTesting,
682+
is_enabled=self.args.build_swift_testing)
681683
builder.add_product(products.SwiftFormat,
682684
is_enabled=self.args.build_swiftformat)
683685
builder.add_product(products.SKStressTester,

utils/swift_build_support/swift_build_support/productpipeline_list_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def add_product(self, product_cls, is_enabled):
101101
self.current_pipeline.append(product_cls, is_enabled)
102102

103103
def add_impl_product(self, product_cls, is_enabled):
104-
"""Add a non-impl product to the current pipeline begin constructed"""
104+
"""Add an impl product to the current pipeline begin constructed"""
105105
assert self.current_pipeline is not None
106106
assert self.is_current_pipeline_impl
107107
assert product_cls.is_build_script_impl_product()

utils/swift_build_support/swift_build_support/products/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .sourcekitlsp import SourceKitLSP
3131
from .staticswiftlinux import StaticSwiftLinuxConfig
3232
from .swift import Swift
33+
from .swift_testing import SwiftTesting
3334
from .swiftdocc import SwiftDocC
3435
from .swiftdoccrender import SwiftDocCRender
3536
from .swiftdriver import SwiftDriver
@@ -68,6 +69,7 @@
6869
'SwiftInspect',
6970
'SwiftPM',
7071
'SwiftDriver',
72+
'SwiftTesting',
7173
'EarlySwiftDriver',
7274
'XCTest',
7375
'SwiftSyntax',
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# swift_build_support/products/xctest.py -------------------------*- python -*-
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2024 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+
15+
from . import cmake_product
16+
from . import swift
17+
from . import swiftsyntax
18+
19+
class SwiftTesting(cmake_product.CMakeProduct):
20+
@classmethod
21+
def is_build_script_impl_product(cls):
22+
return False
23+
24+
@classmethod
25+
def is_before_build_script_impl_product(cls):
26+
return False
27+
28+
@classmethod
29+
def product_source_name(cls):
30+
return "swift-testing"
31+
32+
@classmethod
33+
def get_dependencies(cls):
34+
return [swift.Swift,
35+
swiftsyntax.SwiftSyntax]
36+
37+
def should_build(self, host_target):
38+
return True
39+
40+
def build(self, host_target):
41+
self.cmake_options.define('BUILD_SHARED_LIBS', 'YES')
42+
43+
# Use empty CMake install prefix, since the `DESTDIR` env var is set by
44+
# `install_with_cmake` later which already has the same prefix.
45+
self.cmake_options.define('CMAKE_INSTALL_PREFIX', '')
46+
47+
build_root = os.path.dirname(self.build_dir)
48+
swift_build_dir = os.path.join(
49+
'..', build_root, '%s-%s' % ('swift', host_target))
50+
swift_cmake_dir = os.path.join(swift_build_dir, 'cmake', 'modules')
51+
self.cmake_options.define('SwiftSyntax_DIR:PATH', swift_cmake_dir)
52+
53+
self.build_with_cmake([], self.args.build_variant, [],
54+
prefer_native_toolchain=True)
55+
56+
def should_test(self, host_target):
57+
# TODO
58+
return False
59+
60+
def should_install(self, host_target):
61+
return self.args.install_swift_testing
62+
63+
def install(self, host_target):
64+
install_destdir = self.host_install_destdir(host_target)
65+
install_prefix = install_destdir + self.args.install_prefix
66+
67+
self.install_with_cmake(['install'], install_prefix)

0 commit comments

Comments
 (0)