Skip to content

Commit 593d850

Browse files
authored
Merge pull request #2961 from karwa/validation-defaults
[build-script] Perform validation after defaults propagation
2 parents 323c797 + 02ad66d commit 593d850

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

utils/build-script

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class HostSpecificConfiguration(object):
130130
deployment_platform.is_embedded and \
131131
not deployment_platform.is_simulator:
132132
if deployment_platform not in \
133-
invocation.platforms_to_skip_test_host:
133+
invocation.platforms_to_skip_test_host:
134134
test_host_only = True
135135
test = True
136136
else:
@@ -142,7 +142,7 @@ class HostSpecificConfiguration(object):
142142
# library, whereas the other targets can build a slightly
143143
# smaller subset which is faster to build.
144144
if args.build_swift_stdlib_unittest_extra or \
145-
args.validation_test or args.long_test:
145+
args.validation_test or args.long_test:
146146
self.swift_stdlib_build_targets.append(
147147
"swift-stdlib-" + name)
148148
else:
@@ -395,6 +395,18 @@ class BuildScriptInvocation(object):
395395
args.stdlib_deployment_targets.append(
396396
StdlibDeploymentTarget.Android.armv7.name)
397397

398+
# Infer platform flags from manually-specified configure targets.
399+
# This doesn't apply to Darwin platforms, as they are
400+
# already configured. No building without the platform flag, though.
401+
402+
android_tgts = [tgt for tgt in args.stdlib_deployment_targets
403+
if StdlibDeploymentTarget.Android.contains(tgt)]
404+
if not args.android and len(android_tgts) > 0:
405+
args.android = True
406+
args.skip_build_android = True
407+
408+
# ---
409+
398410
def __init__(self, toolchain, args):
399411
self.toolchain = toolchain
400412
self.args = args
@@ -1771,12 +1783,12 @@ details of the setups of other systems or automated environments.""")
17711783
if args.cmake is not None:
17721784
toolchain.cmake = args.cmake
17731785

1774-
# Validate the arguments.
1775-
BuildScriptInvocation.validate_arguments(toolchain, args)
1776-
17771786
# Preprocess the arguments to apply defaults.
17781787
BuildScriptInvocation.apply_default_arguments(toolchain, args)
17791788

1789+
# Validate the arguments.
1790+
BuildScriptInvocation.validate_arguments(toolchain, args)
1791+
17801792
# Create the build script invocation.
17811793
invocation = BuildScriptInvocation(toolchain, args)
17821794

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ def supports_benchmark(self):
4242
# By default, we don't support benchmarks on most platforms.
4343
return False
4444

45+
def contains(self, target_name):
46+
"""
47+
Returns True if the given target name belongs to a one of this
48+
platform's targets.
49+
"""
50+
for target in self.targets:
51+
if target.name == target_name:
52+
return True
53+
return False
54+
4555

4656
class DarwinPlatform(Platform):
4757
def __init__(self, name, archs, sdk_name=None, is_simulator=False):

utils/swift_build_support/tests/test_targets.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,20 @@ def test_is_not_none_on_this_platform(self):
1818
self.assertIsNotNone(StdlibDeploymentTarget.host_target())
1919

2020

21+
class PlatformTargetsTestCase(unittest.TestCase):
22+
def test_platform_contains(self):
23+
"""
24+
Checks that Platform.contains(target_name)
25+
matches all of its targets' names and rejects non-matching names.
26+
"""
27+
# Pick a few platforms with lots of targets
28+
for platform in [StdlibDeploymentTarget.Linux,
29+
StdlibDeploymentTarget.iOS,
30+
StdlibDeploymentTarget.iOSSimulator]:
31+
for target in platform.targets:
32+
self.assertTrue(platform.contains(target.name))
33+
self.assertFalse(platform.contains("fakeCPU-MSDOS"))
34+
self.assertFalse(platform.contains("singleTransistor-fakeOS"))
35+
2136
if __name__ == '__main__':
2237
unittest.main()

0 commit comments

Comments
 (0)