diff -r 0f62a65fb666 -r a1c8b847b753 make/Defs-internal.gmk --- a/make/Defs-internal.gmk Thu Feb 24 15:15:45 2011 -0800 +++ b/make/Defs-internal.gmk Mon Feb 28 10:56:10 2011 +0100 @@ -28,21 +28,63 @@ # not contain rules. # -# Indicate that we are visiting a separate repo or component +# The build times report is turned off by setting REPORT_BUILD_TIMES to nothing. +# This is necessary for the target clobber/clean which will erase the +# directories where the buildtimes are stored. +REPORT_BUILD_TIMES=1 +# Store the build times in this directory. +BUILDTIMESDIR=$(ABS_OUTPUTDIR)/tmp/buildtimes + +# Record starting time for build of a sub repository. +define RecordStartTime +$(MKDIR) -p $(BUILDTIMESDIR) +$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$1 +$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$1_human_readable +endef + +# Indicate that we started to build a sub repository and record starting time. define MakeStart -$(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n" \ +$(call RecordStartTime,$1) +$(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n\n" \ "########################################################################" \ "########################################################################" \ -"Entering $1 for target $2" \ +"Entering $1 for target(s) $2" \ "########################################################################" endef -define MakeFinish -$(PRINTF) "%s\n##### %-60.60s #####\n%s\n%s\n\n" \ +# Record ending time and calculate the difference and store it in a +# easy to read format. Handles builds that cross midnight. Expects +# that a build will never take 24 hours or more. +define RecordEndTime +$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$1 +$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$1_human_readable +$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$1` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$1` $1 | \ + $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \ + M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \ + > $(BUILDTIMESDIR)/build_time_diff_$1 +endef + +# Indicate that we are done. +# Record ending time and print out the total time it took to build. +define MakeFinish +$(if $(REPORT_BUILD_TIMES),$(call RecordEndTime,$1),) +$(PRINTF) "%s\n##### %-60.60s #####\n%s\n##### %-60.60s #####\n%s\n\n" \ "########################################################################" \ -"Leaving $1 for target $2" \ +"Leaving $1 for target(s) $2" \ "########################################################################" \ -"########################################################################" +$(if $(REPORT_BUILD_TIMES),"Build time `$(CAT) $(BUILDTIMESDIR)/build_time_diff_$1` for target(s) $2","") \ +"########################################################################" +endef + +# Find all build_time_* files and print their contents in a list sorted +# on the name of the sub repository. +define ReportBuildTimes +$(PRINTF) "-- Build times ----------\nTarget %s\nStart %s\nEnd %s\n%s\n%s\n-------------------------\n" \ +$1 \ +"`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \ +"`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \ +"`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | $(XARGS) $(CAT) | $(SORT) -k 2`" \ +"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" endef ifdef OPENJDK