48 # JVM:=The jvm used to run the javac/javah command |
48 # JVM:=The jvm used to run the javac/javah command |
49 # JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out |
49 # JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out |
50 # FLAGS:=Flags to be supplied to javac |
50 # FLAGS:=Flags to be supplied to javac |
51 # SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here |
51 # SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here |
52 # SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above. |
52 # SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above. |
53 $(if $2,$1_$(strip $2)) |
53 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) |
54 $(if $3,$1_$(strip $3)) |
54 $(call LogSetupMacroEntry,SetupJavaCompiler($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) |
55 $(if $4,$1_$(strip $4)) |
55 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk)) |
56 $(if $5,$1_$(strip $5)) |
56 |
57 $(if $6,$1_$(strip $6)) |
57 # The port file contains the tcp/ip on which the server listens |
58 $(if $7,$1_$(strip $7)) |
58 # and the cookie necessary to talk to the server. |
59 $(if $8,$1_$(strip $8)) |
59 $1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port |
60 $(if $9,$1_$(strip $9)) |
60 # You can use a different JVM to run the background javac server. |
61 $(if $(10),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk)) |
61 ifeq ($$($1_SERVER_JVM),) |
62 |
62 # It defaults to the same JVM that is used to start the javac command. |
63 ifeq ($$(ENABLE_SJAVAC),yes) |
63 $1_SERVER_JVM:=$$($1_JVM) |
64 # The port file contains the tcp/ip on which the server listens |
|
65 # and the cookie necessary to talk to the server. |
|
66 $1_JAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port |
|
67 # You can use a different JVM to run the background javac server. |
|
68 ifeq ($$($1_SERVER_JVM),) |
|
69 # It defaults to the same JVM that is used to start the javac command. |
|
70 $1_SERVER_JVM:=$$($1_JVM) |
|
71 endif |
|
72 # Set the $1_REMOTE to spawn a background javac server. |
|
73 $1_REMOTE:=-XDserver:portfile=$$($1_JAVAC_PORTFILE),poolsize=$(SJAVAC_SERVER_CORES),id=$1,javac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_JAVAC)))) |
|
74 endif |
64 endif |
75 endef |
65 endef |
76 |
66 |
77 define SetupArchive |
67 define SetupArchive |
78 # param 1 is for example ARCHIVE_MYPACKAGE |
68 # param 1 is for example ARCHIVE_MYPACKAGE |
90 # JARINDEX:=true means generate the index in the jar file. |
80 # JARINDEX:=true means generate the index in the jar file. |
91 # SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically |
81 # SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically |
92 # added to the archive. |
82 # added to the archive. |
93 # EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest. |
83 # EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest. |
94 # CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable |
84 # CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable |
95 $(if $3,$1_$(strip $3)) |
85 |
96 $(if $4,$1_$(strip $4)) |
86 # NOTE: $2 is dependencies, not a named argument! |
97 $(if $5,$1_$(strip $5)) |
87 $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) |
98 $(if $6,$1_$(strip $6)) |
88 $(call LogSetupMacroEntry,SetupArchive($1),<dependencies>,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) |
99 $(if $7,$1_$(strip $7)) |
89 $(if $(findstring $(LOG),debug trace), $(info *[2] <dependencies> = $(strip $2))) |
100 $(if $8,$1_$(strip $8)) |
|
101 $(if $9,$1_$(strip $9)) |
|
102 $(if $(10),$1_$(strip $(10))) |
|
103 $(if $(11),$1_$(strip $(11))) |
|
104 $(if $(12),$1_$(strip $(12))) |
|
105 $(if $(13),$1_$(strip $(13))) |
|
106 $(if $(14),$1_$(strip $(14))) |
|
107 $(if $(15),$1_$(strip $(15))) |
|
108 $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk)) |
90 $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk)) |
109 |
91 |
110 $1_JARMAIN:=$(strip $$($1_JARMAIN)) |
92 $1_JARMAIN:=$(strip $$($1_JARMAIN)) |
111 $1_JARNAME:=$$(notdir $$($1_JAR)) |
93 $1_JARNAME:=$$(notdir $$($1_JAR)) |
112 $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest |
94 $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest |
123 # On windows, a lot of includes/excludes risk making the command line too long, so |
105 # On windows, a lot of includes/excludes risk making the command line too long, so |
124 # writing the grep patterns to files. |
106 # writing the grep patterns to files. |
125 ifneq (,$$($1_INCLUDES)) |
107 ifneq (,$$($1_INCLUDES)) |
126 $1_GREP_INCLUDE_PATTERNS:=$$(foreach src,$$($1_SRCS),\ |
108 $1_GREP_INCLUDE_PATTERNS:=$$(foreach src,$$($1_SRCS),\ |
127 $$(addprefix $$(src)/,$$($1_INCLUDES))) |
109 $$(addprefix $$(src)/,$$($1_INCLUDES))) |
128 $$(eval $$(call ListPathsSafelyNow,$1_GREP_INCLUDE_PATTERNS,\n, \ |
110 # If there are a lot of include patterns, output to file to shorten command lines |
|
111 ifeq ($$(word 20,$$($1_GREP_INCLUDE_PATTERNS)),) |
|
112 $1_GREP_INCLUDES:=| $(GREP) $$(patsubst %,$(SPACE)-e$(SPACE)$(DQUOTE)%$(DQUOTE),$$($1_GREP_INCLUDE_PATTERNS)) |
|
113 else |
|
114 $$(shell $(RM) $$($1_BIN)/_the.$$($1_JARNAME)_include) |
|
115 $$(eval $$(call ListPathsSafelyNow,$1_GREP_INCLUDE_PATTERNS,\n, \ |
129 >> $$($1_BIN)/_the.$$($1_JARNAME)_include)) |
116 >> $$($1_BIN)/_the.$$($1_JARNAME)_include)) |
130 $1_GREP_INCLUDES:=| $(GREP) -f $$($1_BIN)/_the.$$($1_JARNAME)_include |
117 $1_GREP_INCLUDES:=| $(GREP) -f $$($1_BIN)/_the.$$($1_JARNAME)_include |
|
118 endif |
131 endif |
119 endif |
132 ifneq (,$$($1_EXCLUDES)$$($1_EXCLUDE_FILES)) |
120 ifneq (,$$($1_EXCLUDES)$$($1_EXCLUDE_FILES)) |
133 $1_GREP_EXCLUDE_PATTERNS:=$$(foreach src,$$($1_SRCS),$$(addprefix $$(src)/,\ |
121 $1_GREP_EXCLUDE_PATTERNS:=$$(foreach src,$$($1_SRCS),$$(addprefix $$(src)/,\ |
134 $$($1_EXCLUDES) $$($1_EXCLUDE_FILES))) |
122 $$($1_EXCLUDES) $$($1_EXCLUDE_FILES))) |
135 $$(eval $$(call ListPathsSafelyNow,$1_GREP_EXCLUDE_PATTERNS,\n, \ |
123 # If there are a lot of include patterns, output to file to shorten command lines |
|
124 ifeq ($$(word 20,$$($1_GREP_EXCLUDE_PATTERNS)),) |
|
125 $1_GREP_EXCLUDES:=| $(GREP) -v $$(patsubst %,$(SPACE)-e$(SPACE)$(DQUOTE)%$(DQUOTE),$$($1_GREP_EXCLUDE_PATTERNS)) |
|
126 else |
|
127 $$(shell $(RM) $$($1_BIN)/_the.$$($1_JARNAME)_exclude) |
|
128 $$(eval $$(call ListPathsSafelyNow,$1_GREP_EXCLUDE_PATTERNS,\n, \ |
136 >> $$($1_BIN)/_the.$$($1_JARNAME)_exclude)) |
129 >> $$($1_BIN)/_the.$$($1_JARNAME)_exclude)) |
137 $1_GREP_EXCLUDES:=| $(GREP) -v -f $$($1_BIN)/_the.$$($1_JARNAME)_exclude |
130 $1_GREP_EXCLUDES:=| $(GREP) -v -f $$($1_BIN)/_the.$$($1_JARNAME)_exclude |
|
131 endif |
138 endif |
132 endif |
139 |
133 |
140 # Check if this jar needs to have its index generated. |
134 # Check if this jar needs to have its index generated. |
141 ifneq (,$$($1_JARINDEX)) |
135 ifneq (,$$($1_JARINDEX)) |
142 $1_JARINDEX = (cd $$(dir $$@) && $(JAR) -i $$(notdir $$@)) |
136 $1_JARINDEX = (cd $$(dir $$@) && $(JAR) -i $$(notdir $$@)) |
147 # in make variables. When the macro is run in a different makefile than the java compilation, the |
141 # in make variables. When the macro is run in a different makefile than the java compilation, the |
148 # dependencies need to be found in the filesystem. |
142 # dependencies need to be found in the filesystem. |
149 ifneq (,$2) |
143 ifneq (,$2) |
150 $1_DEPS:=$2 |
144 $1_DEPS:=$2 |
151 else |
145 else |
152 $1_DEPS:=$$(foreach src,$$($1_SRCS),$$(shell ($(FIND) $$(src) -type f \ |
146 # The subst of \ is needed because $ has to be escaped with \ in EXTRA_FILES for the command |
153 -a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \ |
147 # lines, but not here for use in make dependencies. |
154 $$($1_GREP_EXCLUDES) && $(ECHO) $$(addprefix $$(src)/,$$($1_EXTRA_FILES))))) |
148 $1_DEPS:=$$(shell $(FIND) $$($1_SRCS) -type f -a \( $$($1_FIND_PATTERNS) \) \ |
|
149 $$($1_GREP_INCLUDES) $$($1_GREP_EXCLUDES)) \ |
|
150 $$(subst \,,$$(foreach src,$$($1_SRCS),$$(addprefix $$(src)/,$$($1_EXTRA_FILES)))) |
155 ifeq (,$$($1_SKIP_METAINF)) |
151 ifeq (,$$($1_SKIP_METAINF)) |
156 $1_DEPS+=$$(foreach src,$$($1_SRCS),$$(shell $(FIND) $$(src)/META-INF -type f 2> /dev/null)) |
152 $1_DEPS+=$$(shell $(FIND) $$(addsuffix /META-INF,$$($1_SRCS)) -type f 2> /dev/null)) |
157 endif |
153 endif |
158 endif |
154 endif |
159 |
155 |
160 # Utility macros, to make the shell script receipt somewhat easier to dechipher. |
156 # Utility macros, to make the shell script receipt somewhat easier to dechipher. |
161 |
157 |
162 # The capture contents macro finds all files (matching the patterns, typically |
158 # The capture contents macro finds all files (matching the patterns, typically |
163 # .class and .prp) that are newer than the jar-file, ie the new content to be put into the jar. |
159 # .class and .prp) that are newer than the jar-file, ie the new content to be put into the jar. |
164 $1_CAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),(($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) -a -newer $$@ $$($1_GREP_INCLUDES) $$($1_GREP_EXCLUDES) && $(ECHO) $$($1_EXTRA_FILES)) | $(SED) 's|$$(src)/||g' > $$(src)/_the.$$($1_JARNAME)_contents) && ) |
160 $1_CAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\ |
|
161 (($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) -a -newer $$@ $$($1_GREP_INCLUDES) \ |
|
162 $$($1_GREP_EXCLUDES) | $(SED) 's|$$(src)/||g' &&\ |
|
163 $(ECHO) $$(subst $$(src)/,,$$($1_EXTRA_FILES))) > \ |
|
164 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE)) |
165 # The capture metainf macro finds all files below the META-INF directory that are newer than the jar-file. |
165 # The capture metainf macro finds all files below the META-INF directory that are newer than the jar-file. |
166 ifeq (,$$($1_SKIP_METAINF)) |
166 ifeq (,$$($1_SKIP_METAINF)) |
167 $1_CAPTURE_METAINF =$$(foreach src,$$($1_SRCS),($(FIND) $$(src)/META-INF -type f -a -newer $$@ 2> /dev/null | $(SED) 's|$$(src)/||g' >> $$(src)/_the.$$($1_JARNAME)_contents ) && ) |
167 $1_CAPTURE_METAINF =$$(foreach src,$$($1_SRCS),($(FIND) $$(src)/META-INF -type f -a -newer $$@ 2> /dev/null | $(SED) 's|$$(src)/||g' >> $$(src)/_the.$$($1_JARNAME)_contents ) $$(NEWLINE)) |
168 endif |
168 endif |
169 # The capture deletes macro finds all deleted files and concatenates them. The resulting file |
169 # The capture deletes macro finds all deleted files and concatenates them. The resulting file |
170 # tells us what to remove from the jar-file. |
170 # tells us what to remove from the jar-file. |
171 $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.deleted -newer $$@ -exec $(SED) 's|$$(src)||g' \{\} >> $$($1_DELETES_FILE) \;) &&) |
171 $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.deleted -newer $$@ -exec $(SED) 's|$$(src)||g' \{\} >> $$($1_DELETES_FILE) \;) $$(NEWLINE)) |
172 # The update contents macro updates the jar file with the previously capture contents. |
172 # The update contents macro updates the jar file with the previously capture contents. |
173 $1_UPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\ |
173 $1_UPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\ |
174 (cd $$(src) && \ |
174 (cd $$(src) && \ |
175 if [ -s _the.$$($1_JARNAME)_contents ]; then \ |
175 if [ -s _the.$$($1_JARNAME)_contents ]; then \ |
176 $(ECHO) " updating" `$(WC) -l _the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \ |
176 $(ECHO) " updating" `$(WC) -l _the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \ |
177 $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @_the.$$($1_JARNAME)_contents; \ |
177 $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @_the.$$($1_JARNAME)_contents; \ |
178 fi) &&) |
178 fi) $$(NEWLINE)) |
179 # The s-variants of the above macros are used when the jar is created from scratch. |
179 # The s-variants of the above macros are used when the jar is created from scratch. |
180 $1_SCAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\ |
180 $1_SCAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\ |
181 (($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \ |
181 (($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \ |
182 $$($1_GREP_EXCLUDES) && $(ECHO) $$($1_EXTRA_FILES)) | $(SED) 's|$$(src)/||g' > \ |
182 $$($1_GREP_EXCLUDES) | $(SED) 's|$$(src)/||g' &&\ |
183 $$(src)/_the.$$($1_JARNAME)_contents) && ) |
183 $$(subst $$(src)/,,$(ECHO) $$($1_EXTRA_FILES))) > \ |
|
184 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE)) |
184 |
185 |
185 ifeq (,$$($1_SKIP_METAINF)) |
186 ifeq (,$$($1_SKIP_METAINF)) |
186 $1_SCAPTURE_METAINF=$$(foreach src,$$($1_SRCS),\ |
187 $1_SCAPTURE_METAINF=$$(foreach src,$$($1_SRCS),\ |
187 ($(FIND) $$(src)/META-INF -type f 2> /dev/null | $(SED) 's|$$(src)/||g' >> \ |
188 ($(FIND) $$(src)/META-INF -type f 2> /dev/null | $(SED) 's|$$(src)/||g' >> \ |
188 $$(src)/_the.$$($1_JARNAME)_contents) && ) |
189 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE)) |
189 endif |
190 endif |
190 $1_SUPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\ |
191 $1_SUPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\ |
191 (cd $$(src) && $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$(src)/_the.$$($1_JARNAME)_contents) &&) |
192 (cd $$(src) && $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE)) |
192 |
193 |
193 # Use a slightly shorter name for logging, but with enough path to identify this jar. |
194 # Use a slightly shorter name for logging, but with enough path to identify this jar. |
194 $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_JAR)) |
195 $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_JAR)) |
195 |
196 |
196 ifneq (,$$($1_CHECK_COMPRESS_JAR)) |
197 ifneq (,$$($1_CHECK_COMPRESS_JAR)) |
206 endif |
207 endif |
207 |
208 |
208 # Here is the rule that creates/updates the jar file. |
209 # Here is the rule that creates/updates the jar file. |
209 $$($1_JAR) : $$($1_DEPS) |
210 $$($1_JAR) : $$($1_DEPS) |
210 $(MKDIR) -p $$($1_BIN) |
211 $(MKDIR) -p $$($1_BIN) |
211 if [ -n "$$($1_MANIFEST)" ]; then \ |
212 $$(if $$($1_MANIFEST),\ |
212 $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ |
213 $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ |
213 -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $$($1_MANIFEST) > $$($1_MANIFEST_FILE); \ |
214 -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $$($1_MANIFEST) > $$($1_MANIFEST_FILE) \ |
214 else \ |
215 ,\ |
215 $(RM) $$($1_MANIFEST_FILE) && $(TOUCH) $$($1_MANIFEST_FILE); \ |
216 $(RM) $$($1_MANIFEST_FILE) && $(TOUCH) $$($1_MANIFEST_FILE)) |
216 fi |
217 $$(if $$($1_JARMAIN),$(ECHO) "Main-Class: $$(strip $$($1_JARMAIN))" >> $$($1_MANIFEST_FILE)) |
217 if [ -n "$$(strip $$($1_JARMAIN))" ]; then \ |
218 $$(if $$($1_EXTRA_MANIFEST_ATTR),$(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE)) |
218 $(ECHO) "Main-Class: $$(strip $$($1_JARMAIN))" >> $$($1_MANIFEST_FILE); \ |
219 $$(if $$(wildcard $$@),\ |
219 fi |
220 $(ECHO) Modifying $$($1_NAME) $$(NEWLINE)\ |
220 if [ -n "$$($1_EXTRA_MANIFEST_ATTR)" ]; then \ |
|
221 $(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE); \ |
|
222 fi |
|
223 +if [ -s $$@ ]; then \ |
|
224 $(ECHO) Modifying $$($1_NAME) && \ |
|
225 $$($1_CAPTURE_CONTENTS) \ |
221 $$($1_CAPTURE_CONTENTS) \ |
226 $$($1_CAPTURE_METAINF) \ |
222 $$($1_CAPTURE_METAINF) \ |
227 $(RM) $$($1_DELETES_FILE) && \ |
223 $(RM) $$($1_DELETES_FILE) $$(NEWLINE)\ |
228 $$($1_CAPTURE_DELETES) \ |
224 $$($1_CAPTURE_DELETES) \ |
229 $(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) && \ |
225 $(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) $$(NEWLINE)\ |
230 if [ -s $$($1_DELETESS_FILE) ]; then \ |
226 if [ -s $$($1_DELETESS_FILE) ]; then \ |
231 $(ECHO) " deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \ |
227 $(ECHO) " deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \ |
232 $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \ |
228 $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \ |
233 fi && \ |
229 fi $$(NEWLINE) \ |
234 $$($1_UPDATE_CONTENTS) true && \ |
230 $$($1_UPDATE_CONTENTS) true $$(NEWLINE) \ |
235 $$($1_JARINDEX) && true ; \ |
231 $$($1_JARINDEX) && true \ |
236 else \ |
232 ,\ |
237 $(ECHO) Creating $$($1_NAME) && $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) && \ |
233 $(ECHO) Creating $$($1_NAME) && $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \ |
238 $$($1_SCAPTURE_CONTENTS) \ |
234 $$($1_SCAPTURE_CONTENTS) \ |
239 $$($1_SCAPTURE_METAINF) \ |
235 $$($1_SCAPTURE_METAINF) \ |
240 $$($1_SUPDATE_CONTENTS) \ |
236 $$($1_SUPDATE_CONTENTS) \ |
241 $$($1_JARINDEX) && true ; \ |
237 $$($1_JARINDEX) && true ) |
242 fi; |
|
243 |
238 |
244 endef |
239 endef |
245 |
240 |
246 define SetupZipArchive |
241 define SetupZipArchive |
247 # param 1 is for example ZIP_MYSOURCE |
242 # param 1 is for example ZIP_MYSOURCE |
248 # param 2,3,4,5,6,7,8,9 are named args. |
243 # param 2,3,4,5,6,7,8,9 are named args. |
249 # SRC,ZIP,INCLUDES,EXCLUDES,EXCLUDE_FILES,SUFFIXES,EXTRA_DEPS |
244 # SRC,ZIP,INCLUDES,EXCLUDES,EXCLUDE_FILES,SUFFIXES,EXTRA_DEPS |
250 $(if $2,$1_$(strip $2)) |
245 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) |
251 $(if $3,$1_$(strip $3)) |
246 $(call LogSetupMacroEntry,SetupZipArchive($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) |
252 $(if $4,$1_$(strip $4)) |
247 $(if $(16),$(error Internal makefile error: Too many arguments to SetupZipArchive, please update JavaCompilation.gmk)) |
253 $(if $5,$1_$(strip $5)) |
|
254 $(if $6,$1_$(strip $6)) |
|
255 $(if $7,$1_$(strip $7)) |
|
256 $(if $8,$1_$(strip $8)) |
|
257 $(if $9,$1_$(strip $9)) |
|
258 $(if $(10),$(error Internal makefile error: Too many arguments to SetupZipArchive, please update JavaCompilation.gmk)) |
|
259 |
248 |
260 # Find all files in the source tree. |
249 # Find all files in the source tree. |
261 $1_SUFFIX_FILTER := $$(patsubst %,-o -name $(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES)) |
250 $1_SUFFIX_FILTER := $$(patsubst %,-o -name $(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES)) |
262 $1_ALL_SRCS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i -type f -a ! -name "_the.*" \( -name FALSE_DUMMY $$($1_SUFFIX_FILTER) \) )) |
251 $1_ALL_SRCS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i -type f -a ! -name "_the.*" \( -name FALSE_DUMMY $$($1_SUFFIX_FILTER) \) )) |
263 |
252 |
272 $1_ALL_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_SRCS)) |
261 $1_ALL_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_SRCS)) |
273 endif |
262 endif |
274 ifneq ($$($1_EXCLUDES),) |
263 ifneq ($$($1_EXCLUDES),) |
275 $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) |
264 $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) |
276 $1_ZIP_EXCLUDES := $$(addprefix -x$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_EXCLUDES))) |
265 $1_ZIP_EXCLUDES := $$(addprefix -x$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_EXCLUDES))) |
277 $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRC)) |
266 $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_SRCS)) |
278 endif |
267 endif |
279 |
268 |
280 # Use a slightly shorter name for logging, but with enough path to identify this zip. |
269 # Use a slightly shorter name for logging, but with enough path to identify this zip. |
281 $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_ZIP)) |
270 $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_ZIP)) |
282 |
271 |
362 # "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found. |
351 # "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found. |
363 # JAVAC_SOURCE_PATH_UGLY_OVERRIDE:=Don't use this. This forces an explicit -sourcepath to javac. |
352 # JAVAC_SOURCE_PATH_UGLY_OVERRIDE:=Don't use this. This forces an explicit -sourcepath to javac. |
364 # Its only here until we cleanup some nasty source code pasta in the jdk. |
353 # Its only here until we cleanup some nasty source code pasta in the jdk. |
365 # HEADERS:=path to directory where all generated c-headers are written. |
354 # HEADERS:=path to directory where all generated c-headers are written. |
366 # DEPENDS:=Extra dependecy |
355 # DEPENDS:=Extra dependecy |
367 $(if $2,$1_$(strip $2)) |
356 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) |
368 $(if $3,$1_$(strip $3)) |
357 $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) |
369 $(if $4,$1_$(strip $4)) |
358 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) |
370 $(if $5,$1_$(strip $5)) |
|
371 $(if $6,$1_$(strip $6)) |
|
372 $(if $7,$1_$(strip $7)) |
|
373 $(if $8,$1_$(strip $8)) |
|
374 $(if $9,$1_$(strip $9)) |
|
375 $(if $(10),$1_$(strip $(10))) |
|
376 $(if $(11),$1_$(strip $(11))) |
|
377 $(if $(12),$1_$(strip $(12))) |
|
378 $(if $(13),$1_$(strip $(13))) |
|
379 $(if $(14),$1_$(strip $(14))) |
|
380 $(if $(15),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) |
|
381 |
359 |
382 # Extract the info from the java compiler setup. |
360 # Extract the info from the java compiler setup. |
383 $1_REMOTE := $$($$($1_SETUP)_REMOTE) |
|
384 $1_JVM := $$($$($1_SETUP)_JVM) |
361 $1_JVM := $$($$($1_SETUP)_JVM) |
385 $1_JAVAC := $$($$($1_SETUP)_JAVAC) |
362 $1_JAVAC := $$($$($1_SETUP)_JAVAC) |
386 $1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS) |
363 $1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS) |
387 ifeq ($$($1_JAVAC),) |
364 ifeq ($$($1_JAVAC),) |
388 $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP)) |
365 $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP)) |
389 endif |
366 endif |
|
367 $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE) |
|
368 $1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM) |
390 |
369 |
391 # Handle addons and overrides. |
370 # Handle addons and overrides. |
392 $1_SRC:=$$(call ADD_SRCS,$$($1_SRC)) |
371 $1_SRC:=$$(call ADD_SRCS,$$($1_SRC)) |
393 # Make sure the dirs exist. |
372 # Make sure the dirs exist. |
394 $$(shell $(MKDIR) -p $$($1_SRC) $$($1_BIN)) |
373 $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory $$d))) |
|
374 $$(eval $$(call MakeDir,$$($1_BIN))) |
395 # Find all files in the source trees. |
375 # Find all files in the source trees. |
396 $1_ALL_SRCS := $$(filter-out $(OVR_SRCS),$$(foreach i,$$($1_SRC),$$(shell $(FIND) $$i -type f))) |
376 $1_ALL_SRCS := $$(filter-out $(OVR_SRCS),$$(shell $(FIND) $$($1_SRC) -type f)) |
397 # Extract the java files. |
377 # Extract the java files. |
398 ifneq ($$($1_EXCLUDE_FILES),) |
378 ifneq ($$($1_EXCLUDE_FILES),) |
399 $1_EXCLUDE_FILES_PATTERN:=$$(addprefix %,$$($1_EXCLUDE_FILES)) |
379 $1_EXCLUDE_FILES_PATTERN:=$$(addprefix %,$$($1_EXCLUDE_FILES)) |
400 endif |
380 endif |
401 $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$(filter %.java,$$($1_ALL_SRCS))) |
381 $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$(filter %.java,$$($1_ALL_SRCS))) |
426 # Find all files to be copied from source to bin. |
406 # Find all files to be copied from source to bin. |
427 ifneq (,$$($1_COPY)) |
407 ifneq (,$$($1_COPY)) |
428 # Rewrite list of patterns into a find statement. |
408 # Rewrite list of patterns into a find statement. |
429 $1_COPY_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_COPY)) |
409 $1_COPY_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_COPY)) |
430 # Search for all files to be copied. |
410 # Search for all files to be copied. |
431 $1_ALL_COPIES := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_COPY_PATTERN) \) -a -type f)) |
411 $1_ALL_COPIES := $$(filter $$(addprefix %,$$($1_COPY)),$$($1_ALL_SRCS)) |
432 # Copy these explicitly |
412 # Copy these explicitly |
433 $1_ALL_COPIES += $$($1_COPY_FILES) |
413 $1_ALL_COPIES += $$($1_COPY_FILES) |
434 # Copy must also respect filters. |
414 # Copy must also respect filters. |
435 ifneq (,$$($1_INCLUDES)) |
415 ifneq (,$$($1_INCLUDES)) |
436 $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES)) |
416 $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES)) |
440 endif |
420 endif |
441 ifneq (,$$($1_EXCLUDE_FILES)) |
421 ifneq (,$$($1_EXCLUDE_FILES)) |
442 $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES)) |
422 $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES)) |
443 endif |
423 endif |
444 # All files below META-INF are always copied. |
424 # All files below META-INF are always copied. |
445 $1_ALL_COPIES += $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i/META-INF -type f 2> /dev/null)) |
425 $1_ALL_COPIES += $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS)) |
446 ifneq (,$$($1_ALL_COPIES)) |
426 ifneq (,$$($1_ALL_COPIES)) |
447 # Yep, there are files to be copied! |
427 # Yep, there are files to be copied! |
448 $1_ALL_COPY_TARGETS:= |
428 $1_ALL_COPY_TARGETS:= |
449 $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i))) |
429 $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i))) |
450 # Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files! |
430 # Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files! |
454 # Find all property files to be copied and cleaned from source to bin. |
434 # Find all property files to be copied and cleaned from source to bin. |
455 ifneq (,$$($1_CLEAN)) |
435 ifneq (,$$($1_CLEAN)) |
456 # Rewrite list of patterns into a find statement. |
436 # Rewrite list of patterns into a find statement. |
457 $1_CLEAN_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_CLEAN)) |
437 $1_CLEAN_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_CLEAN)) |
458 # Search for all files to be copied. |
438 # Search for all files to be copied. |
459 $1_ALL_CLEANS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_CLEAN_PATTERN) \) -a -type f)) |
439 $1_ALL_CLEANS := $$(filter $$(addprefix %,$$($1_CLEAN)),$$($1_ALL_SRCS)) |
460 # Copy and clean must also respect filters. |
440 # Copy and clean must also respect filters. |
461 ifneq (,$$($1_INCLUDES)) |
441 ifneq (,$$($1_INCLUDES)) |
462 $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS)) |
442 $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS)) |
463 endif |
443 endif |
464 ifneq (,$$($1_EXCLUDES)) |
444 ifneq (,$$($1_EXCLUDES)) |
480 $$(eval $$(call replace_space_with_pathsep,$1_SRCROOTSC,$$($1_JAVAC_SOURCE_PATH_UGLY_OVERRIDE))) |
460 $$(eval $$(call replace_space_with_pathsep,$1_SRCROOTSC,$$($1_JAVAC_SOURCE_PATH_UGLY_OVERRIDE))) |
481 else |
461 else |
482 $$(eval $$(call replace_space_with_pathsep,$1_SRCROOTSC,$$($1_SRC))) |
462 $$(eval $$(call replace_space_with_pathsep,$1_SRCROOTSC,$$($1_SRC))) |
483 endif |
463 endif |
484 |
464 |
485 ifneq (,$$($1_HEADERS)) |
|
486 $1_HEADERS_ARG := -h $$($1_HEADERS) |
|
487 endif |
|
488 |
|
489 # Create a sed expression to remove the source roots and to replace / with . |
465 # Create a sed expression to remove the source roots and to replace / with . |
490 # and remove .java at the end. |
466 # and remove .java at the end. |
491 $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g' |
467 $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g' |
492 |
468 |
493 ifeq ($$($1_DISABLE_SJAVAC)x$$(ENABLE_SJAVAC),xyes) |
469 ifeq ($$($1_DISABLE_SJAVAC)x$$(ENABLE_SJAVAC),xyes) |
|
470 ifneq (,$$($1_HEADERS)) |
|
471 $1_HEADERS_ARG := -h $$($1_HEADERS) |
|
472 endif |
|
473 |
494 # Using sjavac to compile. |
474 # Using sjavac to compile. |
495 $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/javac_state |
475 $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/javac_state |
|
476 |
|
477 # Create SJAVAC variable, |
|
478 # expects $1_JAVAC to be "bootclasspathprepend -jar ...javac.jar" |
|
479 # and it is rewritten into "bootclasspathprepend com.sun.tools.sjavac.Main" |
|
480 $1_SJAVAC:=$$(word 1,$$($1_JAVAC)) -cp $$(word 3,$$($1_JAVAC)) com.sun.tools.sjavac.Main |
|
481 |
|
482 # Set the $1_REMOTE to spawn a background javac server. |
|
483 $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),poolsize=$(SJAVAC_SERVER_CORES),id=$1,sjavac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC)))) |
496 |
484 |
497 $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS) |
485 $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS) |
498 $(MKDIR) -p $$(@D) |
486 $(MKDIR) -p $$(@D) |
499 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp) |
487 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp) |
500 $(ECHO) Compiling $1 |
488 $(ECHO) Compiling $1 |
501 $$($1_JVM) $$(word 1,$$($1_JAVAC)) com.sun.tools.sjavac.Main \ |
489 $$($1_JVM) $$($1_SJAVAC) \ |
502 $$($1_REMOTE) $$($1_SJAVAC_ARGS) --permit-unidentified-artifacts -mfl $$($1_BIN)/_the.batch.tmp \ |
490 $$($1_REMOTE) $$($1_SJAVAC_ARGS) \ |
|
491 --permit-unidentified-artifacts \ |
|
492 --permit-sources-without-package \ |
|
493 --compare-found-sources $$($1_BIN)/_the.batch.tmp \ |
503 $$($1_FLAGS) \ |
494 $$($1_FLAGS) \ |
504 -implicit:none -d $$($1_BIN) $$($1_HEADERS_ARG) |
495 -implicit:none -d $$($1_BIN) $$($1_HEADERS_ARG) |
505 else |
496 else |
506 # Using plain javac to batch compile everything. |
497 # Using plain javac to batch compile everything. |
507 $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.batch |
498 $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.batch |
|
499 |
|
500 # When buliding in batch, put headers in a temp dir to filter out those that actually |
|
501 # changed before copying them to the real header dir. |
|
502 ifneq (,$$($1_HEADERS)) |
|
503 $1_HEADERS_ARG := -h $$($1_HEADERS).tmp |
|
504 |
|
505 $$($1_HEADERS)/_the.headers: $$($1_BIN)/_the.batch |
|
506 $(MKDIR) -p $$(@D) |
|
507 for f in `ls $$($1_HEADERS).tmp`; do \ |
|
508 if [ ! -f "$$($1_HEADERS)/$$$$f" ] || [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).tmp/$$$$f`" != "" ]; then \ |
|
509 $(CP) -f $$($1_HEADERS).tmp/$$$$f $$($1_HEADERS)/$$$$f; \ |
|
510 fi; \ |
|
511 done |
|
512 $(RM) -r $$($1_HEADERS).tmp |
|
513 $(TOUCH) $$@ |
|
514 |
|
515 $1 += $$($1_HEADERS)/_the.headers |
|
516 endif |
508 |
517 |
509 # When not using sjavac, pass along all sources to javac using an @file. |
518 # When not using sjavac, pass along all sources to javac using an @file. |
510 $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS) |
519 $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS) |
511 $(MKDIR) -p $$(@D) |
520 $(MKDIR) -p $$(@D) |
512 $(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp |
521 $(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp |