make/GensrcModuleInfo.gmk
changeset 37978 2614022b9fa5
parent 37650 ef6c24163cb2
child 37979 42ee4e537363
--- a/make/GensrcModuleInfo.gmk	Thu May 19 19:45:47 2016 +0000
+++ b/make/GensrcModuleInfo.gmk	Fri May 20 10:25:40 2016 +0200
@@ -85,21 +85,29 @@
   MODS_REST := $(filter-out $(MODS_QUALIFIED_EXPORTS), $(MOD_FILE_CONTENTS))
 
   # Filter the contents for modules that are actually being built
-  MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
-  MODIFICATIONS := $(filter $(MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
+  ALL_MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
+  MODIFICATIONS := $(filter $(ALL_MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
       $(MODS_REST)
 
+  # Returns non empty if the package exists in the current module
+  # Param 1 - Name of package with dots
+  PackageExists = \
+      $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \
+          $(MODULE_CLASSES_DIRS))))
+
   # Convert the modification lines into arguments for the modification tool.
   # Filter out modifications for non existing to-modules.
   $(foreach line, $(MODIFICATIONS), \
     $(eval split_line := $(subst /,$(SPACE),$(line))) \
     $(eval command := $(word 1, $(split_line))) \
     $(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \
-    $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
-    $(if $(to_module), \
-      $(eval ARGS += -$(command) $(package)/$(to_module)) \
-    , \
-      $(eval ARGS += -$(command) $(package)) \
+    $(if $(call PackageExists, $(package)), \
+      $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
+      $(if $(to_module), \
+        $(eval ARGS += -$(command) $(package)/$(to_module)) \
+      , \
+        $(eval ARGS += -$(command) $(package)) \
+      ) \
     ) \
   )