< prev index next >

make/GensrcModuleInfo.gmk

Print this page




  75   ALL_MODULES := $(call FindAllModules)
  76 
  77   # Read the contents of all the files into a variable. Replace space with / to
  78   # let space represent new lines in the variable as $(shell) normalizes all
  79   # whitespace.
  80   $(foreach f, $(MOD_FILES), \
  81     $(eval MOD_FILE_CONTENTS += $(shell $(GREP) -v -e ".\*" -e "//" $f | $(TR) ' ' '/')))
  82 
  83   # Separate the modifications into qualified exports and the rest
  84   MODS_QUALIFIED_EXPORTS := $(call containing, /to/, $(MOD_FILE_CONTENTS))
  85   MODS_REST := $(filter-out $(MODS_QUALIFIED_EXPORTS), $(MOD_FILE_CONTENTS))
  86 
  87   # Filter the contents for modules that are actually being built
  88   ALL_MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
  89   MODIFICATIONS := $(filter $(ALL_MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
  90       $(MODS_REST)
  91 
  92   # Returns non empty if the package exists in the current module
  93   # Param 1 - Name of package with dots
  94   PackageExists = \
  95       $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \

  96           $(MODULE_CLASSES_DIRS) \
  97           $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \
  98           $(JDK_OUTPUTDIR)/modules/$(MODULE) \

  99       )))
 100 
 101   # Convert the modification lines into arguments for the modification tool.
 102   # Filter out modifications for non existing to-modules.
 103   $(foreach line, $(MODIFICATIONS), \
 104     $(eval split_line := $(subst /,$(SPACE),$(line))) \
 105     $(eval command := $(word 1, $(split_line))) \
 106     $(if $(filter $(command), exports), \
 107       $(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \
 108       $(if $(call PackageExists, $(package)), \
 109         $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
 110         $(if $(to_module), \
 111           $(eval ARGS += -$(command) $(package)/$(to_module)) \
 112         , \
 113           $(eval ARGS += -$(command) $(package)) \
 114         ) \
 115       ) \
 116     , \
 117       $(if $(filter $(command), provides), \
 118         $(eval provider := $(patsubst %;,%,$(word 2, $(split_line)))) \
 119         $(eval class := $(patsubst %;,%,$(word 4, $(split_line)))) \
 120         $(eval ARGS += -$(command) $(provider)/$(class)) \
 121       , \
 122         $(error A module-info.extra in $(MODULE) contains invalid command $(command)) \





 123       ) \
 124     ) \
 125   )
 126 
 127   ifneq ($(ARGS), )
 128     $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java: \
 129         $(firstword $(call FindAllModuleInfos, $(MODULE))) \
 130         $(BUILD_TOOLS_JDK) \
 131         $(call DependOnVariable, ARGS)
 132                 $(MKDIR) -p $(@D)
 133                 $(RM) $@ $@.tmp
 134                 $(TOOL_GENMODULEINFOSOURCE) $(ARGS) -o $@.tmp $<
 135                 $(MV) $@.tmp $@
 136 
 137     TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java
 138   endif
 139 
 140 endif
 141 
 142 # If no modifications are found for this module, remove any module-info.java


  75   ALL_MODULES := $(call FindAllModules)
  76 
  77   # Read the contents of all the files into a variable. Replace space with / to
  78   # let space represent new lines in the variable as $(shell) normalizes all
  79   # whitespace.
  80   $(foreach f, $(MOD_FILES), \
  81     $(eval MOD_FILE_CONTENTS += $(shell $(GREP) -v -e ".\*" -e "//" $f | $(TR) ' ' '/')))
  82 
  83   # Separate the modifications into qualified exports and the rest
  84   MODS_QUALIFIED_EXPORTS := $(call containing, /to/, $(MOD_FILE_CONTENTS))
  85   MODS_REST := $(filter-out $(MODS_QUALIFIED_EXPORTS), $(MOD_FILE_CONTENTS))
  86 
  87   # Filter the contents for modules that are actually being built
  88   ALL_MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
  89   MODIFICATIONS := $(filter $(ALL_MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
  90       $(MODS_REST)
  91 
  92   # Returns non empty if the package exists in the current module
  93   # Param 1 - Name of package with dots
  94   PackageExists = \
  95       $(strip $(wildcard $(foreach s, $(subst .,/,/$(strip $1)) $(subst .,/,/*/src/$(strip $1)), \
  96           $(addsuffix $s, \
  97               $(MODULE_CLASSES_DIRS) \
  98               $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \
  99               $(JDK_OUTPUTDIR)/modules/$(MODULE) \
 100           ) \
 101       )))
 102 
 103   # Convert the modification lines into arguments for the modification tool.
 104   # Filter out modifications for non existing to-modules.
 105   $(foreach line, $(MODIFICATIONS), \
 106     $(eval split_line := $(subst /,$(SPACE),$(line))) \
 107     $(eval command := $(word 1, $(split_line))) \
 108     $(if $(filter $(command), exports), \
 109       $(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \
 110       $(if $(call PackageExists, $(package)), \
 111         $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
 112         $(if $(to_module), \
 113           $(eval ARGS += -$(command) $(package)/$(to_module)) \
 114         , \
 115           $(eval ARGS += -$(command) $(package)) \
 116         ) \
 117       ) \
 118     , \
 119       $(if $(filter $(command), provides), \
 120         $(eval provider := $(patsubst %;,%,$(word 2, $(split_line)))) \
 121         $(eval class := $(patsubst %;,%,$(word 4, $(split_line)))) \
 122         $(eval ARGS += -$(command) $(provider)/$(class)) \
 123       , \
 124         $(if $(filter $(command), uses), \
 125           $(eval provider := $(patsubst %;,%,$(word 2, $(split_line)))) \
 126           $(eval ARGS += -$(command) $(provider)) \
 127         , \
 128           $(error A module-info.java.extra in $(MODULE) contains invalid command $(command)) \
 129         ) \
 130       ) \
 131     ) \
 132   )
 133 
 134   ifneq ($(ARGS), )
 135     $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java: \
 136         $(firstword $(call FindAllModuleInfos, $(MODULE))) \
 137         $(BUILD_TOOLS_JDK) \
 138         $(call DependOnVariable, ARGS)
 139                 $(MKDIR) -p $(@D)
 140                 $(RM) $@ $@.tmp
 141                 $(TOOL_GENMODULEINFOSOURCE) $(ARGS) -o $@.tmp $<
 142                 $(MV) $@.tmp $@
 143 
 144     TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java
 145   endif
 146 
 147 endif
 148 
 149 # If no modifications are found for this module, remove any module-info.java
< prev index next >