3131 import ProductPipelineListBuilder
3232from swift_build_support .swift_build_support .targets \
3333 import StdlibDeploymentTarget
34+ from swift_build_support .swift_build_support .utils import clear_log_time
3435from swift_build_support .swift_build_support .utils \
3536 import exit_rejecting_arguments
3637from swift_build_support .swift_build_support .utils import fatal_error
38+ from swift_build_support .swift_build_support .utils import log_time_in_scope
3739
3840
3941class BuildScriptInvocation (object ):
@@ -50,6 +52,8 @@ def __init__(self, toolchain, args):
5052
5153 self .build_libparser_only = args .build_libparser_only
5254
55+ clear_log_time ()
56+
5357 @property
5458 def install_all (self ):
5559 return self .args .install_all or self .args .infer_dependencies
@@ -790,10 +794,11 @@ def _execute_merged_host_lipo_core_action(self):
790794 self ._execute_action ("merged-hosts-lipo-core" )
791795
792796 def _execute_action (self , action_name ):
793- shell .call_without_sleeping (
794- [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
795- ["--only-execute" , action_name ],
796- env = self .impl_env , echo = self .args .verbose_build )
797+ with log_time_in_scope (action_name ):
798+ shell .call_without_sleeping (
799+ [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
800+ ["--only-execute" , action_name ],
801+ env = self .impl_env , echo = self .args .verbose_build )
797802
798803 def execute_product_build_steps (self , product_class , host_target ):
799804 product_source = product_class .product_source_name ()
@@ -810,14 +815,20 @@ def execute_product_build_steps(self, product_class, host_target):
810815 source_dir = self .workspace .source_dir (product_source ),
811816 build_dir = build_dir )
812817 if product .should_clean (host_target ):
813- print ("--- Cleaning %s ---" % product_name )
814- product .clean (host_target )
818+ log_message = "Cleaning %s" % product_name
819+ print ("--- {} ---" .format (log_message ))
820+ with log_time_in_scope (log_message ):
821+ product .clean (host_target )
815822 if product .should_build (host_target ):
816- print ("--- Building %s ---" % product_name )
817- product .build (host_target )
823+ log_message = "Building %s" % product_name
824+ print ("--- {} ---" .format (log_message ))
825+ with log_time_in_scope (log_message ):
826+ product .build (host_target )
818827 if product .should_test (host_target ):
819- print ("--- Running tests for %s ---" % product_name )
820- product .test (host_target )
828+ log_message = "Running tests for %s" % product_name
829+ print ("--- {} ---" .format (log_message ))
830+ with log_time_in_scope (log_message ):
831+ product .test (host_target )
821832 print ("--- Finished tests for %s ---" % product_name )
822833 # Install the product if it should be installed specifically, or
823834 # if it should be built and `install_all` is set to True.
@@ -827,5 +838,7 @@ def execute_product_build_steps(self, product_class, host_target):
827838 if product .should_install (host_target ) or \
828839 (self .install_all and product .should_build (host_target ) and
829840 not product .is_ignore_install_all_product ()):
830- print ("--- Installing %s ---" % product_name )
831- product .install (host_target )
841+ log_message = "Installing %s" % product_name
842+ print ("--- {} ---" .format (log_message ))
843+ with log_time_in_scope (log_message ):
844+ product .install (host_target )
0 commit comments