make/common/JavaCompilation.gmk
changeset 33055 3676b99f33cf
parent 32807 20386e6d858f
child 33437 1cf150337073
equal deleted inserted replaced
33054:bcb9f5ea5761 33055:3676b99f33cf
    57 #   JVM:=The jvm used to run the javac/javah command
    57 #   JVM:=The jvm used to run the javac/javah command
    58 #   JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out
    58 #   JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out
    59 #   FLAGS:=Flags to be supplied to javac
    59 #   FLAGS:=Flags to be supplied to javac
    60 #   SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here
    60 #   SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here
    61 #   SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above.
    61 #   SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above.
       
    62 #   DISABLE_SJAVAC:=Set to true if this setup does not support sjavac
    62 SetupJavaCompiler = $(NamedParamsMacroTemplate)
    63 SetupJavaCompiler = $(NamedParamsMacroTemplate)
    63 define SetupJavaCompilerBody
    64 define SetupJavaCompilerBody
    64   # The port file contains the tcp/ip on which the server listens
    65   # The port file contains the tcp/ip on which the server listens
    65   # and the cookie necessary to talk to the server.
    66   # and the cookie necessary to talk to the server.
    66   $1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port
    67   $1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port
   437   ifeq ($$($1_JAVAC),)
   438   ifeq ($$($1_JAVAC),)
   438     $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
   439     $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
   439   endif
   440   endif
   440   $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE)
   441   $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE)
   441   $1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM)
   442   $1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM)
       
   443   $1_DISABLE_SJAVAC := $$($$($1_SETUP)_DISABLE_SJAVAC)
   442 
   444 
   443   # Handle addons and overrides.
   445   # Handle addons and overrides.
   444   $1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
   446   $1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
   445   # Make sure the dirs exist.
   447   # Make sure the dirs exist.
   446   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<)))
   448   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<)))
   550 
   552 
   551   # Create a sed expression to remove the source roots and to replace / with .
   553   # Create a sed expression to remove the source roots and to replace / with .
   552   # and remove .java at the end.
   554   # and remove .java at the end.
   553   $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
   555   $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
   554 
   556 
       
   557   # Create SJAVAC variable from JAVAC variable. Expects $1_JAVAC to be
       
   558   # "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main"
       
   559   # and javac is simply replaced with sjavac.
       
   560   $1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC))
       
   561 
       
   562   # Set the $1_REMOTE to spawn a background javac server.
       
   563   $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst \
       
   564       $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC))))
       
   565 
   555   ifeq ($$($1_DISABLE_SJAVAC)x$$(ENABLE_SJAVAC),xyes)
   566   ifeq ($$($1_DISABLE_SJAVAC)x$$(ENABLE_SJAVAC),xyes)
   556     ifneq (,$$($1_HEADERS))
   567     ifneq (,$$($1_HEADERS))
   557       $1_HEADERS_ARG := -h $$($1_HEADERS)
   568       $1_HEADERS_ARG := -h $$($1_HEADERS)
   558     endif
   569     endif
   559 
   570 
   560     # Using sjavac to compile.
   571     # Using sjavac to compile.
   561     $1_COMPILE_TARGETS := $$($1_BIN)/_the.$1_batch
   572     $1_COMPILE_TARGETS := $$($1_BIN)/_the.$1_batch
   562 
       
   563     # Create SJAVAC variable form JAVAC variable. Expects $1_JAVAC to be
       
   564     # "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main"
       
   565     # and javac is simply replaced with sjavac.
       
   566     $1_SJAVAC:=$$(subst com.sun.tools.javac.Main,com.sun.tools.sjavac.Main,$$($1_JAVAC))
       
   567 
       
   568     # Set the $1_REMOTE to spawn a background javac server.
       
   569     $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst \
       
   570         $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC))))
       
   571 
   573 
   572     $1_VARDEPS := $$($1_JVM) $$($1_SJAVAC) $$($1_SJAVAC_ARGS) $$($1_FLAGS) \
   574     $1_VARDEPS := $$($1_JVM) $$($1_SJAVAC) $$($1_SJAVAC_ARGS) $$($1_FLAGS) \
   573         $$($1_HEADERS_ARG) $$($1_BIN) $$($1_EXCLUDES) $$($1_INCLUDES) \
   575         $$($1_HEADERS_ARG) $$($1_BIN) $$($1_EXCLUDES) $$($1_INCLUDES) \
   574         $$($1_EXCLUDE_FILES) $$($1_INCLUDE_FILES)
   576         $$($1_EXCLUDE_FILES) $$($1_INCLUDE_FILES)
   575     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps)
   577     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps)
   630     $1_VARDEPS := $$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) $$($1_BIN) \
   632     $1_VARDEPS := $$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) $$($1_BIN) \
   631         $$($1_HEADERS_ARG) $$($1_EXCLUDES) $$($1_INCLUDES) \
   633         $$($1_HEADERS_ARG) $$($1_EXCLUDES) $$($1_INCLUDES) \
   632         $$($1_EXCLUDE_FILES) $$($1_INCLUDE_FILES)
   634         $$($1_EXCLUDE_FILES) $$($1_INCLUDE_FILES)
   633     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps)
   635     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps)
   634 
   636 
       
   637     ifeq ($$($1_DISABLE_SJAVAC)x$(ENABLE_JAVAC_SERVER), xyes)
       
   638       $1_JAVAC_CMD := $$($1_SJAVAC) $$($1_REMOTE)
       
   639     else
       
   640       $1_JAVAC_CMD := $$($1_JAVAC)
       
   641     endif
       
   642 
   635     # When not using sjavac, pass along all sources to javac using an @file.
   643     # When not using sjavac, pass along all sources to javac using an @file.
   636     $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE)
   644     $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE)
   637 	$(MKDIR) -p $$(@D)
   645 	$(MKDIR) -p $$(@D)
   638 	$$(eval $$(call ListPathsSafely,$1_SRCS, $$($1_BIN)/_the.$1_batch.tmp))
   646 	$$(eval $$(call ListPathsSafely,$1_SRCS, $$($1_BIN)/_the.$1_batch.tmp))
   639 	$(ECHO) Compiling `$(WC) $$($1_BIN)/_the.$1_batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1
   647 	$(ECHO) Compiling `$(WC) $$($1_BIN)/_the.$1_batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1
   640 	$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch.log, $$($1_SAFE_NAME), \
   648 	$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch.log, $$($1_SAFE_NAME), \
   641 	    $$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \
   649 	    $$($1_JVM) $$($1_JAVAC_CMD) $$($1_FLAGS) \
   642 	        -implicit:none \
   650 	        -implicit:none \
   643 	        -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.$1_batch.tmp) && \
   651 	        -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.$1_batch.tmp) && \
   644 	$(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch
   652 	$(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch
   645   endif
   653   endif
   646 
   654