26 # |
26 # |
27 # Common variables used by all the Java makefiles. This file should |
27 # Common variables used by all the Java makefiles. This file should |
28 # not contain rules. |
28 # not contain rules. |
29 # |
29 # |
30 |
30 |
31 # Indicate that we are visiting a separate repo or component |
31 # The build times report is turned off by setting REPORT_BUILD_TIMES to nothing. |
|
32 # This is necessary for the target clobber/clean which will erase the |
|
33 # directories where the buildtimes are stored. |
|
34 REPORT_BUILD_TIMES=1 |
|
35 # Store the build times in this directory. |
|
36 BUILDTIMESDIR=$(ABS_OUTPUTDIR)/tmp/buildtimes |
|
37 |
|
38 # Record starting time for build of a sub repository. |
|
39 define RecordStartTime |
|
40 $(MKDIR) -p $(BUILDTIMESDIR) |
|
41 $(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 |
|
42 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$1_human_readable |
|
43 endef |
|
44 |
|
45 # Indicate that we started to build a sub repository and record starting time. |
32 define MakeStart |
46 define MakeStart |
33 $(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n" \ |
47 $(call RecordStartTime,$1) |
|
48 $(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n\n" \ |
34 "########################################################################" \ |
49 "########################################################################" \ |
35 "########################################################################" \ |
50 "########################################################################" \ |
36 "Entering $1 for target $2" \ |
51 "Entering $1 for target(s) $2" \ |
37 "########################################################################" |
52 "########################################################################" |
38 endef |
53 endef |
39 |
54 |
40 define MakeFinish |
55 # Record ending time and calculate the difference and store it in a |
41 $(PRINTF) "%s\n##### %-60.60s #####\n%s\n%s\n\n" \ |
56 # easy to read format. Handles builds that cross midnight. Expects |
|
57 # that a build will never take 24 hours or more. |
|
58 define RecordEndTime |
|
59 $(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 |
|
60 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$1_human_readable |
|
61 $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$1` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$1` $1 | \ |
|
62 $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \ |
|
63 M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \ |
|
64 > $(BUILDTIMESDIR)/build_time_diff_$1 |
|
65 endef |
|
66 |
|
67 # Indicate that we are done. |
|
68 # Record ending time and print out the total time it took to build. |
|
69 define MakeFinish |
|
70 $(if $(REPORT_BUILD_TIMES),$(call RecordEndTime,$1),) |
|
71 $(PRINTF) "%s\n##### %-60.60s #####\n%s\n##### %-60.60s #####\n%s\n\n" \ |
42 "########################################################################" \ |
72 "########################################################################" \ |
43 "Leaving $1 for target $2" \ |
73 "Leaving $1 for target(s) $2" \ |
44 "########################################################################" \ |
74 "########################################################################" \ |
45 "########################################################################" |
75 $(if $(REPORT_BUILD_TIMES),"Build time `$(CAT) $(BUILDTIMESDIR)/build_time_diff_$1` for target(s) $2","") \ |
|
76 "########################################################################" |
|
77 endef |
|
78 |
|
79 # Find all build_time_* files and print their contents in a list sorted |
|
80 # on the name of the sub repository. |
|
81 define ReportBuildTimes |
|
82 $(PRINTF) "-- Build times ----------\nTarget %s\nStart %s\nEnd %s\n%s\n%s\n-------------------------\n" \ |
|
83 $1 \ |
|
84 "`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \ |
|
85 "`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \ |
|
86 "`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | $(XARGS) $(CAT) | $(SORT) -k 2`" \ |
|
87 "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" |
46 endef |
88 endef |
47 |
89 |
48 ifdef OPENJDK |
90 ifdef OPENJDK |
49 ifneq ($(OPENJDK),true) |
91 ifneq ($(OPENJDK),true) |
50 x:=$(error "OPENJDK (if defined) can only be set to true") |
92 x:=$(error "OPENJDK (if defined) can only be set to true") |