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 ):
@@ -771,13 +770,11 @@ def _execute_merged_host_lipo_core_action(self):
771
770
self ._execute_action ("merged-hosts-lipo-core" )
772
771
773
772
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 )
781
778
782
779
def execute_product_build_steps (self , product_class , host_target ):
783
780
product_source = product_class .product_source_name ()
@@ -796,24 +793,18 @@ def execute_product_build_steps(self, product_class, host_target):
796
793
if product .should_clean (host_target ):
797
794
log_message = "Cleaning %s" % product_name
798
795
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 )
803
798
if product .should_build (host_target ):
804
799
log_message = "Building %s" % product_name
805
800
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 )
810
803
if product .should_test (host_target ):
811
804
log_message = "Running tests for %s" % product_name
812
805
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 )
817
808
print ("--- Finished tests for %s ---" % product_name )
818
809
# Install the product if it should be installed specifically, or
819
810
# 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):
825
816
not product .is_ignore_install_all_product ()):
826
817
log_message = "Installing %s" % product_name
827
818
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