make/common/JavaCompilation.gmk
changeset 34921 ca6c7c325650
parent 34102 c0a98357f847
child 34924 9aaa30dd1b5d
equal deleted inserted replaced
34918:80f67512daa1 34921:ca6c7c325650
   200   # Find all files in the source trees. Preserve order of source roots so that
   200   # Find all files in the source trees. Preserve order of source roots so that
   201   # the first version in case of multiple instances of the same file is selected.
   201   # the first version in case of multiple instances of the same file is selected.
   202   # CacheFind does not preserve order so need to call it for each root.
   202   # CacheFind does not preserve order so need to call it for each root.
   203   $1_ALL_SRCS += $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s)))
   203   $1_ALL_SRCS += $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s)))
   204   # Extract the java files.
   204   # Extract the java files.
   205   ifneq ($$($1_EXCLUDE_FILES),)
   205   $1_SRCS := $$(filter %.java, $$($1_ALL_SRCS))
   206     $1_EXCLUDE_FILES_PATTERN:=$$(addprefix %,$$($1_EXCLUDE_FILES))
   206 
   207   endif
   207   # Translate include/exclude into patterns
   208   $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$(filter %.java,$$($1_ALL_SRCS)))
   208   ifneq ($$($1_EXCLUDE_FILES), )
   209   ifneq ($$($1_INCLUDE_FILES),)
   209     $1_EXCLUDE_PATTERN := $$(addprefix %, $$($1_EXCLUDE_FILES))
   210     $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
   210   endif
   211     $1_SRCS := $$(filter $$($1_INCLUDE_FILES), $$($1_SRCS))
   211   ifneq ($$($1_INCLUDE_FILES), )
   212   endif
   212     $1_INCLUDE_PATTERN := $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$($1_INCLUDE_FILES)))
   213 
   213   endif
   214   # Prepend the source/bin path to the filter expressions.
   214   ifneq ($$($1_EXCLUDES), )
   215   ifneq ($$($1_INCLUDES),)
   215     $1_EXCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_EXCLUDES))))
   216     $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
   216   endif
   217     $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
   217   ifneq ($$($1_INCLUDES), )
   218   endif
   218     $1_INCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_INCLUDES))))
   219   ifneq ($$($1_EXCLUDES),)
   219   endif
   220     $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
   220 
   221     $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
   221   # Apply include/exclude patterns to java sources
       
   222   ifneq ($$($1_EXCLUDE_PATTERN), )
       
   223     $1_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_SRCS))
       
   224   endif
       
   225   ifneq ($$($1_INCLUDE_PATTERN), )
       
   226     $1_SRCS := $$(filter $$($1_INCLUDE_PATTERN), $$($1_SRCS))
   222   endif
   227   endif
   223 
   228 
   224   ifneq ($$($1_KEEP_DUPS), true)
   229   ifneq ($$($1_KEEP_DUPS), true)
   225     # Remove duplicate source files by keeping the first found of each duplicate.
   230     # Remove duplicate source files by keeping the first found of each duplicate.
   226     # This allows for automatic overrides with custom or platform specific versions
   231     # This allows for automatic overrides with custom or platform specific versions
   240   endif
   245   endif
   241 
   246 
   242   $1_SAFE_NAME := $$(strip $$(subst /,_, $1))
   247   $1_SAFE_NAME := $$(strip $$(subst /,_, $1))
   243 
   248 
   244   # Create the corresponding smart javac wrapper command line.
   249   # Create the corresponding smart javac wrapper command line.
   245   $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix /*,$$($1_EXCLUDES))) \
   250   $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix /**,$$($1_EXCLUDES))) \
   246       $$(addprefix -i ,$$(addsuffix /*,$$($1_INCLUDES))) \
   251       $$(addprefix -i ,$$(addsuffix /**,$$($1_INCLUDES))) \
   247       $$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES) $$($1_SJAVAC_EXCLUDE_FILES))) \
   252       $$(addprefix -x **,$$(strip $$($1_EXCLUDE_FILES) $$($1_SJAVAC_EXCLUDE_FILES))) \
   248       $$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \
   253       $$(addprefix -i **,$$(strip $$($1_INCLUDE_FILES))) \
   249       -src $$(call PathList, $$($1_SRC))
   254       -src $$(call PathList, $$($1_SRC))
   250 
   255 
   251   # All files below META-INF are always copied.
   256   # All files below META-INF are always copied.
   252   $1_ALL_COPIES := $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS))
   257   $1_ALL_COPIES := $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS))
   253   # Find all files to be copied from source to bin.
   258   # Find all files to be copied from source to bin.
   256     $1_ALL_COPIES += $$(filter $$(addprefix %,$$($1_COPY)),$$($1_ALL_SRCS))
   261     $1_ALL_COPIES += $$(filter $$(addprefix %,$$($1_COPY)),$$($1_ALL_SRCS))
   257     # Copy these explicitly
   262     # Copy these explicitly
   258     $1_ALL_COPIES += $$($1_COPY_FILES)
   263     $1_ALL_COPIES += $$($1_COPY_FILES)
   259   endif
   264   endif
   260   # Copy must also respect filters.
   265   # Copy must also respect filters.
   261   ifneq (,$$($1_INCLUDES))
   266   ifneq (,$$($1_INCLUDE_PATTERN))
   262     $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES))
   267     $1_ALL_COPIES := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_COPIES))
   263   endif
   268   endif
   264   ifneq (,$$($1_EXCLUDES))
   269   ifneq (,$$($1_EXCLUDE_PATTERN))
   265     $1_ALL_COPIES := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_COPIES))
   270     $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDES_PATTERN),$$($1_ALL_COPIES))
   266   endif
       
   267   ifneq (,$$($1_EXCLUDE_FILES))
       
   268     $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES))
       
   269   endif
   271   endif
   270   ifneq (,$$($1_ALL_COPIES))
   272   ifneq (,$$($1_ALL_COPIES))
   271     # Yep, there are files to be copied!
   273     # Yep, there are files to be copied!
   272     $1_ALL_COPY_TARGETS:=
   274     $1_ALL_COPY_TARGETS:=
   273         $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i)))
   275         $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i)))
   279     # Search for all files to be copied.
   281     # Search for all files to be copied.
   280     $1_ALL_CLEANS := $$(filter $$(addprefix %,$$($1_CLEAN)),$$($1_ALL_SRCS))
   282     $1_ALL_CLEANS := $$(filter $$(addprefix %,$$($1_CLEAN)),$$($1_ALL_SRCS))
   281     # Clean these explicitly
   283     # Clean these explicitly
   282     $1_ALL_CLEANS += $$($1_CLEAN_FILES)
   284     $1_ALL_CLEANS += $$($1_CLEAN_FILES)
   283     # Copy and clean must also respect filters.
   285     # Copy and clean must also respect filters.
   284     ifneq (,$$($1_INCLUDES))
   286     ifneq (,$$($1_INCLUDE_PATTERN))
   285       $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS))
   287       $1_ALL_CLEANS := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_CLEANS))
   286     endif
   288     endif
   287     ifneq (,$$($1_EXCLUDES))
   289     ifneq (,$$($1_EXCLUDE_PATTERN))
   288       $1_ALL_CLEANS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_CLEANS))
   290       $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_CLEANS))
   289     endif
       
   290     ifneq (,$$($1_EXCLUDE_FILES))
       
   291       $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_CLEANS))
       
   292     endif
   291     endif
   293     ifneq (,$$($1_ALL_CLEANS))
   292     ifneq (,$$($1_ALL_CLEANS))
   294       # Yep, there are files to be copied and cleaned!
   293       # Yep, there are files to be copied and cleaned!
   295       $1_ALL_COPY_CLEAN_TARGETS:=
   294       $1_ALL_COPY_CLEAN_TARGETS:=
   296           $$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_clean,$1,$$i)))
   295           $$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_clean,$1,$$i)))