Skip to content

Commit d913fc6

Browse files
committed
[Build Script] Pass down a CMake path to swift-driver's build script
1 parent 5dc969f commit d913fc6

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

utils/swift_build_support/swift_build_support/products/swiftdriver.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@
1010
#
1111
# ----------------------------------------------------------------------------
1212

13+
import os
14+
1315
from . import cmark
1416
from . import foundation
15-
from . import indexstoredb
1617
from . import libcxx
1718
from . import libdispatch
1819
from . import libicu
1920
from . import llbuild
2021
from . import llvm
2122
from . import product
2223
from . import swift
24+
from . import swiftpm
2325
from . import xctest
26+
from .. import shell
27+
from .. import targets
2428

2529

2630
class SwiftDriver(product.Product):
@@ -51,24 +55,48 @@ def should_clean(self, host_target):
5155
return self.args.clean_swift_driver
5256

5357
def clean(self, host_target):
54-
indexstoredb.run_build_script_helper(
55-
'clean', host_target, self, self.args)
58+
run_build_script_helper('clean', host_target, self, self.args)
5659

5760
def build(self, host_target):
58-
indexstoredb.run_build_script_helper(
59-
'build', host_target, self, self.args)
61+
run_build_script_helper('build', host_target, self, self.args)
6062

6163
def should_test(self, host_target):
6264
return self.args.test_swift_driver
6365

6466
def test(self, host_target):
65-
indexstoredb.run_build_script_helper(
66-
'test', host_target, self, self.args,
67-
self.args.test_sourcekitlsp_sanitize_all)
67+
run_build_script_helper('test', host_target, self, self.args)
6868

6969
def should_install(self, host_target):
7070
return self.args.install_swift_driver
7171

7272
def install(self, host_target):
73-
indexstoredb.run_build_script_helper(
74-
'install', host_target, self, self.args)
73+
run_build_script_helper('install', host_target, self, self.args)
74+
75+
76+
def run_build_script_helper(action, host_target, product, args):
77+
script_path = os.path.join(
78+
product.source_dir, 'Utilities', 'build-script-helper.py')
79+
80+
install_destdir = args.install_destdir
81+
if swiftpm.SwiftPM.has_cross_compile_hosts(args):
82+
install_destdir = swiftpm.SwiftPM.get_install_destdir(args,
83+
host_target,
84+
product.build_dir)
85+
toolchain_path = targets.toolchain_path(install_destdir,
86+
args.install_prefix)
87+
is_release = product.is_release()
88+
configuration = 'release' if is_release else 'debug'
89+
helper_cmd = [
90+
script_path,
91+
action,
92+
'--package-path', product.source_dir,
93+
'--build-path', product.build_dir,
94+
'--configuration', configuration,
95+
'--toolchain', toolchain_path,
96+
'--ninja-bin', product.toolchain.ninja,
97+
'--cmake-bin', product.toolchain.cmake,
98+
]
99+
if args.verbose_build:
100+
helper_cmd.append('--verbose')
101+
102+
shell.call(helper_cmd)

0 commit comments

Comments
 (0)