Skip to content

[build-script] Eliminate swift build support subprocess functions #2836

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

Conversation

ddunbar
Copy link
Contributor

@ddunbar ddunbar commented Jun 2, 2016

What's in this pull request?

This PR eliminates the subprocess-related functions in SwiftBuildSupport in favor of using the newer swift_build_support.shell module. It adds a print_command option to the functions in the shell module (to match the behavior of existing code), adds a swift_build_support.shell.capture function which is analogous to subprocess.check_output, and migrates clients to them.


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

ddunbar added 5 commits June 1, 2016 22:21
…ing.

 - This also uses the option in update-checkout to restores the previous, less
   verbose, output.
 - This eliminates the last client of `SwiftBuildSupport.check_call`, which is
   now replaced by `swift_build_support.shell.call`.

 - Part of SR-237.
 - This is an analog to `call`, which returns the captured output of the
   command.
 - This eliminates the last uses of `SwiftBuildSupport.check_output`.
@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 2, 2016

@swift-ci please Python lint

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 2, 2016

/cc @gribozavr

@swift-ci please test

@@ -80,40 +88,74 @@ def call(command, stderr=None, env=None, dry_run=None):
"': " + e.strerror)


def capture(command, stderr=None, env=None, dry_run=None, print_command=True):
Copy link
Member

Choose a reason for hiding this comment

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

For this method, print_command=False is relevant IMO.
BTW, Could you change print_command to echo or trace? it's easier to type.

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 this method, print_command=False is relevant IMO.

Did you mean irrelevant? Or that the default should be different?

BTW, Could you change print_command to echo or trace? it's easier to type.

I agree, I would prefer a shorter name too but I was preserving the existing name carried over from SwiftBuildSupport. If @gribozavr has no objections I will switch to echo.

Copy link
Member

@rintaro rintaro Jun 2, 2016

Choose a reason for hiding this comment

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

Sorry, the default for print_command should be False only for capture method.
I know, it's inconsistent with other methods,
but we rarely want to "trace" side-effect less query command.

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 agree that False makes more sense as a default, but didn't want the methods to be inconsistent. There is also an argument to be made that we generally shouldn't usually be shelling out to query things, and if we are it might be just as useful for logging purposes to see what commands contributed to the build script behavior.

As the module stands I think keeping the methods consistent at the cost of slightly more verbose clients is the right tradeoff.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for echo. (@echo off anyone?)

And I also agree that even though capture would not usually be echoed, consistency is important.

@gribozavr
Copy link
Contributor

LGTM. Please merge when you are ready.

@ddunbar ddunbar merged commit 76a3900 into swiftlang:master Jun 2, 2016
@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 2, 2016

Done, will rename the parameter in a follow on.

@ddunbar ddunbar deleted the eliminate-SwiftBuildSupport-subprocess-functions branch June 6, 2016 16:42
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