268 else |
268 else |
269 $1_JAR_CREATE_OPTIONS := cfm |
269 $1_JAR_CREATE_OPTIONS := cfm |
270 $1_JAR_UPDATE_OPTIONS := uf |
270 $1_JAR_UPDATE_OPTIONS := uf |
271 endif |
271 endif |
272 |
272 |
|
273 # Include all variables of significance in the vardeps file |
|
274 $1_VARDEPS := $(JAR) $$($1_JAR_CREATE_OPTIONS) $$($1_MANIFEST) $(RELEASE) $(COMPANY_NAME) \ |
|
275 $$($1_JARMAIN) $$($1_EXTRA_MANIFEST_ATTR) |
|
276 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$(dir $$($1_JAR))_the.$$($1_JARNAME).vardeps) |
|
277 |
273 # Here is the rule that creates/updates the jar file. |
278 # Here is the rule that creates/updates the jar file. |
274 $$($1_JAR) : $$($1_DEPS) |
279 $$($1_JAR) : $$($1_DEPS) $$($1_MANIFEST) $$($1_VARDEPS_FILE) |
275 $(MKDIR) -p $$($1_BIN) |
280 $(MKDIR) -p $$($1_BIN) |
276 $$($1_GREP_INCLUDE_OUTPUT) |
281 $$($1_GREP_INCLUDE_OUTPUT) |
277 $$($1_GREP_EXCLUDE_OUTPUT) |
282 $$($1_GREP_EXCLUDE_OUTPUT) |
278 $$(if $$($1_MANIFEST), \ |
283 # If the vardeps file is part of the newer prereq list, it means that |
279 $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ |
284 # either the jar file does not exist, or we need to recreate it from |
280 -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $$($1_MANIFEST) > $$($1_MANIFEST_FILE) \ |
285 # from scratch anyway since a simple update will not catch all the |
|
286 # potential changes. |
|
287 $$(if $$(filter $$($1_VARDEPS_FILE) $$($1_MANIFEST), $$?), \ |
|
288 $$(if $$($1_MANIFEST), \ |
|
289 $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ |
|
290 -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $$($1_MANIFEST) > $$($1_MANIFEST_FILE) $$(NEWLINE) \ |
|
291 , \ |
|
292 $(RM) $$($1_MANIFEST_FILE) && $(TOUCH) $$($1_MANIFEST_FILE) $$(NEWLINE)) \ |
|
293 $$(if $$($1_JARMAIN), \ |
|
294 $(ECHO) "Main-Class: $$(strip $$($1_JARMAIN))" >> $$($1_MANIFEST_FILE) $$(NEWLINE)) \ |
|
295 $$(if $$($1_EXTRA_MANIFEST_ATTR), \ |
|
296 $(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE) $$(NEWLINE)) \ |
|
297 $(ECHO) Creating $$($1_NAME) $$(NEWLINE) \ |
|
298 $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \ |
|
299 $$($1_SCAPTURE_CONTENTS) \ |
|
300 $$($1_SCAPTURE_METAINF) \ |
|
301 $$($1_SUPDATE_CONTENTS) \ |
|
302 $$($1_JARINDEX) && true \ |
281 , \ |
303 , \ |
282 $(RM) $$($1_MANIFEST_FILE) && $(TOUCH) $$($1_MANIFEST_FILE)) |
|
283 $$(if $$($1_JARMAIN),$(ECHO) "Main-Class: $$(strip $$($1_JARMAIN))" >> $$($1_MANIFEST_FILE)) |
|
284 $$(if $$($1_EXTRA_MANIFEST_ATTR),$(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE)) |
|
285 $$(if $$(wildcard $$@), \ |
|
286 $(ECHO) Modifying $$($1_NAME) $$(NEWLINE) \ |
304 $(ECHO) Modifying $$($1_NAME) $$(NEWLINE) \ |
287 $$($1_CAPTURE_CONTENTS) \ |
305 $$($1_CAPTURE_CONTENTS) \ |
288 $$($1_CAPTURE_METAINF) \ |
306 $$($1_CAPTURE_METAINF) \ |
289 $(RM) $$($1_DELETES_FILE) $$(NEWLINE) \ |
307 $(RM) $$($1_DELETES_FILE) $$(NEWLINE) \ |
290 $$($1_CAPTURE_DELETES) \ |
308 $$($1_CAPTURE_DELETES) \ |
292 if [ -s $$($1_DELETESS_FILE) ]; then \ |
310 if [ -s $$($1_DELETESS_FILE) ]; then \ |
293 $(ECHO) " deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \ |
311 $(ECHO) " deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \ |
294 $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \ |
312 $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \ |
295 fi $$(NEWLINE) \ |
313 fi $$(NEWLINE) \ |
296 $$($1_UPDATE_CONTENTS) true $$(NEWLINE) \ |
314 $$($1_UPDATE_CONTENTS) true $$(NEWLINE) \ |
297 $$($1_JARINDEX) && true \ |
|
298 , \ |
|
299 $(ECHO) Creating $$($1_NAME) && $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \ |
|
300 $$($1_SCAPTURE_CONTENTS) \ |
|
301 $$($1_SCAPTURE_METAINF) \ |
|
302 $$($1_SUPDATE_CONTENTS) \ |
|
303 $$($1_JARINDEX) && true ) |
315 $$($1_JARINDEX) && true ) |
304 |
316 |
305 # Add jar to target list |
317 # Add jar to target list |
306 $1 += $$($1_JAR) |
318 $1 += $$($1_JAR) |
307 endef |
319 endef |
429 |
441 |
430 # Handle addons and overrides. |
442 # Handle addons and overrides. |
431 $1_SRC:=$$(call ADD_SRCS,$$($1_SRC)) |
443 $1_SRC:=$$(call ADD_SRCS,$$($1_SRC)) |
432 # Make sure the dirs exist. |
444 # Make sure the dirs exist. |
433 $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory $$d))) |
445 $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory $$d))) |
434 $$(eval $$(call MakeDir,$$($1_BIN))) |
446 $$(call MakeDir,$$($1_BIN)) |
435 # Add all source roots to the find cache since we are likely going to run find |
447 # Add all source roots to the find cache since we are likely going to run find |
436 # on these more than once. The cache will only be updated if necessary. |
448 # on these more than once. The cache will only be updated if necessary. |
437 $$(eval $$(call FillCacheFind,$$($1_SRC))) |
449 $$(eval $$(call FillCacheFind,$$($1_SRC))) |
438 # Find all files in the source trees. Preserve order of source roots for overrides to |
450 # Find all files in the source trees. Preserve order of source roots for overrides to |
439 # work correctly. CacheFind does not preserve order so need to call it for each root. |
451 # work correctly. CacheFind does not preserve order so need to call it for each root. |
533 # "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main" |
545 # "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main" |
534 # and javac is simply replaced with sjavac. |
546 # and javac is simply replaced with sjavac. |
535 $1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC)) |
547 $1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC)) |
536 |
548 |
537 # Set the $1_REMOTE to spawn a background javac server. |
549 # Set the $1_REMOTE to spawn a background javac server. |
538 $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC)))) |
550 $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst \ |
539 |
551 $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC)))) |
540 $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) |
552 |
|
553 $1_VARDEPS := $$($1_JVM) $$($1_SJAVAC) $$($1_SJAVAC_ARGS) $$($1_FLAGS) \ |
|
554 $$($1_HEADERS_ARG) $$($1_BIN) |
|
555 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps) |
|
556 |
|
557 $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE) |
541 $(MKDIR) -p $$(@D) $$(dir $$($1_SJAVAC_PORTFILE)) |
558 $(MKDIR) -p $$(@D) $$(dir $$($1_SJAVAC_PORTFILE)) |
542 # As a workaround for sjavac not tracking api changed from the classpath, force full |
559 # As a workaround for sjavac not tracking api changed from the classpath, force full |
543 # recompile if an external dependency, which is something other than a source |
560 # recompile if an external dependency, which is something other than a source |
544 # change, triggered this compilation. |
561 # change, triggered this compilation. |
545 $$(if $$(filter-out $$($1_SRCS), $$?), $(FIND) $$(@D) -name "*.class" $(FIND_DELETE)) |
562 $$(if $$(filter-out $$($1_SRCS), $$?), $(FIND) $$(@D) -name "*.class" $(FIND_DELETE)) |
590 $(TOUCH) $$@ |
607 $(TOUCH) $$@ |
591 |
608 |
592 $1_HEADER_TARGETS := $$($1_HEADERS)/_the.$1_headers |
609 $1_HEADER_TARGETS := $$($1_HEADERS)/_the.$1_headers |
593 endif |
610 endif |
594 |
611 |
|
612 $1_VARDEPS := $$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) $$($1_BIN) $$($1_HEADERS_ARG) |
|
613 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps) |
|
614 |
595 # When not using sjavac, pass along all sources to javac using an @file. |
615 # When not using sjavac, pass along all sources to javac using an @file. |
596 $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) |
616 $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE) |
597 $(MKDIR) -p $$(@D) |
617 $(MKDIR) -p $$(@D) |
598 $(RM) $$($1_BIN)/_the.$1_batch $$($1_BIN)/_the.$1_batch.tmp |
618 $(RM) $$($1_BIN)/_the.$1_batch $$($1_BIN)/_the.$1_batch.tmp |
599 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp) |
619 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp) |
600 $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.$1_batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1 |
620 $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.$1_batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1 |
601 ($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \ |
621 ($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \ |