jdk

Форк
0
/
LauncherCommon.gmk 
240 строк · 9.7 Кб
1
#
2
# Copyright (c) 2011, 2024, 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
include CopyFiles.gmk
27
include JdkNativeCompilation.gmk
28
include Modules.gmk
29
include ProcessMarkdown.gmk
30
include ToolsJdk.gmk
31

32
LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher
33
LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \
34
    -I$(TOPDIR)/src/java.base/share/native/libjli \
35
    -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \
36
    -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \
37
    #
38
MACOSX_PLIST_DIR := $(TOPDIR)/src/java.base/macosx/native/launcher
39
JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest
40

41
################################################################################
42
# Build standard launcher.
43

44
# Setup make rules for building a standard launcher.
45
#
46
# Parameter 1 is the name of the rule. This name is used as variable prefix,
47
# and the targets generated are listed in a variable by that name. It is also
48
# used as the name of the executable.
49
#
50
# Remaining parameters are named arguments. These include:
51
# MAIN_MODULE  The module of the main class to launch if different from the
52
#     current module
53
# MAIN_CLASS   The Java main class to launch
54
# JAVA_ARGS   Processed into a -DJAVA_ARGS and added to CFLAGS
55
# EXTRA_JAVA_ARGS Processed into a -DEXTRA_JAVA_ARGS and is prepended
56
#     before JAVA_ARGS to CFLAGS, primarily to allow long string literal
57
#     compile time defines exceeding Visual Studio 2013 limitations.
58
# CFLAGS   Additional CFLAGS
59
# CFLAGS_windows   Additional CFLAGS_windows
60
# EXTRA_RCFLAGS   Additional EXTRA_RCFLAGS
61
# MACOSX_PRIVILEGED   On macosx, allow to access other processes
62
# OPTIMIZATION   Override default optimization level (LOW)
63
# OUTPUT_DIR   Override default output directory
64
# VERSION_INFO_RESOURCE   Override default Windows resource file
65
SetupBuildLauncher = $(NamedParamsMacroTemplate)
66
define SetupBuildLauncherBody
67
  # Setup default values (unless overridden)
68
  ifeq ($$($1_OPTIMIZATION), )
69
    $1_OPTIMIZATION := LOW
70
  endif
71

72
  ifeq ($$($1_MAIN_MODULE), )
73
    $1_MAIN_MODULE := $(MODULE)
74
  endif
75

76
  ifneq ($$($1_MAIN_CLASS), )
77
    $1_JAVA_ARGS += -ms8m
78
    $1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS)
79
  endif
80

81
  ifneq ($$($1_EXTRA_JAVA_ARGS), )
82
    $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
83
      $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }'
84
    $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR)
85
  endif
86

87
  ifneq ($$($1_JAVA_ARGS), )
88
    $1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
89
        $$(addprefix -J, $$($1_JAVA_ARGS)) $$($1_LAUNCHER_CLASS), "$$a"$(COMMA) )) }'
90
    $1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR)
91
  endif
92

93
  ifeq ($(call isTargetOs, macosx), true)
94
    ifeq ($$($1_MACOSX_PRIVILEGED), true)
95
      $1_PLIST_EXTRA := <key>SecTaskAccess</key><string>allowed</string>
96
    endif
97

98
    $1_PLIST_FILE := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$1/Info.plist
99

100
    $$(eval $$(call SetupTextFileProcessing, BUILD_PLIST_$1, \
101
        SOURCE_FILES := $(TOPDIR)/make/data/bundle/cmdline-Info.plist.template, \
102
        OUTPUT_FILE := $$($1_PLIST_FILE), \
103
        REPLACEMENTS := \
104
            @@ID@@ => $(MACOSX_BUNDLE_ID_BASE).$1 ; \
105
            @@VERSION@@ => $(VERSION_NUMBER) ; \
106
            @@BUILD_VERSION@@ => $(MACOSX_BUNDLE_BUILD_VERSION) ; \
107
            @@EXTRA@@ => $$($1_PLIST_EXTRA), \
108
    ))
109

110
    $1_LDFLAGS += -sectcreate __TEXT __info_plist $$($1_PLIST_FILE)
111
  endif
112

113
  $1_EXTRA_FILES := $(LAUNCHER_SRC)/main.c
114

115
  ifeq ($(ASAN_ENABLED), true)
116
    $1_EXTRA_FILES += $(TOPDIR)/make/data/asan/asan_default_options.c
117
  endif
118

119
  ifeq ($(LSAN_ENABLED), true)
120
    $1_EXTRA_FILES += $(TOPDIR)/make/data/lsan/lsan_default_options.c
121
  endif
122

123
  ##############################################################################
124
  ## Build launcher "$1"
125
  ##############################################################################
126

127
  $$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
128
      NAME := $1, \
129
      EXTRA_FILES := $$($1_EXTRA_FILES), \
130
      OPTIMIZATION := $$($1_OPTIMIZATION), \
131
      CFLAGS := $$(LAUNCHER_CFLAGS) \
132
          $$(VERSION_CFLAGS) \
133
          -DLAUNCHER_NAME='"$$(LAUNCHER_NAME)"' \
134
          -DPROGNAME='"$1"' \
135
          $$($1_CFLAGS), \
136
      CFLAGS_windows := $$($1_CFLAGS_windows), \
137
      EXTRA_HEADER_DIRS := java.base:libjvm, \
138
      DISABLED_WARNINGS_gcc := unused-function, \
139
      LDFLAGS := $$($1_LDFLAGS), \
140
      LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
141
      LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
142
      JDK_LIBS := java.base:libjli, \
143
      JDK_LIBS_windows := java.base:libjava, \
144
      LIBS := $$($1_LIBS), \
145
      LIBS_unix := $(LIBZ_LIBS), \
146
      LIBS_linux := $(LIBDL) -lpthread, \
147
      LIBS_macosx := \
148
          -framework ApplicationServices \
149
          -framework Cocoa \
150
          -framework Security, \
151
      OUTPUT_DIR := $$($1_OUTPUT_DIR), \
152
      VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \
153
      EXTRA_RCFLAGS := $$($1_EXTRA_RCFLAGS), \
154
      MANIFEST := $(JAVA_MANIFEST), \
155
      MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \
156
  ))
157

158
  $1 += $$(BUILD_LAUNCHER_$1)
159
  TARGETS += $$($1)
160

161
  $$(BUILD_LAUNCHER_$1): $$(BUILD_PLIST_$1)
162

163
  ifeq ($(call isTargetOs, macosx), true)
164
    $$(BUILD_LAUNCHER_$1): $$($1_PLIST_FILE)
165
  endif
166
endef
167

168
################################################################################
169
# Create man pages for jmod to pick up. There should be a one-to-one
170
# relationship between executables and man pages (even if this is not always
171
# the case), so piggyback man page generation on the launcher compilation. This
172
# file may be included from other places as well, so only process man pages
173
# when called from <module>/Launcher.gmk.
174

175
ifeq ($(call isTargetOsType, unix)+$(MAKEFILE_PREFIX), true+Launcher)
176
  # Only build manpages on unix systems.
177
  # We assume all our man pages should reside in section 1.
178

179
  MAN_FILES_MD := $(wildcard $(addsuffix /*.md, $(call FindModuleManDirs, $(MODULE))))
180
  MAN_FILES_TROFF := $(wildcard $(addsuffix /*.1, $(call FindModuleManDirs, $(MODULE))))
181

182
  ifneq ($(MAN_FILES_MD), )
183
    # If we got markdown files, ignore the troff files
184
    ifeq ($(ENABLE_PANDOC), false)
185
      $(info Warning: pandoc not found. Not generating man pages)
186
    else
187
      # Create dynamic man pages from markdown using pandoc. We need
188
      # PANDOC_TROFF_MANPAGE_FILTER, a wrapper around
189
      # PANDOC_TROFF_MANPAGE_FILTER_JAVASCRIPT. This is created by buildtools-jdk.
190

191
      # We should also depend on the source code for the filter
192
      PANDOC_TROFF_MANPAGE_FILTER_SOURCE := $(call FindFiles, \
193
          $(TOPDIR)/make/jdk/src/classes/build/tools/pandocfilter)
194

195
      # The norm in man pages is to display code literals as bold, but pandoc
196
      # "correctly" converts these constructs (encoded in markdown using `...`
197
      # or ```...```) to \f[C]. Ideally, we should use the filter to encapsulate
198
      # the Code/CodeBlock in Strong. While this works for Code, pandoc cannot
199
      # correctly render man page output for CodeBlock wrapped in Strong. So we
200
      # take the easy way out, and post-process the troff output, replacing
201
      # \f[C] with \f[CB]. This has the added benefit of working correctly on
202
      # pandoc prior to version 2.0, which cannot properly produced nested
203
      # formatting in man pages (see https://github.com/jgm/pandoc/issues/3568).
204
      #
205
      # As of pandoc 2.3, the termination of formatting is still broken
206
      # (see https://github.com/jgm/pandoc/issues/4973). We need to replace
207
      # \f[] with \f[R].
208
      MAN_POST_PROCESS := $(SED) -e 's/\\f\[C\]/\\f\[CB\]/g' \
209
          -e 's/\\f\[\]/\\f\[R\]/g'
210

211
      # Now generate the man pages from markdown using pandoc
212
      $(eval $(call SetupProcessMarkdown, BUILD_MAN_PAGES, \
213
          DEST := $(SUPPORT_OUTPUTDIR)/modules_man/$(MODULE)/man1, \
214
          FILES := $(MAN_FILES_MD), \
215
          FORMAT := man, \
216
          FILTER := $(PANDOC_TROFF_MANPAGE_FILTER), \
217
          POST_PROCESS := $(MAN_POST_PROCESS), \
218
          REPLACEMENTS := \
219
              @@COPYRIGHT_YEAR@@ => $(COPYRIGHT_YEAR) ; \
220
              @@VERSION_SHORT@@ => $(VERSION_SHORT) ; \
221
              @@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION), \
222
          EXTRA_DEPS := $(PANDOC_TROFF_MANPAGE_FILTER) \
223
              $(PANDOC_TROFF_MANPAGE_FILTER_SOURCE), \
224
      ))
225

226
      TARGETS += $(BUILD_MAN_PAGES)
227
    endif
228
  else
229
    # No markdown man pages present
230
    ifeq ($(BUILD_MANPAGES), true)
231
      # BUILD_MANPAGES is a mis-nomer. It really means "copy the pre-generated man pages".
232
      $(eval $(call SetupCopyFiles, COPY_MAN_PAGES, \
233
          DEST := $(SUPPORT_OUTPUTDIR)/modules_man/$(MODULE)/man1, \
234
          FILES := $(MAN_FILES_TROFF), \
235
      ))
236

237
      TARGETS += $(COPY_MAN_PAGES)
238
    endif
239
  endif
240
endif
241

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

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

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

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