Skip to content

Commit e74ebd5

Browse files
committed
[build-script] Flush immediately after print() in Python
1 parent 5ea4efb commit e74ebd5

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

utils/SwiftBuildSupport.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def _get_default_source_root():
6767

6868
def print_with_argv0(message):
6969
print(sys.argv[0] + ": " + message)
70+
sys.stdout.flush()
7071

7172

7273
def quote_shell_command(args):
@@ -82,6 +83,7 @@ def check_call(args, print_command=False, verbose=False, disable_sleep=False):
8283

8384
if print_command:
8485
print(os.getcwd() + "$ " + quote_shell_command(args))
86+
sys.stdout.flush()
8587
try:
8688
return subprocess.check_call(args)
8789
except subprocess.CalledProcessError as e:
@@ -101,6 +103,7 @@ def check_call(args, print_command=False, verbose=False, disable_sleep=False):
101103
def check_output(args, print_command=False, verbose=False):
102104
if print_command:
103105
print(os.getcwd() + "$ " + quote_shell_command(args))
106+
sys.stdout.flush()
104107
try:
105108
return subprocess.check_output(args)
106109
except subprocess.CalledProcessError as e:

utils/swift_build_support/swift_build_support/debug.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ def print_xcodebuild_versions(file=sys.stdout):
3737
print(u'--- SDK versions ---', file=file)
3838
print(u'{}\n'.format(_output(['xcodebuild', '-version', '-sdk'])),
3939
file=file)
40+
file.flush()
4041
# You can't test beyond this because each developer's machines may have
4142
# a different set of SDKs installed.

utils/swift_build_support/swift_build_support/shell.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ def _print_command(dry_run, command, env=None, prompt="+ "):
4141
if env is not None:
4242
output += ['env'] + [_quote("%s=%s" % (k, v)) for k, v in env]
4343
output += [_quote(arg) for arg in command]
44-
file = None
45-
if not dry_run:
46-
file = sys.stderr
44+
file = sys.stderr
45+
if dry_run:
46+
file = sys.stdout
4747
print(prompt + ' '.join(output), file=file)
48+
file.flush()
4849

4950

5051
def call(command, stderr=None, env=None, dry_run=None):

0 commit comments

Comments
 (0)