author | joehw |
Thu, 01 Sep 2016 17:03:41 -0700 | |
changeset 40755 | 26f6264ee481 |
parent 39110 | 712f29ba8708 |
child 41458 | f285e333e8db |
permissions | -rw-r--r-- |
36506 | 1 |
# |
2 |
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
# |
|
5 |
# This code is free software; you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
|
7 |
# published by the Free Software Foundation. Oracle designates this |
|
8 |
# particular file as subject to the "Classpath" exception as provided |
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
|
10 |
# |
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
# accompanied this code). |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License version |
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
# |
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
24 |
# |
|
25 |
||
26 |
################################################################################ |
|
27 |
# This file makes modifications to module-info.java files based on the build |
|
28 |
# configuration. |
|
29 |
# |
|
30 |
# Depending on build platform, imported modules and optional parts of the build |
|
31 |
# being active, some modules need to have extra exports, provides or uses |
|
32 |
# declarations added to them. These optional extras are defined in .extra files: |
|
33 |
# |
|
34 |
# src/<module>/<share,platform>/classes/module-info.java.extra |
|
35 |
# |
|
36 |
# The contents of the .extra files are simply extra lines that could fit into |
|
37 |
# the module-info file. |
|
38 |
# |
|
39 |
# This makefile is called once for each from-module with the variable |
|
40 |
# MODULE naming the from-module. |
|
41 |
# |
|
42 |
# The modified module-info.java files are put in the gensrc directory where |
|
43 |
# they will automatically override the static versions in the src tree. |
|
44 |
# |
|
45 |
################################################################################ |
|
46 |
||
47 |
default: all |
|
48 |
||
49 |
include $(SPEC) |
|
50 |
include MakeBase.gmk |
|
51 |
include Modules.gmk |
|
52 |
||
53 |
################################################################################ |
|
54 |
# Define this here since jdk/make/Tools.gmk cannot be included from the top |
|
55 |
# make directory. Should probably move some tools away from the jdk repo. |
|
56 |
TOOL_GENMODULEINFOSOURCE = $(JAVA_SMALL) \ |
|
57 |
$(INTERIM_LANGTOOLS_ARGS) \ |
|
58 |
-cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes" \ |
|
59 |
build.tools.module.GenModuleInfoSource |
|
60 |
||
61 |
################################################################################ |
|
62 |
||
63 |
# Name of data file. Keep module-info.java.ext until javafx has changed. |
|
64 |
MOD_FILENAME := module-info.java.extra module-info.java.ext |
|
65 |
||
66 |
# Construct all possible src directories for the module. |
|
37030 | 67 |
MODULE_CLASSES_DIRS := $(call FindModuleSrcDirs, $(MODULE)) |
36506 | 68 |
|
69 |
# Find all the .extra files in the src dirs. |
|
70 |
MOD_FILES := $(wildcard $(foreach f, $(MOD_FILENAME), $(addsuffix /$(f), \ |
|
71 |
$(MODULE_CLASSES_DIRS)))) |
|
72 |
||
73 |
ifneq ($(MOD_FILES), ) |
|
74 |
# Only make this call if modification files are found for this module |
|
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), \ |
|
37650
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
81 |
$(eval MOD_FILE_CONTENTS += $(shell $(GREP) -v -e ".\*" -e "//" $f | $(TR) ' ' '/'))) |
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
82 |
|
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
83 |
# Separate the modifications into qualified exports and the rest |
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
84 |
MODS_QUALIFIED_EXPORTS := $(call containing, /to/, $(MOD_FILE_CONTENTS)) |
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
85 |
MODS_REST := $(filter-out $(MODS_QUALIFIED_EXPORTS), $(MOD_FILE_CONTENTS)) |
36506 | 86 |
|
87 |
# Filter the contents for modules that are actually being built |
|
37978
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
88 |
ALL_MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES))) |
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
89 |
MODIFICATIONS := $(filter $(ALL_MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \ |
37650
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
90 |
$(MODS_REST) |
36506 | 91 |
|
37978
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
92 |
# Returns non empty if the package exists in the current module |
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
93 |
# Param 1 - Name of package with dots |
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
94 |
PackageExists = \ |
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
95 |
$(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \ |
37979
42ee4e537363
8157507: JDK-8157348 broke gensrc of imported modules
erikj
parents:
37978
diff
changeset
|
96 |
$(MODULE_CLASSES_DIRS) \ |
42ee4e537363
8157507: JDK-8157348 broke gensrc of imported modules
erikj
parents:
37978
diff
changeset
|
97 |
$(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \ |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
37981
diff
changeset
|
98 |
$(JDK_OUTPUTDIR)/modules/$(MODULE) \ |
37979
42ee4e537363
8157507: JDK-8157348 broke gensrc of imported modules
erikj
parents:
37978
diff
changeset
|
99 |
))) |
37978
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
100 |
|
36506 | 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))) \ |
|
37981
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
106 |
$(if $(filter $(command), exports), \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
107 |
$(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
108 |
$(if $(call PackageExists, $(package)), \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
109 |
$(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
110 |
$(if $(to_module), \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
111 |
$(eval ARGS += -$(command) $(package)/$(to_module)) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
112 |
, \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
113 |
$(eval ARGS += -$(command) $(package)) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
114 |
) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
115 |
) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
116 |
, \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
117 |
$(if $(filter $(command), provides), \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
118 |
$(eval provider := $(patsubst %;,%,$(word 2, $(split_line)))) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
119 |
$(eval class := $(patsubst %;,%,$(word 4, $(split_line)))) \ |
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
120 |
$(eval ARGS += -$(command) $(provider)/$(class)) \ |
37978
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
121 |
, \ |
37981
e0375f6012c1
8157511: JDK-8157348 broke gensrc of module infos with extra provides
erikj
parents:
37979
diff
changeset
|
122 |
$(error A module-info.extra in $(MODULE) contains invalid command $(command)) \ |
37978
2614022b9fa5
8157348: Build fails with certain source configurations
erikj
parents:
37650
diff
changeset
|
123 |
) \ |
37650
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
124 |
) \ |
ef6c24163cb2
8044773: Refactor jdk.net API so that it can be moved out of the base module
chegar
parents:
37030
diff
changeset
|
125 |
) |
36506 | 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 |
|
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), ) |
|
146 |
$(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java) |
|
147 |
endif |
|
148 |
endif |
|
149 |
||
150 |
################################################################################ |
|
151 |
||
152 |
all: $(TARGETS) |