Skip to content

Commit ee41df0

Browse files
authored
Merge pull request #32474 from DougGregor/build-script-swift-driver
[build-script] Add support for building, installing, and testing swift-driver
2 parents b1050b5 + 26bb4ec commit ee41df0

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed

utils/build-script

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,8 @@ class BuildScriptInvocation(object):
862862
product_classes = []
863863
if self.args.build_swiftpm:
864864
product_classes.append(products.SwiftPM)
865+
if self.args.build_swift_driver:
866+
product_classes.append(products.SwiftDriver)
865867
if self.args.build_swiftsyntax:
866868
product_classes.append(products.SwiftSyntax)
867869
if self.args.build_skstresstester:

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def _apply_default_arguments(args):
184184
args.test_watchos = False
185185
args.test_android = False
186186
args.test_swiftpm = False
187+
args.test_swift_driver = False
187188
args.test_swiftsyntax = False
188189
args.test_indexstoredb = False
189190
args.test_sourcekitlsp = False
@@ -574,6 +575,9 @@ def create_argument_parser():
574575
option(['--swiftevolve'], store_true('build_swiftevolve'),
575576
help='build the swift-evolve tool')
576577

578+
option(['--swift-driver'], toggle_true('build_swift_driver'),
579+
help='build swift-driver')
580+
577581
option(['--indexstore-db'], toggle_true('build_indexstoredb'),
578582
help='build IndexStoreDB')
579583
option('--test-indexstore-db-sanitize-all',
@@ -596,6 +600,8 @@ def create_argument_parser():
596600
help='install SourceKitLSP')
597601
option(['--install-skstresstester'], toggle_true('install_skstresstester'),
598602
help='install the SourceKit stress tester')
603+
option(['--install-swift-driver'], toggle_true('install_swift_driver'),
604+
help='install new Swift driver')
599605
option(['--install-swiftevolve'], toggle_true('install_swiftevolve'),
600606
help='install SwiftEvolve')
601607
option(['--toolchain-benchmarks'],
@@ -1009,6 +1015,8 @@ def create_argument_parser():
10091015

10101016
option('--skip-test-swiftpm', toggle_false('test_swiftpm'),
10111017
help='skip testing swiftpm')
1018+
option('--skip-test-swift-driver', toggle_false('test_swift_driver'),
1019+
help='skip testing Swift driver')
10121020
option('--skip-test-swiftsyntax', toggle_false('test_swiftsyntax'),
10131021
help='skip testing SwiftSyntax')
10141022
option('--skip-test-indexstore-db', toggle_false('test_indexstoredb'),

utils/build_swift/tests/expected_options.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
'build_swift_static_stdlib': False,
9090
'build_swift_stdlib_unittest_extra': False,
9191
'build_swiftpm': False,
92+
'build_swift_driver': False,
9293
'build_swiftsyntax': False,
9394
'build_tensorflow_swift_apis': False,
9495
'build_libparser_only': False,
@@ -99,6 +100,7 @@
99100
'test_sourcekitlsp_sanitize_all': False,
100101
'build_sourcekitlsp': False,
101102
'install_swiftpm': False,
103+
'install_swift_driver': False,
102104
'install_swiftsyntax': False,
103105
'swiftsyntax_verify_generated_files': False,
104106
'install_playgroundsupport': False,
@@ -230,6 +232,7 @@
230232
'test_watchos_simulator': False,
231233
'test_playgroundsupport': True,
232234
'test_swiftpm': False,
235+
'test_swift_driver': False,
233236
'test_swiftsyntax': False,
234237
'test_indexstoredb': False,
235238
'test_sourcekitlsp': False,
@@ -473,6 +476,7 @@ class BuildScriptImplOption(_BaseOption):
473476
dest='install_tensorflow_swift_apis'),
474477
SetTrueOption('--skip-build'),
475478
SetTrueOption('--swiftpm', dest='build_swiftpm'),
479+
SetTrueOption('--swift-driver', dest='build_swift_driver'),
476480
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
477481
SetTrueOption('--build-libparser-only', dest='build_libparser_only'),
478482
SetTrueOption('--skstresstester', dest='build_skstresstester'),
@@ -523,6 +527,7 @@ class BuildScriptImplOption(_BaseOption):
523527
EnableOption('--swiftsyntax-verify-generated-files',
524528
dest='swiftsyntax_verify_generated_files'),
525529
EnableOption('--install-swiftpm', dest='install_swiftpm'),
530+
EnableOption('--install-swift-driver', dest='install_swift_driver'),
526531
EnableOption('--install-sourcekit-lsp', dest='install_sourcekitlsp'),
527532
EnableOption('--install-skstresstester', dest='install_skstresstester'),
528533
EnableOption('--install-swiftevolve', dest='install_swiftevolve'),
@@ -588,6 +593,7 @@ class BuildScriptImplOption(_BaseOption):
588593
DisableOption('--skip-test-playgroundsupport',
589594
dest='test_playgroundsupport'),
590595
DisableOption('--skip-test-swiftpm', dest='test_swiftpm'),
596+
DisableOption('--skip-test-swift-driver', dest='test_swift_driver'),
591597
DisableOption('--skip-test-swiftsyntax', dest='test_swiftsyntax'),
592598
DisableOption('--skip-test-indexstore-db', dest='test_indexstoredb'),
593599
DisableOption('--skip-test-sourcekit-lsp', dest='test_sourcekitlsp'),

utils/swift_build_support/swift_build_support/products/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .skstresstester import SKStressTester
2727
from .sourcekitlsp import SourceKitLSP
2828
from .swift import Swift
29+
from .swiftdriver import SwiftDriver
2930
from .swiftevolve import SwiftEvolve
3031
from .swiftinspect import SwiftInspect
3132
from .swiftpm import SwiftPM
@@ -50,6 +51,7 @@
5051
'Swift',
5152
'SwiftInspect',
5253
'SwiftPM',
54+
'SwiftDriver',
5355
'TensorFlowSwiftAPIs',
5456
'XCTest',
5557
'SwiftSyntax',
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# swift_build_support/products/swiftdriver.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+
from . import cmark
14+
from . import foundation
15+
from . import indexstoredb
16+
from . import libcxx
17+
from . import libdispatch
18+
from . import libicu
19+
from . import llbuild
20+
from . import llvm
21+
from . import product
22+
from . import swift
23+
from . import xctest
24+
25+
26+
class SwiftDriver(product.Product):
27+
@classmethod
28+
def product_source_name(cls):
29+
return "swift-driver"
30+
31+
@classmethod
32+
def is_build_script_impl_product(cls):
33+
return False
34+
35+
def should_build(self, host_target):
36+
return self.args.build_swift_driver
37+
38+
@classmethod
39+
def get_dependencies(cls):
40+
return [cmark.CMark,
41+
llvm.LLVM,
42+
libcxx.LibCXX,
43+
libicu.LibICU,
44+
swift.Swift,
45+
libdispatch.LibDispatch,
46+
foundation.Foundation,
47+
xctest.XCTest,
48+
llbuild.LLBuild]
49+
50+
def build(self, host_target):
51+
indexstoredb.run_build_script_helper(
52+
'build', host_target, self, self.args)
53+
54+
def should_test(self, host_target):
55+
return self.args.test_swift_driver
56+
57+
def test(self, host_target):
58+
indexstoredb.run_build_script_helper(
59+
'test', host_target, self, self.args,
60+
self.args.test_sourcekitlsp_sanitize_all)
61+
62+
def should_install(self, host_target):
63+
return self.args.install_swift_driver
64+
65+
def install(self, host_target):
66+
indexstoredb.run_build_script_helper(
67+
'install', host_target, self, self.args)

0 commit comments

Comments
 (0)