Skip to content

Commit 39c3f39

Browse files
committed
[build-script] Add function to compute toolchain path
1 parent 7be52d3 commit 39c3f39

File tree

7 files changed

+58
-30
lines changed

7 files changed

+58
-30
lines changed

utils/build-script

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,11 +790,11 @@ class BuildScriptInvocation(object):
790790
source_dir=self.workspace.source_dir(product_source),
791791
build_dir=self.workspace.build_dir(
792792
host_target, product_name))
793-
if product.shall_build(host_target):
793+
if product.should_build(host_target):
794794
product.build(host_target)
795-
if product.shall_test(host_target):
795+
if product.should_test(host_target):
796796
product.test(host_target)
797-
if product.shall_install(host_target):
797+
if product.should_install(host_target):
798798
product.install(host_target)
799799

800800
# Extract symbols...

utils/swift_build_support/swift_build_support/products/benchmarks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ def product_source_name(cls):
2828
def is_build_script_impl_product(cls):
2929
return False
3030

31-
def shall_build(self, host_target):
31+
def should_build(self, host_target):
3232
return True
3333

3434
def build(self, host_target):
3535
run_build_script_helper(host_target, self, self.args)
3636

37-
def shall_test(self, host_target):
37+
def should_test(self, host_target):
3838
return True
3939

4040
def test(self, host_target):
@@ -51,7 +51,7 @@ def test(self, host_target):
5151
bench_Osize = os.path.join(self.build_dir, 'bin', 'Benchmark_Osize')
5252
shell.call([bench_Osize] + cmdline)
5353

54-
def shall_install(self, host_target):
54+
def should_install(self, host_target):
5555
return False
5656

5757
def install(self, host_target):

utils/swift_build_support/swift_build_support/products/indexstoredb.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# ----------------------------------------------------------------------------
1212

1313
import os
14-
import platform
1514

1615
from . import product
1716
from .. import shell
@@ -27,19 +26,19 @@ def product_source_name(cls):
2726
def is_build_script_impl_product(cls):
2827
return False
2928

30-
def shall_build(self, host_target):
29+
def should_build(self, host_target):
3130
return True
3231

3332
def build(self, host_target):
3433
run_build_script_helper('build', host_target, self, self.args)
3534

36-
def shall_test(self, host_target):
35+
def should_test(self, host_target):
3736
return self.args.test_indexstoredb
3837

3938
def test(self, host_target):
4039
run_build_script_helper('test', host_target, self, self.args)
4140

42-
def shall_install(self, host_target):
41+
def should_install(self, host_target):
4342
return False
4443

4544
def install(self, host_target):
@@ -49,11 +48,10 @@ def install(self, host_target):
4948
def run_build_script_helper(action, host_target, product, args):
5049
script_path = os.path.join(
5150
product.source_dir, 'Utilities', 'build-script-helper.py')
52-
toolchain_path = args.install_destdir
53-
if platform.system() == 'Darwin':
54-
# The prefix is an absolute path, so concatenate without os.path.
55-
toolchain_path += \
56-
targets.darwin_toolchain_prefix(args.install_prefix)
51+
52+
toolchain_path = targets.toolchain_path(args.install_destdir,
53+
args.install_prefix)
54+
5755
configuration = 'debug' if args.build_variant == 'Debug' else 'release'
5856
helper_cmd = [
5957
script_path,

utils/swift_build_support/swift_build_support/products/product.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def is_build_script_impl_product(cls):
4242
"""
4343
return True
4444

45-
def shall_build(self, host_target):
46-
"""shall_build() -> Bool
45+
def should_build(self, host_target):
46+
"""should_build() -> Bool
4747
48-
Whether or not this product shall be built with the given arguments.
48+
Whether or not this product should be built with the given arguments.
4949
"""
5050
raise NotImplementedError
5151

@@ -56,10 +56,10 @@ def build(self, host_target):
5656
"""
5757
raise NotImplementedError
5858

59-
def shall_test(self, host_target):
60-
"""shall_test() -> Bool
59+
def should_test(self, host_target):
60+
"""should_test() -> Bool
6161
62-
Whether or not this product shall be tested with the given arguments.
62+
Whether or not this product should be tested with the given arguments.
6363
"""
6464
raise NotImplementedError
6565

@@ -70,10 +70,11 @@ def test(self, host_target):
7070
"""
7171
raise NotImplementedError
7272

73-
def shall_install(self, host_target):
74-
"""shall_install() -> Bool
73+
def should_install(self, host_target):
74+
"""should_install() -> Bool
7575
76-
Whether or not this product shall be installed with the given arguments
76+
Whether or not this product should be installed with the given
77+
arguments.
7778
"""
7879
raise NotImplementedError
7980

@@ -85,6 +86,19 @@ def install(self, host_target):
8586
raise NotImplementedError
8687

8788
def __init__(self, args, toolchain, source_dir, build_dir):
89+
"""
90+
Parameters
91+
----------
92+
args : `argparse.Namespace`
93+
The arguments passed by the user to the invocation of the script.
94+
toolchain : `swift_build_support.toolchain.Toolchain`
95+
The toolchain being used to build the product. The toolchain will
96+
point to the tools that the builder should use to build (like the
97+
compiler or the linker).
98+
build_dir: string
99+
The directory in which the product should put all of its build
100+
products.
101+
"""
88102
self.args = args
89103
self.toolchain = toolchain
90104
self.source_dir = source_dir

utils/swift_build_support/swift_build_support/products/sourcekitlsp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ def product_source_name(cls):
2323
def is_build_script_impl_product(cls):
2424
return False
2525

26-
def shall_build(self, host_target):
26+
def should_build(self, host_target):
2727
return True
2828

2929
def build(self, host_target):
3030
indexstoredb.run_build_script_helper(
3131
'build', host_target, self, self.args)
3232

33-
def shall_test(self, host_target):
33+
def should_test(self, host_target):
3434
return self.args.test_sourcekitlsp
3535

3636
def test(self, host_target):
3737
indexstoredb.run_build_script_helper(
3838
'test', host_target, self, self.args)
3939

40-
def shall_install(self, host_target):
40+
def should_install(self, host_target):
4141
return self.args.install_sourcekitlsp
4242

4343
def install(self, host_target):

utils/swift_build_support/swift_build_support/products/tsan_libdispatch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def product_source_name(cls):
2929
def is_build_script_impl_product(cls):
3030
return False
3131

32-
def shall_build(self, host_target):
32+
def should_build(self, host_target):
3333
return True
3434

3535
def build(self, host_target):
@@ -62,7 +62,7 @@ def build(self, host_target):
6262
shell.call(config_cmd)
6363
shell.call(build_cmd)
6464

65-
def shall_test(self, host_target):
65+
def should_test(self, host_target):
6666
return True
6767

6868
def test(self, host_target):
@@ -73,7 +73,7 @@ def test(self, host_target):
7373
with shell.pushd(self.build_dir):
7474
shell.call(cmd, env=env)
7575

76-
def shall_install(self, host_target):
76+
def should_install(self, host_target):
7777
return False
7878

7979
def install(self, host_target):

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,19 @@ def darwin_toolchain_prefix(darwin_install_prefix):
283283
directory.
284284
"""
285285
return os.path.split(darwin_install_prefix)[0]
286+
287+
288+
def toolchain_path(install_destdir, install_prefix):
289+
"""
290+
Given the install prefix for a Darwin system, and assuming that that path
291+
is to a .xctoolchain directory, return the path to the .xctoolchain
292+
directory in the given install directory.
293+
This toolchain is being populated during the build-script invocation.
294+
Downstream products can use products that were previously installed into
295+
this toolchain.
296+
"""
297+
built_toolchain_path = install_destdir
298+
if platform.system() == 'Darwin':
299+
# The prefix is an absolute path, so concatenate without os.path.
300+
built_toolchain_path += darwin_toolchain_prefix(install_prefix)
301+
return built_toolchain_path

0 commit comments

Comments
 (0)