13
13
import os
14
14
import pipes
15
15
import platform
16
- import time
17
16
18
17
from build_swift .build_swift import argparse
19
18
from build_swift .build_swift .constants import BUILD_SCRIPT_IMPL_PATH
36
35
from swift_build_support .swift_build_support .utils \
37
36
import exit_rejecting_arguments
38
37
from swift_build_support .swift_build_support .utils import fatal_error
39
- from swift_build_support .swift_build_support .utils import log_time
38
+ from swift_build_support .swift_build_support .utils import log_time_in_scope
40
39
41
40
42
41
class BuildScriptInvocation (object ):
@@ -781,13 +780,11 @@ def _execute_merged_host_lipo_core_action(self):
781
780
self ._execute_action ("merged-hosts-lipo-core" )
782
781
783
782
def _execute_action (self , action_name ):
784
- log_time ('start' , action_name )
785
- t_start = time .time ()
786
- shell .call_without_sleeping (
787
- [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
788
- ["--only-execute" , action_name ],
789
- env = self .impl_env , echo = self .args .verbose_build )
790
- log_time ('end' , action_name , time .time () - t_start )
783
+ with log_time_in_scope (action_name ):
784
+ shell .call_without_sleeping (
785
+ [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
786
+ ["--only-execute" , action_name ],
787
+ env = self .impl_env , echo = self .args .verbose_build )
791
788
792
789
def execute_product_build_steps (self , product_class , host_target ):
793
790
product_source = product_class .product_source_name ()
@@ -806,24 +803,18 @@ def execute_product_build_steps(self, product_class, host_target):
806
803
if product .should_clean (host_target ):
807
804
log_message = "Cleaning %s" % product_name
808
805
print ("--- {} ---" .format (log_message ))
809
- t_start = time .time ()
810
- log_time ('start' , log_message )
811
- product .clean (host_target )
812
- log_time ('end' , log_message , time .time () - t_start )
806
+ with log_time_in_scope (log_message ):
807
+ product .clean (host_target )
813
808
if product .should_build (host_target ):
814
809
log_message = "Building %s" % product_name
815
810
print ("--- {} ---" .format (log_message ))
816
- t_start = time .time ()
817
- log_time ('start' , log_message , '0' )
818
- product .build (host_target )
819
- log_time ('end' , log_message , time .time () - t_start )
811
+ with log_time_in_scope (log_message ):
812
+ product .build (host_target )
820
813
if product .should_test (host_target ):
821
814
log_message = "Running tests for %s" % product_name
822
815
print ("--- {} ---" .format (log_message ))
823
- t_start = time .time ()
824
- log_time ('start' , log_message )
825
- product .test (host_target )
826
- log_time ('end' , log_message , time .time () - t_start )
816
+ with log_time_in_scope (log_message ):
817
+ product .test (host_target )
827
818
print ("--- Finished tests for %s ---" % product_name )
828
819
# Install the product if it should be installed specifically, or
829
820
# if it should be built and `install_all` is set to True.
@@ -835,7 +826,5 @@ def execute_product_build_steps(self, product_class, host_target):
835
826
not product .is_ignore_install_all_product ()):
836
827
log_message = "Installing %s" % product_name
837
828
print ("--- {} ---" .format (log_message ))
838
- t_start = time .time ()
839
- log_time ('start' , log_message )
840
- product .install (host_target )
841
- log_time ('end' , log_message , time .time () - t_start )
829
+ with log_time_in_scope (log_message ):
830
+ product .install (host_target )
0 commit comments