< prev index next >
make/common/JavaCompilation.gmk
Print this page
@@ -57,20 +57,12 @@
# JVM:=The jvm used to run the javac/javah command
# JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out
# FLAGS:=Flags to be supplied to javac
# SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here
# SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above.
-define SetupJavaCompiler
- $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk))
- $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilerInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)))
-endef
-
-define SetupJavaCompilerInner
- $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE))
- $(call LogSetupMacroEntry,SetupJavaCompiler($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
- $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk))
-
+SetupJavaCompiler = $(NamedParamsMacroTemplate)
+define SetupJavaCompilerBody
# The port file contains the tcp/ip on which the server listens
# and the cookie necessary to talk to the server.
$1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port
# You can use a different JVM to run the background javac server.
ifeq ($$($1_SERVER_JVM),)
@@ -82,14 +74,15 @@
# Setup make rules for creating a jar archive.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
-# Parameter 2 is a list of dependencies for the jar target. If left empty,
-# dependencies are searched using SRCS, which should not be empty.
-#
# Remaining parameters are named arguments. These include:
+# DEPENDENCIES:=List of dependencies for the jar target. If left empty,
+# dependencies are calculated automatically from the source files found.
+# For this to work, the source files must exist when the makefile is
+# parsed.
# SRCS:=List of directories in where to find files to add to archive
# SUFFIXES:=File suffixes to include in jar
# INCLUDES:=List of directories/packages in SRCS that should be included
# EXCLUDES:=List of directories/packages in SRCS that should be excluded
# EXCLUDE_FILES:=List of files in SRCS that should be excluded
@@ -100,21 +93,12 @@
# JARINDEX:=true means generate the index in the jar file.
# SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically
# added to the archive.
# EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest.
# CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable
-define SetupArchive
- $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk))
- $(call EvalDebugWrapper,$(strip $1),$(call SetupArchiveInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)))
-endef
-
-define SetupArchiveInner
- # NOTE: $2 is dependencies, not a named argument!
- $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE))
- $(call LogSetupMacroEntry,SetupArchive($1),<dependencies>,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
- $(if $(findstring $(LOG_LEVEL),trace), $(info *[2] <dependencies> = $(strip $2)))
- $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk))
+SetupArchive = $(NamedParamsMacroTemplate)
+define SetupArchiveBody
$1_JARMAIN:=$(strip $$($1_JARMAIN))
$1_JARNAME:=$$(notdir $$($1_JAR))
$1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest
$1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess
@@ -169,33 +153,31 @@
$1_JARINDEX = true
endif
# When this macro is run in the same makefile as the java compilation, dependencies are
# transfered in make variables. When the macro is run in a different makefile than the
# java compilation, the dependencies need to be found in the filesystem.
- ifneq (,$2)
- $1_DEPS:=$2
- else
+ ifeq ($$($1_DEPENDENCIES), )
# Add all source roots to the find cache since we are likely going to run find
# on these more than once. The cache will only be updated if necessary.
$$(eval $$(call FillCacheFind, $$($1_FIND_LIST)))
- $1_DEPS:=$$(filter $$(addprefix %,$$($1_SUFFIXES)), \
+ $1_DEPENDENCIES:=$$(filter $$(addprefix %,$$($1_SUFFIXES)), \
$$(call CacheFind,$$($1_SRCS)))
ifneq (,$$($1_GREP_INCLUDE_PATTERNS))
- $1_DEPS:=$$(filter $$(addsuffix %,$$($1_GREP_INCLUDE_PATTERNS)),$$($1_DEPS))
+ $1_DEPENDENCIES:=$$(filter $$(addsuffix %,$$($1_GREP_INCLUDE_PATTERNS)),$$($1_DEPENDENCIES))
endif
ifneq (,$$($1_GREP_EXCLUDE_PATTERNS))
- $1_DEPS:=$$(filter-out $$(addsuffix %,$$($1_GREP_EXCLUDE_PATTERNS)),$$($1_DEPS))
+ $1_DEPENDENCIES:=$$(filter-out $$(addsuffix %,$$($1_GREP_EXCLUDE_PATTERNS)),$$($1_DEPENDENCIES))
endif
# Look for EXTRA_FILES in all SRCS dirs and as absolute paths.
- $1_DEPS+=$$(wildcard $$(foreach src, $$($1_SRCS), \
+ $1_DEPENDENCIES+=$$(wildcard $$(foreach src, $$($1_SRCS), \
$$(addprefix $$(src)/, $$($1_EXTRA_FILES))) $$($1_EXTRA_FILES))
ifeq (,$$($1_SKIP_METAINF))
- $1_DEPS+=$$(call CacheFind,$$(wildcard $$(addsuffix /META-INF,$$($1_SRCS))))
+ $1_DEPENDENCIES+=$$(call CacheFind,$$(wildcard $$(addsuffix /META-INF,$$($1_SRCS))))
endif
endif
# The dependency list should never be empty
- ifeq ($$(strip $$($1_DEPS)), )
+ ifeq ($$(strip $$($1_DEPENDENCIES)), )
$$(warning No dependencies found for $1)
endif
# Utility macros, to make the shell script receipt somewhat easier to decipher.
@@ -286,11 +268,11 @@
$1_VARDEPS := $(JAR) $$($1_JAR_CREATE_OPTIONS) $$($1_MANIFEST) $(RELEASE) $(COMPANY_NAME) \
$$($1_JARMAIN) $$($1_EXTRA_MANIFEST_ATTR)
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$(dir $$($1_JAR))_the.$$($1_JARNAME).vardeps)
# Here is the rule that creates/updates the jar file.
- $$($1_JAR) : $$($1_DEPS) $$($1_MANIFEST) $$($1_VARDEPS_FILE)
+ $$($1_JAR) : $$($1_DEPENDENCIES) $$($1_MANIFEST) $$($1_VARDEPS_FILE)
$(MKDIR) -p $$($1_BIN)
$$($1_GREP_INCLUDE_OUTPUT)
$$($1_GREP_EXCLUDE_OUTPUT)
# If the vardeps file is part of the newer prereq list, it means that
# either the jar file does not exist, or we need to recreate it from
@@ -427,19 +409,12 @@
# EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
# "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
# HEADERS:=path to directory where all generated c-headers are written.
# DEPENDS:=Extra dependecy
# DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit.
-define SetupJavaCompilation
- $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))
- $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilationInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)))
-endef
-
-define SetupJavaCompilationInner
- $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE))
- $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
- $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))
+SetupJavaCompilation = $(NamedParamsMacroTemplate)
+define SetupJavaCompilationBody
# Verify arguments
ifeq ($$($1_BIN),)
$$(error Must specify BIN (in $1))
endif
@@ -651,11 +626,12 @@
# for the types of files to be put into the jar.
ifeq (,$$($1_SUFFIXES))
$1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
endif
- $$(eval $$(call SetupArchive,ARCHIVE_$1,$$($1), \
+ $$(eval $$(call SetupArchive,ARCHIVE_$1, \
+ DEPENDENCIES:=$$($1), \
SRCS:=$$($1_BIN), \
SUFFIXES:=$$($1_SUFFIXES), \
EXCLUDE:=$$($1_EXCLUDES), \
INCLUDES:=$$($1_INCLUDES), \
EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS), \
< prev index next >