< prev index next >
make/common/JavaCompilation.gmk
Print this page
*** 319,330 ****
$2_TARGET:=$2
# Remove the source prefix.
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
# To allow for automatic overrides, do not create a rule for a target file that
# already has one
! ifeq ($$(findstring $$($2_TARGET), $$($1_COPY_LIST)), )
! $1_COPY_LIST += $$($2_TARGET)
# Now we can setup the depency that will trigger the copying.
$$($1_BIN)$$($2_TARGET) : $2
$(MKDIR) -p $$(@D)
$(CP) $$< $$@
$(CHMOD) -f ug+w $$@
--- 319,330 ----
$2_TARGET:=$2
# Remove the source prefix.
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
# To allow for automatic overrides, do not create a rule for a target file that
# already has one
! ifneq ($$($1_COPY_$$($2_TARGET)), 1)
! $1_COPY_$$($2_TARGET) := 1
# Now we can setup the depency that will trigger the copying.
$$($1_BIN)$$($2_TARGET) : $2
$(MKDIR) -p $$(@D)
$(CP) $$< $$@
$(CHMOD) -f ug+w $$@
*** 363,373 ****
# parma 2 = The source file to copy and clean.
$2_TARGET:=$2
# Remove the source prefix.
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
# Now we can setup the depency that will trigger the copying.
! $$($1_BIN)$$($2_TARGET) : $2
$(MKDIR) -p $$(@D)
export LC_ALL=C ; ( $(CAT) $$< && $(ECHO) "" ) \
| $(SED) -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' \
-e 's/\([^\\]\)!/\1\\!/g' -e 's/^[ ]*#.*/#/g' \
| $(SED) -f "$(SRC_ROOT)/make/common/support/unicode2x.sed" \
--- 363,377 ----
# parma 2 = The source file to copy and clean.
$2_TARGET:=$2
# Remove the source prefix.
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
# Now we can setup the depency that will trigger the copying.
! # To allow for automatic overrides, do not create a rule for a target file that
! # already has one
! ifneq ($$($1_CLEAN_$$($2_TARGET)), 1)
! $1_CLEAN_$$($2_TARGET) := 1
! $$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET) : $2
$(MKDIR) -p $$(@D)
export LC_ALL=C ; ( $(CAT) $$< && $(ECHO) "" ) \
| $(SED) -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' \
-e 's/\([^\\]\)!/\1\\!/g' -e 's/^[ ]*#.*/#/g' \
| $(SED) -f "$(SRC_ROOT)/make/common/support/unicode2x.sed" \
*** 378,387 ****
--- 382,392 ----
| $(SORT) > $$@
$(CHMOD) -f ug+w $$@
# And do not forget this target
$1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($2_TARGET)
+ endif
endef
define remove_string
$2 := $$(subst $1,,$$($2))
endef
*** 394,404 ****
#
# Remaining parameters are named arguments. These include:
# SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC
# JVM:=path to ..bin/java
# ADD_JAVAC_FLAGS:=javac flags to append to the default ones.
! # SRC:=one or more directories to search for sources
# BIN:=store classes here
# INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
# EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
# COPY:=.prp means copy all prp files to the corresponding package in BIN.
# COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo
--- 399,410 ----
#
# Remaining parameters are named arguments. These include:
# SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC
# JVM:=path to ..bin/java
# ADD_JAVAC_FLAGS:=javac flags to append to the default ones.
! # SRC:=one or more directories to search for sources. The order of the source roots
! # is significant. The first found file of a certain name has priority.
# BIN:=store classes here
# INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
# EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
# COPY:=.prp means copy all prp files to the corresponding package in BIN.
# COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo
*** 430,440 ****
$1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM)
# Handle addons and overrides.
$1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
# Make sure the dirs exist.
! $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory $$d)))
$$(call MakeDir,$$($1_BIN))
# 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_SRC)))
# Find all files in the source trees. Preserve order of source roots for overrides to
--- 436,446 ----
$1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM)
# Handle addons and overrides.
$1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
# Make sure the dirs exist.
! $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<)))
$$(call MakeDir,$$($1_BIN))
# 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_SRC)))
# Find all files in the source trees. Preserve order of source roots for overrides to
*** 448,476 ****
ifneq ($$($1_INCLUDE_FILES),)
$1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
$1_SRCS := $$(filter $$($1_INCLUDE_FILES), $$($1_SRCS))
endif
- # Now we have a list of all java files to compile: $$($1_SRCS)
-
- # Create the corresponding smart javac wrapper command line.
- $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix /*,$$($1_EXCLUDES))) \
- $$(addprefix -i ,$$(addsuffix /*,$$($1_INCLUDES))) \
- $$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES))) \
- $$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \
- -src "$$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))"
-
# Prepend the source/bin path to the filter expressions.
ifneq ($$($1_INCLUDES),)
$1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
$1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
endif
ifneq ($$($1_EXCLUDES),)
$1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
$1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
endif
# All files below META-INF are always copied.
$1_ALL_COPIES := $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS))
# Find all files to be copied from source to bin.
ifneq (,$$($1_COPY)$$($1_COPY_FILES))
# Search for all files to be copied.
--- 454,492 ----
ifneq ($$($1_INCLUDE_FILES),)
$1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
$1_SRCS := $$(filter $$($1_INCLUDE_FILES), $$($1_SRCS))
endif
# Prepend the source/bin path to the filter expressions.
ifneq ($$($1_INCLUDES),)
$1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
$1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
endif
ifneq ($$($1_EXCLUDES),)
$1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
$1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
endif
+ # Remove duplicate source files by keeping the first found of each duplicate.
+ # This allows for automatic overrides with custom or platform specific versions
+ # source files.
+ #
+ # For the smart javac wrapper case, add each removed file to an extra exclude
+ # file list to prevent sjavac from finding duplicate sources.
+ $1_SRCS := $$(strip $$(foreach s, $$($1_SRCS), \
+ $$(eval relative_src := $$(call remove-prefixes, $$($1_SRC), $$(s))) \
+ $$(if $$($1_$$(relative_src)), \
+ $$(eval $1_SJAVAC_EXCLUDE_FILES += $$(s)), \
+ $$(eval $1_$$(relative_src) := 1) $$(s))))
+
+ # Create the corresponding smart javac wrapper command line.
+ $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix /*,$$($1_EXCLUDES))) \
+ $$(addprefix -i ,$$(addsuffix /*,$$($1_INCLUDES))) \
+ $$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES) $$($1_SJAVAC_EXCLUDE_FILES))) \
+ $$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \
+ -src "$$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))"
+
# All files below META-INF are always copied.
$1_ALL_COPIES := $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS))
# Find all files to be copied from source to bin.
ifneq (,$$($1_COPY)$$($1_COPY_FILES))
# Search for all files to be copied.
< prev index next >