make/common/JavaCompilation.gmk
changeset 47364 6b3389375f31
parent 47217 72e3ae9a25eb
child 47398 1fd27535bc57
--- a/make/common/JavaCompilation.gmk	Thu Oct 19 10:59:02 2017 +0200
+++ b/make/common/JavaCompilation.gmk	Thu Oct 19 14:16:45 2017 +0200
@@ -166,6 +166,8 @@
 #   INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
 #   EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
 #       "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
+#   EXTRA_FILES:=List of extra source files to include in compilation. Can be used to
+#       specify files that need to be generated by other rules first.
 #   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.
@@ -203,16 +205,23 @@
     $1_MODULE_SUBDIR := /$$($1_MODULE)
   endif
 
-  # Make sure the dirs exist.
-  $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<)))
+  # Make sure the dirs exist, or that one of the EXTRA_FILES, that may not
+  # exist yet, is in it.
+  $$(foreach d, $$($1_SRC), \
+    $$(if $$(wildcard $$d), , \
+      $$(if $$(filter $$d%, $$($1_EXTRA_FILES)), , \
+        $$(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)))
+  $$(eval $$(call FillCacheFind, $$($1_SRC)))
   # Find all files in the source trees. Preserve order of source roots so that
   # the first version in case of multiple instances of the same file is selected.
   # CacheFind does not preserve order so need to call it for each root.
-  $1_ALL_SRCS += $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s)))
+  $1_ALL_SRCS += $$($1_EXTRA_FILES) $$(foreach s, $$($1_SRC), $$(call CacheFind, $$s))
   # Extract the java files.
   $1_SRCS := $$(filter %.java, $$($1_ALL_SRCS))
 
@@ -235,7 +244,7 @@
     $1_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_SRCS))
   endif
   ifneq ($$($1_INCLUDE_PATTERN), )
-    $1_SRCS := $$(filter $$($1_INCLUDE_PATTERN), $$($1_SRCS))
+    $1_SRCS := $$(filter $$($1_INCLUDE_PATTERN) $$($1_EXTRA_FILES), $$($1_SRCS))
   endif
 
   ifneq ($$($1_KEEP_DUPS), true)