Skip to content

Commit bf9f0ec

Browse files
committed
[build-script] Add support for building, installing, and testing swift-driver
Add build-script command-line options for building, installing, and testing swift-driver: * `--swift-driver` will build the Swift driver. If testing is enabled, it will be tested as well * `--install-swift-driver` will install the `swift-driver` and `swift-help` executables in the toolchain. * `--skip-test-swift-driver` will disable testing of the Swift driver when other tests are being run. The Swift driver depends on SwiftPM to build; it is recommended that you use `--infer` to get the appropriate dependencies built. Note that this option does not yet replace the existing Swift driver executables (`swiftc`, `swift`) with the new driver, nor does it install the SwiftDriver library for use elsewhere.
1 parent 1b98ca3 commit bf9f0ec

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-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-swiftdriver', 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/swift_build_support/swift_build_support/products/__init__.py

Lines changed: 1 addition & 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
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
import os
14+
15+
from . import cmark
16+
from . import foundation
17+
from . import indexstoredb
18+
from . import libcxx
19+
from . import libdispatch
20+
from . import libicu
21+
from . import llbuild
22+
from . import llvm
23+
from . import product
24+
from . import swift
25+
from . import xctest
26+
27+
from .. import shell
28+
from .. import targets
29+
30+
class SwiftDriver(product.Product):
31+
@classmethod
32+
def product_source_name(cls):
33+
return "swift-driver"
34+
35+
@classmethod
36+
def is_build_script_impl_product(cls):
37+
return False
38+
39+
def should_build(self, host_target):
40+
return self.args.build_swift_driver
41+
42+
@classmethod
43+
def get_dependencies(cls):
44+
return [cmark.CMark,
45+
llvm.LLVM,
46+
libcxx.LibCXX,
47+
libicu.LibICU,
48+
swift.Swift,
49+
libdispatch.LibDispatch,
50+
foundation.Foundation,
51+
xctest.XCTest,
52+
llbuild.LLBuild]
53+
54+
def build(self, host_target):
55+
indexstoredb.run_build_script_helper(
56+
'build', host_target, self, self.args)
57+
58+
def should_test(self, host_target):
59+
return self.args.test_swift_driver
60+
61+
def test(self, host_target):
62+
indexstoredb.run_build_script_helper(
63+
'test', host_target, self, self.args,
64+
self.args.test_sourcekitlsp_sanitize_all)
65+
66+
def should_install(self, host_target):
67+
return self.args.install_swift_driver
68+
69+
def install(self, host_target):
70+
indexstoredb.run_build_script_helper(
71+
'install', host_target, self, self.args)
72+

0 commit comments

Comments
 (0)