-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathCreateJmods.gmk
274 lines (240 loc) · 10.1 KB
/
CreateJmods.gmk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#
# Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
include MakeFileStart.gmk
################################################################################
include CopyFiles.gmk
include Execute.gmk
include Modules.gmk
ifeq ($(MODULE), )
$(error MODULE must be set when calling CreateJmods.gmk)
endif
################################################################################
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
JMODS_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jmods
JMOD_FILE := $(MODULE).jmod
LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
CMDS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
CONF_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
CLASSES_DIR ?= $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
INCLUDE_HEADERS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS))))
MAN_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
$(call FillFindCache, \
$(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \
)
ifneq ($(LIBS_DIR), )
DEPS += $(call FindFiles, $(LIBS_DIR))
ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
# For public debug symbols on Windows, we have to use stripped pdbs and rename them
rename_stripped = $(patsubst %.stripped.pdb,%.pdb,$1)
LIBS_DIR_FILTERED := $(subst modules_libs,modules_libs_filtered, $(LIBS_DIR))
FILES_LIBS := $(filter-out %.pdb, $(call FindFiles, $(LIBS_DIR))) \
$(filter %.stripped.pdb, $(call FindFiles, $(LIBS_DIR)))
$(eval $(call SetupCopyFiles, COPY_FILTERED_LIBS, \
SRC := $(LIBS_DIR), \
DEST := $(LIBS_DIR_FILTERED), \
FILES := $(FILES_LIBS), \
NAME_MACRO := rename_stripped, \
))
DEPS += $(COPY_FILTERED_LIBS)
JMOD_FLAGS += --libs $(LIBS_DIR_FILTERED)
else
JMOD_FLAGS += --libs $(LIBS_DIR)
endif
endif
ifneq ($(CMDS_DIR), )
DEPS += $(call FindFiles, $(CMDS_DIR))
ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
# For public debug symbols on Windows, we have to use stripped pdbs and rename them
rename_stripped = $(patsubst %.stripped.pdb,%.pdb,$1)
CMDS_DIR_FILTERED := $(subst modules_cmds,modules_cmds_filtered, $(CMDS_DIR))
FILES_CMDS := $(filter-out %.pdb, $(call FindFiles, $(CMDS_DIR))) \
$(filter %.stripped.pdb, $(call FindFiles, $(CMDS_DIR)))
$(eval $(call SetupCopyFiles, COPY_FILTERED_CMDS, \
SRC := $(CMDS_DIR), \
DEST := $(CMDS_DIR_FILTERED), \
FILES := $(FILES_CMDS), \
NAME_MACRO := rename_stripped, \
))
DEPS += $(COPY_FILTERED_CMDS)
JMOD_FLAGS += --cmds $(CMDS_DIR_FILTERED)
else
JMOD_FLAGS += --cmds $(CMDS_DIR)
endif
endif
ifneq ($(CONF_DIR), )
JMOD_FLAGS += --config $(CONF_DIR)
DEPS += $(call FindFiles, $(CONF_DIR))
endif
ifneq ($(CLASSES_DIR), )
JMOD_FLAGS += --class-path $(CLASSES_DIR)
DEPS += $(call FindFiles, $(CLASSES_DIR))
endif
ifneq ($(INCLUDE_HEADERS_DIR), )
JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR)
DEPS += $(call FindFiles, $(INCLUDE_HEADERS_DIR))
endif
ifneq ($(MAN_DIR), )
JMOD_FLAGS += --man-pages $(MAN_DIR)
DEPS += $(call FindFiles, $(MAN_DIR))
endif
# If a specific modules_legal dir exists for this module, only pick up files
# from there. These files were explicitly filtered or modified in <module>-copy
# targets. For the rest, just pick up everything from the source legal dirs.
LEGAL_NOTICES := \
$(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/common) \
$(if $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
$(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
$(call FindModuleLegalSrcDirs, $(MODULE)) \
)
ifneq ($(strip $(LEGAL_NOTICES)), )
LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES))
DEPS += $(call FindFiles, $(LEGAL_NOTICES))
JMOD_FLAGS += --legal-notices $(LEGAL_NOTICES_PATH)
endif
ifeq ($(filter-out jdk.incubator.%, $(MODULE)), )
JMOD_FLAGS += --do-not-resolve-by-default
JMOD_FLAGS += --warn-if-resolved=incubating
endif
# Add dependencies on other jmod files. Only java.base needs access to other
# jmods.
ifeq ($(MODULE), java.base)
# When creating a BUILDJDK, we don't need to add hashes to java.base
ifneq ($(CREATING_BUILDJDK), true)
# When creating interim versions of jmods, skip hashes
ifneq ($(INTERIM_JMOD), true)
ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules)
DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
$(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
EXCLUDE_PATTERN := $(strip $(subst $(SPACE),$$|,$(strip $(ALL_UPGRADEABLE_MODULES))))
JMOD_FLAGS += --module-path $(JMODS_DIR) \
--hash-modules '^(?!$(EXCLUDE_PATTERN)$$)'
endif
endif
else # not java.base
ifeq ($(call isTargetOs, windows), true)
# Only java.base needs to include the MSVC*_DLLs. Make sure no other module
# tries to include them (typically imported ones).
ifneq ($(MSVCR_DLL), )
ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCR_DLL))), )
JMOD_FLAGS += --exclude '$(notdir $(MSVCR_DLL))'
endif
endif
ifneq ($(VCRUNTIME_1_DLL), )
ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(VCRUNTIME_1_DLL))), )
JMOD_FLAGS += --exclude '$(notdir $(VCRUNTIME_1_DLL))'
endif
endif
ifneq ($(MSVCP_DLL), )
ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCP_DLL))), )
JMOD_FLAGS += --exclude '$(notdir $(MSVCP_DLL))'
endif
endif
ifneq ($(UCRT_DLL_DIR), )
UCRT_DLL_FILES := $(notdir $(wildcard $(UCRT_DLL_DIR)/*.dll))
ifneq ($(wildcard $(LIBS_DIR)/$(firstword $(UCRT_DLL_FILES))), )
JMOD_FLAGS += $(patsubst %, --exclude '%', $(UCRT_DLL_FILES))
endif
endif
endif
endif
################################################################################
# Include module specific build settings
THIS_SNIPPET := modules/$(MODULE)/Jmod.gmk
ifneq ($(wildcard $(THIS_SNIPPET)), )
include MakeSnippetStart.gmk
include $(THIS_SNIPPET)
include MakeSnippetEnd.gmk
endif
# Set main class
ifneq ($(JMOD_FLAGS_main_class), )
JMOD_FLAGS += $(JMOD_FLAGS_main_class)
endif
# Changes to the jmod tool itself should also trigger a rebuild of all jmods.
# The variable JMOD_CMD could contain an environment variable assignment before
# the actual command. Filter that out using wildcard before adding to DEPS.
DEPS += $(wildcard $(JMOD_CMD))
ifeq ($(EXTERNAL_BUILDJDK), false)
DEPS += $(call FindFiles, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
endif
# If creating interim versions of jmods, certain files need to be filtered out
# to avoid false incremental rebuilds.
ifeq ($(INTERIM_JMOD), true)
DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
INTERIM_MSG := interim$(SPACE)
endif
ifeq ($(call isTargetOs, windows), true)
ifeq ($(SHIP_DEBUG_SYMBOLS), )
JMOD_FLAGS += --exclude '**{_the.*,_*.marker*,*.diz,*.pdb,*.map}'
else
JMOD_FLAGS += --exclude '**{_the.*,_*.marker*,*.diz,*.map}'
endif
else
JMOD_FLAGS += --exclude '**{_the.*,_*.marker*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM}'
endif
# Unless we are creating a very large module, use the small tool JVM options
JMOD_SMALL_FLAGS :=
ifeq ($(findstring $(MODULE), java.base java.desktop jdk.localedata), )
JMOD_SMALL_FLAGS += $(JAVA_TOOL_FLAGS_SMALL)
endif
ifeq ($(INTERIM_JMOD), true)
# Interim JMODs are not shipped anywhere, so there is no reason
# to compress them at all.
JMOD_FLAGS += --compress zip-0
JMOD_TARGET_OS := $(OPENJDK_BUILD_OS)
ifeq ($(JMOD_TARGET_OS), macosx)
JMOD_TARGET_OS := macos
endif
JMOD_TARGET_CPU := $(OPENJDK_BUILD_CPU)
ifeq ($(JMOD_TARGET_CPU), x86_64)
JMOD_TARGET_CPU := amd64
endif
JMOD_TARGET_PLATFORM := $(JMOD_TARGET_OS)-$(JMOD_TARGET_CPU)
else
JMOD_FLAGS += --compress $(JMOD_COMPRESS)
JMOD_TARGET_PLATFORM := $(OPENJDK_MODULE_TARGET_PLATFORM)
endif
# Create jmods in the support dir and then move them into place to keep the
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
$(eval $(call SetupExecute, create_$(JMOD_FILE), \
WARN := Creating $(INTERIM_MSG)$(JMOD_FILE), \
DEPS := $(DEPS), \
OUTPUT_FILE := $(JMODS_DIR)/$(JMOD_FILE), \
SUPPORT_DIR := $(JMODS_SUPPORT_DIR), \
PRE_COMMAND := $(RM) $(JMODS_DIR)/$(JMOD_FILE) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
COMMAND := $(JMOD) $(JMOD_SMALL_FLAGS) create --module-version $(VERSION_SHORT) \
--target-platform '$(JMOD_TARGET_PLATFORM)' \
--module-path $(JMODS_DIR) $(JMOD_FLAGS) \
--date $(SOURCE_DATE_ISO_8601) \
$(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
POST_COMMAND := $(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \
))
TARGETS += $(create_$(JMOD_FILE))
################################################################################
include MakeFileEnd.gmk