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
38
37
from swift_build_support .swift_build_support .utils \
39
38
import exit_rejecting_arguments
40
39
from 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
42
41
43
42
44
43
class BuildScriptInvocation (object ):
@@ -769,13 +768,11 @@ def _execute_merged_host_lipo_core_action(self):
769
768
self ._execute_action ("merged-hosts-lipo-core" )
770
769
771
770
def _execute_action (self , action_name ):
772
- log_time ('start' , action_name )
773
- t_start = time .time ()
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 )
778
- log_time ('end' , action_name , time .time () - t_start )
771
+ with log_time_in_scope (action_name ):
772
+ shell .call_without_sleeping (
773
+ [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
774
+ ["--only-execute" , action_name ],
775
+ env = self .impl_env , echo = self .args .verbose_build )
779
776
780
777
def execute_product_build_steps (self , product_class , host_target ):
781
778
product_source = product_class .product_source_name ()
@@ -794,24 +791,18 @@ def execute_product_build_steps(self, product_class, host_target):
794
791
if product .should_clean (host_target ):
795
792
log_message = "Cleaning %s" % product_name
796
793
print ("--- {} ---" .format (log_message ))
797
- t_start = time .time ()
798
- log_time ('start' , log_message )
799
- product .clean (host_target )
800
- log_time ('end' , log_message , time .time () - t_start )
794
+ with log_time_in_scope (log_message ):
795
+ product .clean (host_target )
801
796
if product .should_build (host_target ):
802
797
log_message = "Building %s" % product_name
803
798
print ("--- {} ---" .format (log_message ))
804
- t_start = time .time ()
805
- log_time ('start' , log_message , '0' )
806
- product .build (host_target )
807
- log_time ('end' , log_message , time .time () - t_start )
799
+ with log_time_in_scope (log_message ):
800
+ product .build (host_target )
808
801
if product .should_test (host_target ):
809
802
log_message = "Running tests for %s" % product_name
810
803
print ("--- {} ---" .format (log_message ))
811
- t_start = time .time ()
812
- log_time ('start' , log_message )
813
- product .test (host_target )
814
- log_time ('end' , log_message , time .time () - t_start )
804
+ with log_time_in_scope (log_message ):
805
+ product .test (host_target )
815
806
print ("--- Finished tests for %s ---" % product_name )
816
807
# Install the product if it should be installed specifically, or
817
808
# if it should be built and `install_all` is set to True.
@@ -823,7 +814,5 @@ def execute_product_build_steps(self, product_class, host_target):
823
814
not product .is_ignore_install_all_product ()):
824
815
log_message = "Installing %s" % product_name
825
816
print ("--- {} ---" .format (log_message ))
826
- t_start = time .time ()
827
- log_time ('start' , log_message )
828
- product .install (host_target )
829
- log_time ('end' , log_message , time .time () - t_start )
817
+ with log_time_in_scope (log_message ):
818
+ product .install (host_target )
0 commit comments