58 -cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes" \ |
58 -cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes" \ |
59 build.tools.module.GenModuleInfoSource |
59 build.tools.module.GenModuleInfoSource |
60 |
60 |
61 ################################################################################ |
61 ################################################################################ |
62 |
62 |
63 # Name of data file. Keep module-info.java.ext until javafx has changed. |
63 # Name of modification file. |
64 MOD_FILENAME := module-info.java.extra module-info.java.ext |
64 MOD_FILENAME := module-info.java.extra |
65 |
65 |
66 # Construct all possible src directories for the module. |
66 # Construct all possible src directories for the module. |
67 MODULE_CLASSES_DIRS := $(call FindModuleSrcDirs, $(MODULE)) |
67 MODULE_CLASSES_DIRS := $(call FindModuleSrcDirs, $(MODULE)) |
68 |
68 |
69 # Find all the .extra files in the src dirs. |
69 # Find all the .extra files in the src dirs. |
72 |
72 |
73 ifneq ($(MOD_FILES), ) |
73 ifneq ($(MOD_FILES), ) |
74 # Only make this call if modification files are found for this module |
74 # Only make this call if modification files are found for this module |
75 ALL_MODULES := $(call FindAllModules) |
75 ALL_MODULES := $(call FindAllModules) |
76 |
76 |
77 # Read the contents of all the files into a variable. Replace space with / to |
77 $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java: \ |
78 # let space represent new lines in the variable as $(shell) normalizes all |
78 $(firstword $(call FindAllModuleInfos, $(MODULE))) \ |
79 # whitespace. |
79 $(BUILD_TOOLS_JDK) \ |
80 $(foreach f, $(MOD_FILES), \ |
80 $(MOD_FILES) \ |
81 $(eval MOD_FILE_CONTENTS += $(shell $(GREP) -v -e ".\*" -e "//" $f | $(TR) ' ' '/'))) |
81 $(call DependOnVariable, ALL_MODULES) |
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) |
82 $(MKDIR) -p $(@D) |
133 $(RM) $@ $@.tmp |
83 $(RM) $@ $@.tmp |
134 $(TOOL_GENMODULEINFOSOURCE) $(ARGS) -o $@.tmp $< |
84 $(TOOL_GENMODULEINFOSOURCE) -o $@.tmp \ |
|
85 --source-file $< \ |
|
86 --modules $(call CommaList, $(ALL_MODULES)) \ |
|
87 $(MOD_FILES) |
135 $(MV) $@.tmp $@ |
88 $(MV) $@.tmp $@ |
136 |
89 |
137 TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java |
90 TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java |
138 endif |
|
139 |
91 |
140 endif |
92 else |
141 |
93 # If no modifications are found for this module, remove any module-info.java |
142 # If no modifications are found for this module, remove any module-info.java |
94 # created by a previous build since that is no longer valid. |
143 # created by a previous build since that is no longer valid. |
|
144 ifeq ($(MODIFICATIONS), ) |
|
145 ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java), ) |
95 ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java), ) |
146 $(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java) |
96 $(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java) |
147 endif |
97 endif |
148 endif |
98 endif |
149 |
99 |