common/makefiles/JavaCompilation.gmk

Print this page




 485     $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
 486 
 487     ifeq ($$($1_DISABLE_SJAVAC)x$$(ENABLE_SJAVAC),xyes)
 488         ifneq (,$$($1_HEADERS))
 489             $1_HEADERS_ARG := -h $$($1_HEADERS)
 490         endif
 491 
 492         # Using sjavac to compile. 
 493         $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/javac_state
 494 
 495         # Create SJAVAC variable form JAVAC variable. Expects $1_JAVAC to be 
 496         # "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main"
 497         # and javac is simply replaced with sjavac.
 498         $1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC))
 499 
 500         # Set the $1_REMOTE to spawn a background javac server.
 501         $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC))))
 502 
 503         $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS)
 504                 $(MKDIR) -p $$(@D)
 505                 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
 506                 $(ECHO) Compiling $1
 507                 ($$($1_JVM) $$($1_SJAVAC) \
 508                         $$($1_REMOTE) \
 509                         -j $(JOBS) \
 510                         --permit-unidentified-artifacts \
 511                         --permit-sources-without-package \
 512                         --compare-found-sources $$($1_BIN)/_the.batch.tmp \
 513                         --log=$(LOG_LEVEL) \
 514                         $$($1_SJAVAC_ARGS) \
 515                         $$($1_FLAGS) \
 516                         $$($1_HEADERS_ARG) \
 517                         -d $$($1_BIN) && \
 518                         $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
 519     else
 520         # Using plain javac to batch compile everything.
 521         $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.batch
 522 
 523         # When buliding in batch, put headers in a temp dir to filter out those that actually
 524         # changed before copying them to the real header dir.
 525         ifneq (,$$($1_HEADERS))
 526             $1_HEADERS_ARG := -h $$($1_HEADERS).tmp
 527 
 528             $$($1_HEADERS)/_the.headers: $$($1_BIN)/_the.batch
 529                 $(MKDIR) -p $$(@D)
 530                 for f in `ls $$($1_HEADERS).tmp`; do \
 531                   if [ ! -f "$$($1_HEADERS)/$$$$f" ] || [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).tmp/$$$$f`" != "" ]; then \
 532                     $(CP) -f $$($1_HEADERS).tmp/$$$$f $$($1_HEADERS)/$$$$f; \
 533                   fi; \
 534                 done
 535                 $(RM) -r $$($1_HEADERS).tmp
 536                 $(TOUCH) $$@
 537 
 538             $1 += $$($1_HEADERS)/_the.headers
 539         endif
 540 
 541         # When not using sjavac, pass along all sources to javac using an @file.
 542         $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS)
 543                 $(MKDIR) -p $$(@D)
 544                 $(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp
 545                 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
 546                 $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1
 547                 ($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \
 548                         -implicit:none -sourcepath "$$($1_SRCROOTSC)" \
 549                         -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.batch.tmp && \
 550                         $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
 551 
 552     endif
 553 
 554     # Check if a jar file was specified, then setup the rules for the jar.
 555     ifneq (,$$($1_JAR))
 556         # If no suffixes was explicitly set for this jar file.
 557         # Use class and the cleaned/copied properties file suffixes as the default
 558         # for the types of files to be put into the jar.
 559         ifeq (,$$($1_SUFFIXES))
 560             $1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
 561         endif
 562 
 563         $$(eval $$(call SetupArchive,ARCHIVE_$1,$$($1),\
 564                 SRCS:=$$($1_BIN),\
 565                 SUFFIXES:=$$($1_SUFFIXES),\
 566                 EXCLUDE:=$$($1_EXCLUDES),\
 567                 INCLUDES:=$$($1_INCLUDES),\
 568                 EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS),\
 569                 JAR:=$$($1_JAR),\
 570                 JARMAIN:=$$($1_JARMAIN),\


 485     $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
 486 
 487     ifeq ($$($1_DISABLE_SJAVAC)x$$(ENABLE_SJAVAC),xyes)
 488         ifneq (,$$($1_HEADERS))
 489             $1_HEADERS_ARG := -h $$($1_HEADERS)
 490         endif
 491 
 492         # Using sjavac to compile. 
 493         $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/javac_state
 494 
 495         # Create SJAVAC variable form JAVAC variable. Expects $1_JAVAC to be 
 496         # "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main"
 497         # and javac is simply replaced with sjavac.
 498         $1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC))
 499 
 500         # Set the $1_REMOTE to spawn a background javac server.
 501         $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC))))
 502 
 503         $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS)
 504                 $(MKDIR) -p $$(@D)
 505                 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp)
 506                 $(ECHO) Compiling $1
 507                 ($$($1_JVM) $$($1_SJAVAC) \
 508                         $$($1_REMOTE) \
 509                         -j $(JOBS) \
 510                         --permit-unidentified-artifacts \
 511                         --permit-sources-without-package \
 512                         --compare-found-sources $$($1_BIN)/_the.$1_batch.tmp \
 513                         --log=$(LOG_LEVEL) \
 514                         $$($1_SJAVAC_ARGS) \
 515                         $$($1_FLAGS) \
 516                         $$($1_HEADERS_ARG) \
 517                         -d $$($1_BIN) && \
 518                         $(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch)
 519     else
 520         # Using plain javac to batch compile everything.
 521         $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.$1_batch
 522 
 523         # When buliding in batch, put headers in a temp dir to filter out those that actually
 524         # changed before copying them to the real header dir.
 525         ifneq (,$$($1_HEADERS))
 526             $1_HEADERS_ARG := -h $$($1_HEADERS).tmp
 527 
 528             $$($1_HEADERS)/_the.$1_headers: $$($1_BIN)/_the.$1_batch
 529                 $(MKDIR) -p $$(@D)
 530                 for f in `ls $$($1_HEADERS).tmp`; do \
 531                   if [ ! -f "$$($1_HEADERS)/$$$$f" ] || [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).tmp/$$$$f`" != "" ]; then \
 532                     $(CP) -f $$($1_HEADERS).tmp/$$$$f $$($1_HEADERS)/$$$$f; \
 533                   fi; \
 534                 done
 535                 $(RM) -r $$($1_HEADERS).tmp
 536                 $(TOUCH) $$@
 537 
 538             $1 += $$($1_HEADERS)/_the.$1_headers
 539         endif
 540 
 541         # When not using sjavac, pass along all sources to javac using an @file.
 542         $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS)
 543                 $(MKDIR) -p $$(@D)
 544                 $(RM) $$($1_BIN)/_the.$1_batch $$($1_BIN)/_the.$1_batch.tmp
 545                 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp)
 546                 $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.$1_batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1
 547                 ($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \
 548                         -implicit:none -sourcepath "$$($1_SRCROOTSC)" \
 549                         -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.$1_batch.tmp && \
 550                         $(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch)
 551 
 552     endif
 553 
 554     # Check if a jar file was specified, then setup the rules for the jar.
 555     ifneq (,$$($1_JAR))
 556         # If no suffixes was explicitly set for this jar file.
 557         # Use class and the cleaned/copied properties file suffixes as the default
 558         # for the types of files to be put into the jar.
 559         ifeq (,$$($1_SUFFIXES))
 560             $1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
 561         endif
 562 
 563         $$(eval $$(call SetupArchive,ARCHIVE_$1,$$($1),\
 564                 SRCS:=$$($1_BIN),\
 565                 SUFFIXES:=$$($1_SUFFIXES),\
 566                 EXCLUDE:=$$($1_EXCLUDES),\
 567                 INCLUDES:=$$($1_INCLUDES),\
 568                 EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS),\
 569                 JAR:=$$($1_JAR),\
 570                 JARMAIN:=$$($1_JARMAIN),\