Skip to content

[WIP] SR-237 Refactor build-script argument parsing logic into separate module #11827

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

Closed
wants to merge 5 commits into from

Conversation

Rostepher
Copy link
Contributor

@Rostepher Rostepher commented Sep 9, 2017

Purpose

This PR is part of my ongoing effort to refactor build-script and build-script-impl into a single script. Here I have re-used part of @rintaro's argparser_builder module from PR #2190 and then implemented a new argument parser for the main script mode.

This PR is still a WIP, I still want to add testing for the argparser_builder module and then integrate it with the main script. There's still some other groundwork to finish before that can be accomplished.

rdar://problem/34336890

@Rostepher
Copy link
Contributor Author

I'm going to add tests that parse in the preset file and ensure that all the presets still work under this new parser. If there's any conflicts I'll consider that a bug in the new implementation. In addition I have planned to manually get all the flags accepted by the current parser implementation and have a static test against that list to ensure all flags are supported.

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

Some quick comments.

# These options are not exposed as command line options on purpose. If you
# need to change any of these, you should do so on trunk or in a branch.

LLVM_TARGETS_TO_BUILD = 'X86;ARM;AArch64;PowerPC'
Copy link
Contributor

Choose a reason for hiding this comment

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

No. We want these to be configurable from the command line. For our smoke tests (where we only test X86), we only want to build the X86 LLVM target.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the purpose of this PR I don't think we should change this value. I don't want to change too much in a single PR. I copied this value from the previous default. It won't be too late to change it in a follow-up PR.

'Swift host tools, target Swift standard libraries, LLDB '
'(if enabled) (default)')

option(['-r', '--release-debug'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you keep this as --release-debuginfo. Otherwise, it is ambiguous against --debug.

option('--no-legacy-impl', disable('lecacy_impl'), default=True, nargs=0,
help='avoid legacy build-script-impl implementation')

option('--export-compile-commands', enable, default=False, nargs=0,
Copy link
Contributor

Choose a reason for hiding this comment

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

The default for this should be true. It is not expensive and can be useful for tooling purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the purpose of this PR I am hesitant to change any default values since I'm already replacing the whole argument parser. I'd rather hold off on reworking the defaults to be more sensible until we have this merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the default was to have this enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can double check as I make a cleanup pass over this again to make sure all the defaults are preserved (in combination with the new unit-tests).

with mutually_exclusive_group():
option('--debug-swift',
set_('swift_build_variant', const='Debug'),
help='build the Debug variant of Swift')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make it clear that this only makes the swift compiler, not the stdlib in debug?

help='CMake build variant for Swift')

with mutually_exclusive_group():
option('--debug-swift-stdlib',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make it clearer here that "the swift compiler" is not controlled by this option?


option('--stdlib-deployment-targets', append(separator=' '),
metavar='TARGET',
help='space-separated ist of targets to compile or cross-compile '
Copy link
Contributor

Choose a reason for hiding this comment

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

"ist" => "list"

option('--stdlib-deployment-targets', append(separator=' '),
metavar='TARGET',
help='space-separated ist of targets to compile or cross-compile '
'the Swift standard library for. %(default)s by default')
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats up with the format string here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The magical %(default)s format string inputs the default value when the argument parser outputs the help message.


with mutually_exclusive_group():
option('--build-llvm',
enable('build_llvm'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to double check (I didn't look), did you preserve the behavior where --skip-build-llvm builds enough of LLVM to compile Swift archives? (I think it tablegens some things and produces a few utilities, but thats it).

@gottesmm
Copy link
Contributor

I am going to do another pass over this after Ross pings me. He said he is going to make some other changes.

…ParserBuilder DSL based on Rintaro's work last year.
…s and fixed one failing test for stdlib-deployment-targets which I couldn't preserve the old behavior with 1:1.
@swiftlang swiftlang deleted a comment from swift-ci Oct 25, 2017
@swiftlang swiftlang deleted a comment from swift-ci Oct 25, 2017
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 5fb944c

@Rostepher
Copy link
Contributor Author

@swift-ci please test

@Rostepher
Copy link
Contributor Author

@swift-ci please smoke test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3d6883d

@Rostepher Rostepher removed the request for review from bob-wilson October 25, 2017 19:10
@Rostepher
Copy link
Contributor Author

@swift-ci please smoke test

@Rostepher
Copy link
Contributor Author

Closing in favor #12873 and a handful of follow-up PRs which should make reviews much easier.

@Rostepher Rostepher closed this Nov 15, 2017
@Rostepher Rostepher deleted the build-me-a-swift branch November 15, 2017 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants