1313import os
1414import pipes
1515import platform
16+ import time
1617
1718from build_swift .build_swift import argparse
1819from build_swift .build_swift .constants import BUILD_SCRIPT_IMPL_PATH
3334 import ProductPipelineListBuilder
3435from swift_build_support .swift_build_support .targets \
3536 import StdlibDeploymentTarget
37+ from swift_build_support .swift_build_support .utils import clear_log_time
3638from swift_build_support .swift_build_support .utils \
3739 import exit_rejecting_arguments
3840from swift_build_support .swift_build_support .utils import fatal_error
41+ from swift_build_support .swift_build_support .utils import log_time
3942
4043
4144class BuildScriptInvocation (object ):
@@ -52,6 +55,8 @@ def __init__(self, toolchain, args):
5255
5356 self .build_libparser_only = args .build_libparser_only
5457
58+ clear_log_time ()
59+
5560 @property
5661 def install_all (self ):
5762 return self .args .install_all or self .args .infer_dependencies
@@ -766,10 +771,13 @@ def _execute_merged_host_lipo_core_action(self):
766771 self ._execute_action ("merged-hosts-lipo-core" )
767772
768773 def _execute_action (self , action_name ):
774+ log_time ('start' , action_name )
775+ t_start = time .time ()
769776 shell .call_without_sleeping (
770777 [BUILD_SCRIPT_IMPL_PATH ] + self .impl_args +
771778 ["--only-execute" , action_name ],
772779 env = self .impl_env , echo = self .args .verbose_build )
780+ log_time ('end' , action_name , time .time () - t_start )
773781
774782 def execute_product_build_steps (self , product_class , host_target ):
775783 product_source = product_class .product_source_name ()
@@ -786,14 +794,26 @@ def execute_product_build_steps(self, product_class, host_target):
786794 source_dir = self .workspace .source_dir (product_source ),
787795 build_dir = build_dir )
788796 if product .should_clean (host_target ):
789- print ("--- Cleaning %s ---" % product_name )
797+ log_message = "Cleaning %s" % product_name
798+ print ("--- {} ---" .format (log_message ))
799+ t_start = time .time ()
800+ log_time ('start' , log_message )
790801 product .clean (host_target )
802+ log_time ('end' , log_message , time .time () - t_start )
791803 if product .should_build (host_target ):
792- print ("--- Building %s ---" % product_name )
804+ log_message = "Building %s" % product_name
805+ print ("--- {} ---" .format (log_message ))
806+ t_start = time .time ()
807+ log_time ('start' , log_message , '0' )
793808 product .build (host_target )
809+ log_time ('end' , log_message , time .time () - t_start )
794810 if product .should_test (host_target ):
795- print ("--- Running tests for %s ---" % product_name )
811+ log_message = "Running tests for %s" % product_name
812+ print ("--- {} ---" .format (log_message ))
813+ t_start = time .time ()
814+ log_time ('start' , log_message )
796815 product .test (host_target )
816+ log_time ('end' , log_message , time .time () - t_start )
797817 print ("--- Finished tests for %s ---" % product_name )
798818 # Install the product if it should be installed specifically, or
799819 # if it should be built and `install_all` is set to True.
@@ -803,5 +823,9 @@ def execute_product_build_steps(self, product_class, host_target):
803823 if product .should_install (host_target ) or \
804824 (self .install_all and product .should_build (host_target ) and
805825 not product .is_ignore_install_all_product ()):
806- print ("--- Installing %s ---" % product_name )
826+ log_message = "Installing %s" % product_name
827+ print ("--- {} ---" .format (log_message ))
828+ t_start = time .time ()
829+ log_time ('start' , log_message )
807830 product .install (host_target )
831+ log_time ('end' , log_message , time .time () - t_start )
0 commit comments