1313import os
1414import pipes
1515import platform
16- import time
1716
1817from build_swift .build_swift import argparse
1918from build_swift .build_swift .constants import BUILD_SCRIPT_IMPL_PATH
3837from swift_build_support .swift_build_support .utils \
3938 import exit_rejecting_arguments
4039from swift_build_support .swift_build_support .utils import fatal_error
41- from swift_build_support .swift_build_support .utils import log_time
40+ from swift_build_support .swift_build_support .utils import log_time_in_scope
4241
4342
4443class BuildScriptInvocation (object ):
@@ -771,13 +770,11 @@ def _execute_merged_host_lipo_core_action(self):
771770 self ._execute_action ("merged-hosts-lipo-core" )
772771
773772 def _execute_action (self , action_name ):
774- log_time ('start' , action_name )
775- t_start = time .time ()
776- shell .call_without_sleeping (
777- [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
778- ["--only-execute" , action_name ],
779- env = self .impl_env , echo = self .args .verbose_build )
780- log_time ('end' , action_name , time .time () - t_start )
773+ with log_time_in_scope (action_name ):
774+ shell .call_without_sleeping (
775+ [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
776+ ["--only-execute" , action_name ],
777+ env = self .impl_env , echo = self .args .verbose_build )
781778
782779 def execute_product_build_steps (self , product_class , host_target ):
783780 product_source = product_class .product_source_name ()
@@ -796,24 +793,18 @@ def execute_product_build_steps(self, product_class, host_target):
796793 if product .should_clean (host_target ):
797794 log_message = "Cleaning %s" % product_name
798795 print ("--- {} ---" .format (log_message ))
799- t_start = time .time ()
800- log_time ('start' , log_message )
801- product .clean (host_target )
802- log_time ('end' , log_message , time .time () - t_start )
796+ with log_time_in_scope (log_message ):
797+ product .clean (host_target )
803798 if product .should_build (host_target ):
804799 log_message = "Building %s" % product_name
805800 print ("--- {} ---" .format (log_message ))
806- t_start = time .time ()
807- log_time ('start' , log_message , '0' )
808- product .build (host_target )
809- log_time ('end' , log_message , time .time () - t_start )
801+ with log_time_in_scope (log_message ):
802+ product .build (host_target )
810803 if product .should_test (host_target ):
811804 log_message = "Running tests for %s" % product_name
812805 print ("--- {} ---" .format (log_message ))
813- t_start = time .time ()
814- log_time ('start' , log_message )
815- product .test (host_target )
816- log_time ('end' , log_message , time .time () - t_start )
806+ with log_time_in_scope (log_message ):
807+ product .test (host_target )
817808 print ("--- Finished tests for %s ---" % product_name )
818809 # Install the product if it should be installed specifically, or
819810 # if it should be built and `install_all` is set to True.
@@ -825,7 +816,5 @@ def execute_product_build_steps(self, product_class, host_target):
825816 not product .is_ignore_install_all_product ()):
826817 log_message = "Installing %s" % product_name
827818 print ("--- {} ---" .format (log_message ))
828- t_start = time .time ()
829- log_time ('start' , log_message )
830- product .install (host_target )
831- log_time ('end' , log_message , time .time () - t_start )
819+ with log_time_in_scope (log_message ):
820+ product .install (host_target )
0 commit comments