jdk

Форк
0
/
CreateJmods.gmk 
258 строк · 9.7 Кб
1
#
2
# Copyright (c) 2014, 2023, 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
default: all
27

28
include $(SPEC)
29
include MakeBase.gmk
30

31
include CopyFiles.gmk
32
include Execute.gmk
33
include Modules.gmk
34

35
ifeq ($(MODULE), )
36
  $(error MODULE must be set when calling CreateJmods.gmk)
37
endif
38

39
$(eval $(call IncludeCustomExtension, CreateJmods.gmk))
40

41
################################################################################
42

43
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
44
JMODS_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/images/jmods
45
JMOD_FILE := $(MODULE).jmod
46

47
LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
48
    $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
49
CMDS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
50
    $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
51
CONF_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
52
    $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
53
CLASSES_DIR ?= $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
54
INCLUDE_HEADERS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
55
    $(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS))))
56
MAN_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
57
    $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
58

59
$(call FillFindCache, \
60
    $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \
61
)
62

63
ifneq ($(LIBS_DIR), )
64
  DEPS += $(call FindFiles, $(LIBS_DIR))
65
  ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
66
    # For public debug symbols on Windows, we have to use stripped pdbs and rename them
67
    rename_stripped = $(patsubst %.stripped.pdb,%.pdb,$1)
68
    LIBS_DIR_FILTERED := $(subst modules_libs,modules_libs_filtered, $(LIBS_DIR))
69
    FILES_LIBS := $(filter-out %.pdb, $(call FindFiles, $(LIBS_DIR))) \
70
        $(filter %.stripped.pdb, $(call FindFiles, $(LIBS_DIR)))
71
    $(eval $(call SetupCopyFiles, COPY_FILTERED_LIBS, \
72
        SRC := $(LIBS_DIR), \
73
        DEST := $(LIBS_DIR_FILTERED), \
74
        FILES := $(FILES_LIBS), \
75
        NAME_MACRO := rename_stripped, \
76
    ))
77
    DEPS += $(COPY_FILTERED_LIBS)
78
    JMOD_FLAGS += --libs $(LIBS_DIR_FILTERED)
79
  else
80
    JMOD_FLAGS += --libs $(LIBS_DIR)
81
  endif
82
endif
83
ifneq ($(CMDS_DIR), )
84
  DEPS += $(call FindFiles, $(CMDS_DIR))
85
  ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
86
    # For public debug symbols on Windows, we have to use stripped pdbs and rename them
87
    rename_stripped = $(patsubst %.stripped.pdb,%.pdb,$1)
88
    CMDS_DIR_FILTERED := $(subst modules_cmds,modules_cmds_filtered, $(CMDS_DIR))
89
    FILES_CMDS := $(filter-out %.pdb, $(call FindFiles, $(CMDS_DIR))) \
90
        $(filter %.stripped.pdb, $(call FindFiles, $(CMDS_DIR)))
91
    $(eval $(call SetupCopyFiles, COPY_FILTERED_CMDS, \
92
        SRC := $(CMDS_DIR), \
93
        DEST := $(CMDS_DIR_FILTERED), \
94
        FILES := $(FILES_CMDS), \
95
        NAME_MACRO := rename_stripped, \
96
    ))
97
    DEPS += $(COPY_FILTERED_CMDS)
98
    JMOD_FLAGS += --cmds $(CMDS_DIR_FILTERED)
99
  else
100
    JMOD_FLAGS += --cmds $(CMDS_DIR)
101
  endif
102
endif
103
ifneq ($(CONF_DIR), )
104
  JMOD_FLAGS += --config $(CONF_DIR)
105
  DEPS += $(call FindFiles, $(CONF_DIR))
106
endif
107
ifneq ($(CLASSES_DIR), )
108
  JMOD_FLAGS += --class-path $(CLASSES_DIR)
109
  DEPS += $(call FindFiles, $(CLASSES_DIR))
110
endif
111
ifneq ($(INCLUDE_HEADERS_DIR), )
112
  JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR)
113
  DEPS += $(call FindFiles, $(INCLUDE_HEADERS_DIR))
114
endif
115
ifneq ($(MAN_DIR), )
116
  JMOD_FLAGS += --man-pages $(MAN_DIR)
117
  DEPS += $(call FindFiles, $(MAN_DIR))
118
endif
119

120
# If a specific modules_legal dir exists for this module, only pick up files
121
# from there. These files were explicitly filtered or modified in <module>-copy
122
# targets. For the rest, just pick up everything from the source legal dirs.
123
LEGAL_NOTICES := \
124
    $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/common) \
125
    $(if $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
126
      $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
127
      $(call FindModuleLegalSrcDirs, $(MODULE)) \
128
    )
129

130
ifneq ($(strip $(LEGAL_NOTICES)), )
131
  LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES))
132
  DEPS += $(call FindFiles, $(LEGAL_NOTICES))
133

134
  JMOD_FLAGS += --legal-notices $(LEGAL_NOTICES_PATH)
135
endif
136

137
ifeq ($(filter-out jdk.incubator.%, $(MODULE)), )
138
  JMOD_FLAGS += --do-not-resolve-by-default
139
  JMOD_FLAGS += --warn-if-resolved=incubating
140
endif
141

142
# Add dependencies on other jmod files. Only java.base needs access to other
143
# jmods.
144
ifeq ($(MODULE), java.base)
145
  # When creating a BUILDJDK, we don't need to add hashes to java.base
146
  ifneq ($(CREATING_BUILDJDK), true)
147
    # When creating interim versions of jmods, skip hashes
148
    ifneq ($(INTERIM_JMOD), true)
149
      ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules)
150
      DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
151
          $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
152

153
      EXCLUDE_PATTERN := $(strip $(subst $(SPACE),$$|,$(strip $(ALL_UPGRADEABLE_MODULES))))
154

155
      JMOD_FLAGS += --module-path $(JMODS_DIR) \
156
          --hash-modules '^(?!$(EXCLUDE_PATTERN)$$)'
157
    endif
158
  endif
159
else # not java.base
160
  ifeq ($(call isTargetOs, windows), true)
161
    # Only java.base needs to include the MSVC*_DLLs. Make sure no other module
162
    # tries to include them (typically imported ones).
163
    ifneq ($(MSVCR_DLL), )
164
      ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCR_DLL))), )
165
        JMOD_FLAGS += --exclude '$(notdir $(MSVCR_DLL))'
166
      endif
167
    endif
168
    ifneq ($(VCRUNTIME_1_DLL), )
169
      ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(VCRUNTIME_1_DLL))), )
170
        JMOD_FLAGS += --exclude '$(notdir $(VCRUNTIME_1_DLL))'
171
      endif
172
    endif
173
    ifneq ($(MSVCP_DLL), )
174
      ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCP_DLL))), )
175
        JMOD_FLAGS += --exclude '$(notdir $(MSVCP_DLL))'
176
      endif
177
    endif
178
    ifneq ($(UCRT_DLL_DIR), )
179
      UCRT_DLL_FILES := $(notdir $(wildcard $(UCRT_DLL_DIR)/*.dll))
180
      ifneq ($(wildcard $(LIBS_DIR)/$(firstword $(UCRT_DLL_FILES))), )
181
        JMOD_FLAGS += $(patsubst %, --exclude '%', $(UCRT_DLL_FILES))
182
      endif
183
    endif
184
  endif
185
endif
186

187
################################################################################
188
# Include module specific build settings
189

190
-include Jmod.gmk
191

192
# Set main class
193
ifneq ($(JMOD_FLAGS_main_class), )
194
  JMOD_FLAGS += $(JMOD_FLAGS_main_class)
195
endif
196

197
# Changes to the jmod tool itself should also trigger a rebuild of all jmods.
198
# The variable JMOD_CMD could contain an environment variable assignment before
199
# the actual command. Filter that out using wildcard before adding to DEPS.
200
DEPS += $(wildcard $(JMOD_CMD))
201
ifeq ($(EXTERNAL_BUILDJDK), false)
202
  DEPS += $(call FindFiles, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
203
endif
204

205
# If creating interim versions of jmods, certain files need to be filtered out
206
# to avoid false incremental rebuilds.
207
ifeq ($(INTERIM_JMOD), true)
208
  DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
209
  INTERIM_MSG := interim$(SPACE)
210
endif
211

212
ifeq ($(call isTargetOs, windows), true)
213
  ifeq ($(SHIP_DEBUG_SYMBOLS), )
214
    JMOD_FLAGS += --exclude '**{_the.*,_*.marker*,*.diz,*.pdb,*.map}'
215
  else
216
    JMOD_FLAGS += --exclude '**{_the.*,_*.marker*,*.diz,*.map}'
217
  endif
218
else
219
  JMOD_FLAGS += --exclude '**{_the.*,_*.marker*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM}'
220
endif
221

222
# Unless we are creating a very large module, use the small tool JVM options
223
JMOD_SMALL_FLAGS :=
224
ifeq ($(findstring $(MODULE), java.base java.desktop jdk.localedata), )
225
  JMOD_SMALL_FLAGS += $(JAVA_TOOL_FLAGS_SMALL)
226
endif
227

228
ifeq ($(INTERIM_JMOD), true)
229
  # Interim JMODs are not shipped anywhere, so there is no reason
230
  # to compress them at all.
231
  JMOD_FLAGS += --compress zip-0
232
else
233
  JMOD_FLAGS += --compress $(JMOD_COMPRESS)
234
endif
235

236
# Create jmods in the support dir and then move them into place to keep the
237
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
238
$(eval $(call SetupExecute, create_$(JMOD_FILE), \
239
    WARN := Creating $(INTERIM_MSG)$(JMOD_FILE), \
240
    DEPS := $(DEPS), \
241
    OUTPUT_FILE := $(JMODS_DIR)/$(JMOD_FILE), \
242
    SUPPORT_DIR := $(JMODS_SUPPORT_DIR), \
243
    PRE_COMMAND := $(RM) $(JMODS_DIR)/$(JMOD_FILE) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
244
    COMMAND := $(JMOD) $(JMOD_SMALL_FLAGS) create --module-version $(VERSION_SHORT) \
245
        --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
246
        --module-path $(JMODS_DIR) $(JMOD_FLAGS) \
247
        --date $(SOURCE_DATE_ISO_8601) \
248
        $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
249
    POST_COMMAND := $(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \
250
))
251

252
TARGETS += $(create_$(JMOD_FILE))
253

254
################################################################################
255

256
all: $(TARGETS)
257

258
################################################################################
259

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.