Skip to content

[build-script] Perform validation after defaults propagation #2961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class HostSpecificConfiguration(object):
deployment_platform.is_embedded and \
not deployment_platform.is_simulator:
if deployment_platform not in \
invocation.platforms_to_skip_test_host:
invocation.platforms_to_skip_test_host:
test_host_only = True
test = True
else:
Expand All @@ -142,7 +142,7 @@ class HostSpecificConfiguration(object):
# library, whereas the other targets can build a slightly
# smaller subset which is faster to build.
if args.build_swift_stdlib_unittest_extra or \
args.validation_test or args.long_test:
args.validation_test or args.long_test:
self.swift_stdlib_build_targets.append(
"swift-stdlib-" + name)
else:
Expand Down Expand Up @@ -395,6 +395,18 @@ class BuildScriptInvocation(object):
args.stdlib_deployment_targets.append(
StdlibDeploymentTarget.Android.armv7.name)

# Infer platform flags from manually-specified configure targets.
# This doesn't apply to Darwin platforms, as they are
# already configured. No building without the platform flag, though.

android_tgts = [tgt for tgt in args.stdlib_deployment_targets
if StdlibDeploymentTarget.Android.contains(tgt)]
if not args.android and len(android_tgts) > 0:
args.android = True
args.skip_build_android = True

# ---
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is there to fix a PEP error about too many blank lines. I assumed 2 lines were left blank to separate the initialiser from the massive block of parsing code above.


def __init__(self, toolchain, args):
self.toolchain = toolchain
self.args = args
Expand Down Expand Up @@ -1768,12 +1780,12 @@ details of the setups of other systems or automated environments.""")
if args.cmake is not None:
toolchain.cmake = args.cmake

# Validate the arguments.
BuildScriptInvocation.validate_arguments(toolchain, args)

# Preprocess the arguments to apply defaults.
BuildScriptInvocation.apply_default_arguments(toolchain, args)

# Validate the arguments.
BuildScriptInvocation.validate_arguments(toolchain, args)

# Create the build script invocation.
invocation = BuildScriptInvocation(toolchain, args)

Expand Down
10 changes: 10 additions & 0 deletions utils/swift_build_support/swift_build_support/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ def supports_benchmark(self):
# By default, we don't support benchmarks on most platforms.
return False

def contains(self, target_name):
"""
Returns True if the given target name belongs to a one of this
platform's targets.
"""
for target in self.targets:
if target.name == target_name:
return True
return False


class DarwinPlatform(Platform):
def __init__(self, name, archs, sdk_name=None, is_simulator=False):
Expand Down
15 changes: 15 additions & 0 deletions utils/swift_build_support/tests/test_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,20 @@ def test_is_not_none_on_this_platform(self):
self.assertIsNotNone(StdlibDeploymentTarget.host_target())


class PlatformTargetsTestCase(unittest.TestCase):
def test_platform_contains(self):
"""
Checks that Platform.contains(target_name)
matches all of its targets' names and rejects non-matching names.
"""
# Pick a few platforms with lots of targets
for platform in [StdlibDeploymentTarget.Linux,
StdlibDeploymentTarget.iOS,
StdlibDeploymentTarget.iOSSimulator]:
for target in platform.targets:
self.assertTrue(platform.contains(target.name))
self.assertFalse(platform.contains("fakeCPU-MSDOS"))
self.assertFalse(platform.contains("singleTransistor-fakeOS"))

if __name__ == '__main__':
unittest.main()