make/common/JavaCompilation.gmk
changeset 47364 6b3389375f31
parent 47217 72e3ae9a25eb
child 47398 1fd27535bc57
equal deleted inserted replaced
47363:77c792d06646 47364:6b3389375f31
   164 #   CLEAN_FILES:=myapp/foo/setting.txt means clean this file over to the package myapp/foo
   164 #   CLEAN_FILES:=myapp/foo/setting.txt means clean this file over to the package myapp/foo
   165 #   SRCZIP:=Create a src.zip based on the found sources and copied files.
   165 #   SRCZIP:=Create a src.zip based on the found sources and copied files.
   166 #   INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
   166 #   INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
   167 #   EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
   167 #   EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
   168 #       "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
   168 #       "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
       
   169 #   EXTRA_FILES:=List of extra source files to include in compilation. Can be used to
       
   170 #       specify files that need to be generated by other rules first.
   169 #   HEADERS:=path to directory where all generated c-headers are written.
   171 #   HEADERS:=path to directory where all generated c-headers are written.
   170 #   DEPENDS:=Extra dependecy
   172 #   DEPENDS:=Extra dependecy
   171 #   DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit.
   173 #   DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit.
   172 #   KEEP_DUPS:=Do not remove duplicate file names from different source roots.
   174 #   KEEP_DUPS:=Do not remove duplicate file names from different source roots.
   173 #   FAIL_NO_SRC:=Set to false to not fail the build if no source files are found,
   175 #   FAIL_NO_SRC:=Set to false to not fail the build if no source files are found,
   201 
   203 
   202   ifneq ($$($1_MODULE), )
   204   ifneq ($$($1_MODULE), )
   203     $1_MODULE_SUBDIR := /$$($1_MODULE)
   205     $1_MODULE_SUBDIR := /$$($1_MODULE)
   204   endif
   206   endif
   205 
   207 
   206   # Make sure the dirs exist.
   208   # Make sure the dirs exist, or that one of the EXTRA_FILES, that may not
   207   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<)))
   209   # exist yet, is in it.
       
   210   $$(foreach d, $$($1_SRC), \
       
   211     $$(if $$(wildcard $$d), , \
       
   212       $$(if $$(filter $$d%, $$($1_EXTRA_FILES)), , \
       
   213         $$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<) \
       
   214       ) \
       
   215     ) \
       
   216   )
   208   $$(call MakeDir,$$($1_BIN))
   217   $$(call MakeDir,$$($1_BIN))
   209   # Add all source roots to the find cache since we are likely going to run find
   218   # Add all source roots to the find cache since we are likely going to run find
   210   # on these more than once. The cache will only be updated if necessary.
   219   # on these more than once. The cache will only be updated if necessary.
   211   $$(eval $$(call FillCacheFind,$$($1_SRC)))
   220   $$(eval $$(call FillCacheFind, $$($1_SRC)))
   212   # Find all files in the source trees. Preserve order of source roots so that
   221   # Find all files in the source trees. Preserve order of source roots so that
   213   # the first version in case of multiple instances of the same file is selected.
   222   # the first version in case of multiple instances of the same file is selected.
   214   # CacheFind does not preserve order so need to call it for each root.
   223   # CacheFind does not preserve order so need to call it for each root.
   215   $1_ALL_SRCS += $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s)))
   224   $1_ALL_SRCS += $$($1_EXTRA_FILES) $$(foreach s, $$($1_SRC), $$(call CacheFind, $$s))
   216   # Extract the java files.
   225   # Extract the java files.
   217   $1_SRCS := $$(filter %.java, $$($1_ALL_SRCS))
   226   $1_SRCS := $$(filter %.java, $$($1_ALL_SRCS))
   218 
   227 
   219   # Translate include/exclude into patterns
   228   # Translate include/exclude into patterns
   220   ifneq ($$($1_EXCLUDE_FILES), )
   229   ifneq ($$($1_EXCLUDE_FILES), )
   233   # Apply include/exclude patterns to java sources
   242   # Apply include/exclude patterns to java sources
   234   ifneq ($$($1_EXCLUDE_PATTERN), )
   243   ifneq ($$($1_EXCLUDE_PATTERN), )
   235     $1_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_SRCS))
   244     $1_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_SRCS))
   236   endif
   245   endif
   237   ifneq ($$($1_INCLUDE_PATTERN), )
   246   ifneq ($$($1_INCLUDE_PATTERN), )
   238     $1_SRCS := $$(filter $$($1_INCLUDE_PATTERN), $$($1_SRCS))
   247     $1_SRCS := $$(filter $$($1_INCLUDE_PATTERN) $$($1_EXTRA_FILES), $$($1_SRCS))
   239   endif
   248   endif
   240 
   249 
   241   ifneq ($$($1_KEEP_DUPS), true)
   250   ifneq ($$($1_KEEP_DUPS), true)
   242     # Remove duplicate source files by keeping the first found of each duplicate.
   251     # Remove duplicate source files by keeping the first found of each duplicate.
   243     # This allows for automatic overrides with custom or platform specific versions
   252     # This allows for automatic overrides with custom or platform specific versions