-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
Merged
ddunbar
merged 5 commits into
swiftlang:master
from
ddunbar:eliminate-SwiftBuildSupport-subprocess-functions
Jun 2, 2016
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c74a9d
[utils] Add swift_build_support.shell option to control command print…
ddunbar 87a1700
[utils] Switch some random scripts to `shell.call`.
ddunbar 3d06dee
[utils] Inline `caffeinate` logic into sole client.
ddunbar e8b121b
[util] Add `swift_build_support.shell.capture`.
ddunbar ad1540f
[utils] Switch random scripts to `shell.capture`.
ddunbar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
|
||
import os | ||
import platform | ||
import subprocess | ||
import sys | ||
import tempfile | ||
import unittest | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,6 @@ sys.path.append(os.path.dirname(__file__)) | |
|
||
from SwiftBuildSupport import ( | ||
SWIFT_SOURCE_ROOT, | ||
check_call, | ||
check_output, | ||
) # noqa (E402 module level import not at top of file) | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), 'swift_build_support')) | ||
|
@@ -94,21 +92,23 @@ def update_working_copy(repo_path, branch): | |
return | ||
|
||
print("--- Updating '" + repo_path + "' ---") | ||
with shell.pushd(repo_path, dry_run=False): | ||
with shell.pushd(repo_path, dry_run=False, print_command=False): | ||
if branch: | ||
status = check_output(['git', 'status', '--porcelain']) | ||
status = shell.capture(['git', 'status', '--porcelain'], | ||
print_command=False) | ||
if status: | ||
print("Please, commit your changes.") | ||
print(status) | ||
exit(1) | ||
check_call(['git', 'checkout', branch]) | ||
shell.call(['git', 'checkout', branch], print_command=False) | ||
|
||
# Prior to Git 2.6, this is the way to do a "git pull | ||
# --rebase" that respects rebase.autostash. See | ||
# http://stackoverflow.com/a/30209750/125349 | ||
check_call(["git", "fetch"]) | ||
check_call(["git", "rebase", "FETCH_HEAD"]) | ||
check_call(["git", "submodule", "update", "--recursive"]) | ||
shell.call(["git", "fetch"], print_command=False) | ||
shell.call(["git", "rebase", "FETCH_HEAD"], print_command=False) | ||
shell.call(["git", "submodule", "update", "--recursive"], | ||
print_command=False) | ||
|
||
|
||
def obtain_additional_swift_sources( | ||
|
@@ -117,19 +117,20 @@ def obtain_additional_swift_sources( | |
if dir_name in skip_repositories: | ||
print("--- Skipping '" + dir_name + "' ---") | ||
continue | ||
with shell.pushd(SWIFT_SOURCE_ROOT, dry_run=False): | ||
with shell.pushd(SWIFT_SOURCE_ROOT, dry_run=False, | ||
print_command=False): | ||
if not os.path.isdir(os.path.join(dir_name, ".git")): | ||
print("--- Cloning '" + dir_name + "' ---") | ||
if with_ssh is True: | ||
remote = "[email protected]:" + repo + '.git' | ||
else: | ||
remote = "https://github.com/" + repo + '.git' | ||
if skip_history: | ||
check_call(['git', 'clone', '--recursive', '--depth', '1', | ||
remote, dir_name]) | ||
shell.call(['git', 'clone', '--recursive', '--depth', '1', | ||
remote, dir_name], print_command=False) | ||
else: | ||
check_call(['git', 'clone', '--recursive', remote, | ||
dir_name]) | ||
shell.call(['git', 'clone', '--recursive', remote, | ||
dir_name], print_command=False) | ||
if branch: | ||
if branch == "master" or branch == "stable": | ||
repo_branch = MASTER_BRANCHES[dir_name] | ||
|
@@ -142,9 +143,9 @@ def obtain_additional_swift_sources( | |
repo_branch = branch | ||
src_path = SWIFT_SOURCE_ROOT + "/" + dir_name + "/" + \ | ||
".git" | ||
check_call(['git', '--git-dir', src_path, '--work-tree', | ||
shell.call(['git', '--git-dir', src_path, '--work-tree', | ||
os.path.join(SWIFT_SOURCE_ROOT, dir_name), | ||
'checkout', repo_branch]) | ||
'checkout', repo_branch], print_command=False) | ||
|
||
|
||
def main(): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
toecho
ortrace
? it's easier to type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean irrelevant? Or that the default should be different?
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 toecho
.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 beFalse
only forcapture
method.I know, it's inconsistent with other methods,
but we rarely want to "trace" side-effect less query command.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.