Skip to content

Commit 9106543

Browse files
authored
Flush build step log messages in build_script_invocation.py (swiftlang#77324)
This ensures that log messages are printed as soon as a corresponding build step starts, instead of printing these messages in the end out of order. For example, before for SwiftPM ``` --- Cleaning swiftpm --- --- Building swiftpm --- --- Running tests for swiftpm --- --- Finished tests for swiftpm --- --- Installing swiftpm --- ``` was printed at the end of the CI job log with no actual build phase output in between these markers. Now these build phase markers are printed in the correct order and one can infer which log messages were printed for each build phase.
1 parent c9cb122 commit 9106543

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

utils/swift_build_support/swift_build_support/build_script_invocation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,20 +891,20 @@ def execute_product_build_steps(self, product_class, host_target):
891891
build_dir=build_dir)
892892
if product.should_clean(host_target):
893893
log_message = "Cleaning %s" % product_name
894-
print("--- {} ---".format(log_message))
894+
print("--- {} ---".format(log_message), flush=True)
895895
with log_time_in_scope(log_message):
896896
product.clean(host_target)
897897
if product.should_build(host_target):
898898
log_message = "Building %s" % product_name
899-
print("--- {} ---".format(log_message))
899+
print("--- {} ---".format(log_message), flush=True)
900900
with log_time_in_scope(log_message):
901901
product.build(host_target)
902902
if product.should_test(host_target):
903903
log_message = "Running tests for %s" % product_name
904-
print("--- {} ---".format(log_message))
904+
print("--- {} ---".format(log_message), flush=True)
905905
with log_time_in_scope(log_message):
906906
product.test(host_target)
907-
print("--- Finished tests for %s ---" % product_name)
907+
print("--- Finished tests for %s ---" % product_name, flush=True)
908908
# Install the product if it should be installed specifically, or
909909
# if it should be built and `install_all` is set to True.
910910
# The exception is select before_build_script_impl products
@@ -914,6 +914,6 @@ def execute_product_build_steps(self, product_class, host_target):
914914
(self.install_all and product.should_build(host_target) and
915915
not product.is_ignore_install_all_product()):
916916
log_message = "Installing %s" % product_name
917-
print("--- {} ---".format(log_message))
917+
print("--- {} ---".format(log_message), flush=True)
918918
with log_time_in_scope(log_message):
919919
product.install(host_target)

0 commit comments

Comments
 (0)