make/common/JavaCompilation.gmk
Print this page
*** 562,583 ****
ifneq (,$$($1_HEADERS))
$1_HEADERS_ARG := -h $$($1_HEADERS)
endif
# Using sjavac to compile.
! $1_COMPILE_TARGETS := $$($1_BIN)/javac_state
# Create SJAVAC variable form JAVAC variable. Expects $1_JAVAC to be
# "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main"
# and javac is simply replaced with sjavac.
$1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC))
# Set the $1_REMOTE to spawn a background javac server.
$1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC))))
! $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS)
$(MKDIR) -p $$(@D)
$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp)
$(ECHO) Compiling $1
($$($1_JVM) $$($1_SJAVAC) \
$$($1_REMOTE) \
-j 1 \
--- 562,587 ----
ifneq (,$$($1_HEADERS))
$1_HEADERS_ARG := -h $$($1_HEADERS)
endif
# Using sjavac to compile.
! $1_COMPILE_TARGETS := $$($1_BIN)/_the.$1_batch
# Create SJAVAC variable form JAVAC variable. Expects $1_JAVAC to be
# "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main"
# and javac is simply replaced with sjavac.
$1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC))
# Set the $1_REMOTE to spawn a background javac server.
$1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC))))
! $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS)
$(MKDIR) -p $$(@D)
+ # As a workaround for sjavac not tracking api from the classpath, force full
+ # recompile if an external dependency, which is something other than a source
+ # change, triggered this compilation.
+ $$(if $$(filter-out $$($1_SRCS), $$?), $(FIND) $$(@D) -name "*.class" $(FIND_DELETE))
$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp)
$(ECHO) Compiling $1
($$($1_JVM) $$($1_SJAVAC) \
$$($1_REMOTE) \
-j 1 \
*** 588,599 ****
$$($1_SJAVAC_ARGS) \
$$($1_FLAGS) \
$$($1_HEADERS_ARG) \
-d $$($1_BIN) && \
$(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch)
! # sjavac doesn't touch this if nothing has changed
! $(TOUCH) $$@
else
# Using plain javac to batch compile everything.
$1_COMPILE_TARGETS := $$($1_BIN)/_the.$1_batch
# When building in batch, put headers in a temp dir to filter out those that actually
--- 592,611 ----
$$($1_SJAVAC_ARGS) \
$$($1_FLAGS) \
$$($1_HEADERS_ARG) \
-d $$($1_BIN) && \
$(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch)
! # Create a pubapi file that only changes when the pubapi changes. Dependent
! # compilations can use this file to only get recompiled when pubapi has changed.
! # Grep returns 1 if no matching lines are found. Do not fail for this.
! $(GREP) -e "^I" $$($1_BIN)/javac_state > $$($1_BIN)/_the.$1_pubapi.tmp \
! || test "$$$$?" = "1"
! if [ ! -f $$($1_BIN)/_the.$1_pubapi ] \
! || [ "`$(DIFF) $$($1_BIN)/_the.$1_pubapi $$($1_BIN)/_the.$1_pubapi.tmp`" != "" ]; then \
! $(MV) $$($1_BIN)/_the.$1_pubapi.tmp $$($1_BIN)/_the.$1_pubapi; \
! fi
!
else
# Using plain javac to batch compile everything.
$1_COMPILE_TARGETS := $$($1_BIN)/_the.$1_batch
# When building in batch, put headers in a temp dir to filter out those that actually
*** 679,687 ****
# SetupJavaCompilation is declared in a different makefile, to avoid having
# to declare and evaluate it again.
# param 1 is for example BUILD_MYPACKAGE
# param 2 is the output directory (BIN)
define SetupJavaCompilationCompileTarget
! $(if $(findsring yes, $(ENABLE_SJAVAC)), $(strip $2)/javac_state, \
$(strip $2)/_the.$(strip $1)_batch)
endef
endif
--- 691,699 ----
# SetupJavaCompilation is declared in a different makefile, to avoid having
# to declare and evaluate it again.
# param 1 is for example BUILD_MYPACKAGE
# param 2 is the output directory (BIN)
define SetupJavaCompilationCompileTarget
! $(if $(findstring yes, $(ENABLE_SJAVAC)), $(strip $2)/_the.$(strip $1)_pubapi, \
$(strip $2)/_the.$(strip $1)_batch)
endef
endif