jdk

Форк
0
/
CreateWorkspace.gmk 
359 строк · 15.6 Кб
1
#
2
# Copyright (c) 2016, 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
include TextFileProcessing.gmk
31
include Utils.gmk
32
include Modules.gmk
33

34
JVM_VARIANT := $(JVM_VARIANT_MAIN)
35
include hotspot/HotspotCommon.gmk
36
include hotspot/lib/JvmFeatures.gmk
37
include hotspot/lib/JvmOverrideFiles.gmk
38
include hotspot/lib/JvmFlags.gmk
39

40
# Random number generation, with the amount of specified digits
41
# No need to check if the parameter passed is a valid number, the shell will
42
# be more than happy to complain if it isn't ;)
43
RandomDigits = \
44
    $(shell od -An -N8 -d /dev/urandom | sed -e 's| ||g' -e 's|\(.\{$(strip $1)\}\).*|\1|')
45

46
# Modified version of utility from JdkNativeCompilation.gmk
47
# The full path could be omitted, but it was chosen not to so wildcard
48
# can work properly for existing directories. The pathsubst below that
49
# this necessitates is a relatively small price to pay.
50
FindModuleNativeDirs = \
51
    $(call uniq, $(wildcard \
52
        $(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native \
53
        $(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native \
54
        $(TOPDIR)/src/$(strip $1)/share/native))
55

56
# Taken from JdkNativeCompilation.gmk
57
FindJavaHeaderDir = \
58
    $(if $(strip $1),$(wildcard $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)))
59

60
JAVA_DIRS := $(strip $(foreach module, $(call FindAllModules), \
61
    $(patsubst $(TOPDIR)/%,%,$(filter-out $(OUTPUTDIR)%, \
62
    $(call FindModuleSrcDirs, $(module))))))
63

64
NATIVE_DIRS := $(strip $(foreach module, $(call FindAllModules), \
65
    $(patsubst $(TOPDIR)/%,%,$(call FindModuleNativeDirs, $(module)))))
66

67
# Emit the defines extracted from the list of options specified in the first parameter into
68
# the language settings file, in Eclipse format.
69
EmitExtractedDefines = \
70
    $(shell echo $(1) | grep -o "\-D\s\?")
71

72
################################################################################
73
# Create an Eclipse Workspace with the specified nature
74
#
75
# Parameter 1 is the name of the rule. This name is used as variable prefix,
76
# and the targets generated are listed in a variable by that name.
77
#
78
# Remaining parameter(s) are named arguments:
79
#   NATURE - Which Eclipse Workspace nature to generate for the Workspace. Can
80
#       be one of JAVA, HOTSPOT, NATIVE, or MIXED.
81
SetupEclipseWorkspace = $(NamedParamsMacroTemplate)
82
define SetupEclipseWorkspaceBody
83

84
  $1_NATURES :=
85
  $1_BUILD_MANAGERS :=
86
  $1_LINKED_RESOURCES :=
87

88
  ifeq ($$($1_NATURE), )
89
    $$(error No nature specified for Eclipse Workspace, cannot continue)
90
  endif
91

92
  ifeq ($$(findstring $$($1_NATURE), JAVA HOTSPOT NATIVE MIXED), )
93
    $$(error Unrecognised nature $$($1_NATURE) specified for Eclipse Workspace)
94
  endif
95

96
  $1_IDE_OUTPUTDIR := $(OUTPUTDIR)/ide/eclipse
97
  $1_CLASSPATH_FILE := $$($1_IDE_OUTPUTDIR)/.classpath
98
  $1_WORKSPACE_FILE := $$($1_IDE_OUTPUTDIR)/.project
99
  $1_NATIVE_FILE := $$($1_IDE_OUTPUTDIR)/.cproject
100
  $1_SETTINGS_FILE := $$($1_IDE_OUTPUTDIR)/.settings/language.settings.xml
101
  $$(call MakeDir, $$($1_IDE_OUTPUTDIR))
102

103
  ifneq ($$(findstring $$($1_NATURE), HOTSPOT NATIVE MIXED), )
104
    ifeq ($$(call isCompiler, microsoft), true)
105
      $$(error Visual C++ is not yet supported as an indexer for Native Workspaces!)
106
    endif
107
  endif
108

109
  ifneq ($$(findstring $$($1_NATURE), JAVA MIXED), )
110

111
    $1_CLASSPATH :=
112

113
    # Eclipse crashes when processing multiple module-info.java files
114
    # This is an annoying bug that has not been fixed for some time now
115
    $1_CLASSPATH += $$(foreach src,$(JAVA_DIRS), \
116
        <classpathentry excluding="module-info.java|module-info.java.extra" kind="src" path="$$(src)"/>$$(NEWLINE))
117

118
    $$(eval $$(call SetupTextFileProcessing, $1_CREATE_CLASSPATH_FILE, \
119
        SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/classpath.template, \
120
        OUTPUT_FILE := $$($1_CLASSPATH_FILE), \
121
        REPLACEMENTS := \
122
            @@CLASSPATH@@ => $$($1_CLASSPATH), \
123
    ))
124

125
    TARGETS += $$($1_CREATE_CLASSPATH_FILE)
126

127
    $1_NATURES += <nature>org.eclipse.jdt.core.javanature</nature>$$(NEWLINE)
128

129
  endif
130

131
  ifneq ($$(findstring $$($1_NATURE), HOTSPOT NATIVE MIXED), )
132

133
    $1_NATIVE_SRCS :=
134

135
    $1_BUILD_MANAGERS += \
136
        <buildCommand> \
137
            <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> \
138
            <triggers>clean$$(COMMA)full$$(COMMA)incremental$$(COMMA)</triggers> \
139
            <arguments> \
140
            </arguments> \
141
        </buildCommand> \
142
        <buildCommand> \
143
            <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> \
144
            <triggers>full$$(COMMA)incremental$$(COMMA)</triggers> \
145
            <arguments> \
146
            </arguments> \
147
        </buildCommand>$$(NEWLINE)
148

149
    $1_NATURES += \
150
        <nature>org.eclipse.cdt.core.cnature</nature> \
151
        <nature>org.eclipse.cdt.core.ccnature</nature> \
152
        <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> \
153
        <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>$$(NEWLINE)
154

155
    # This is always emitted, no matter which of the 3 natures were selected
156
    $1_NATIVE_SRCS += \
157
        <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/hotspot"/>$$(NEWLINE)
158

159
    ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
160
      $1_NATIVE_SRCS += $$(foreach src,$(NATIVE_DIRS), \
161
          <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="$$(strip $$(src))"/>$$(NEWLINE))
162
    endif
163

164
    $1_WORKSPACE_MAJOR := $$(call RandomDigits, 10)
165
    $1_WORKSPACE_MINOR := $$(call RandomDigits, 9)
166

167
    # FixPath already removes $(FIXPATH) automatically, but if we rely on FixPath
168
    # to do it for us dir won't be able to handle the converted path (if on Windows).
169
    # Reversing the order causes dir to mangle the preceeding $(FIXPATH) which breaks
170
    # the ability of FixPath to remove it, so it has to be manually removed here.
171
    #
172
    # Note that the workspace setup system currently does not support Visual C++ when
173
    # extracting compiler and/or system headers vital to the build!
174
    $1_ENV := $$(call FixPath, $$(dir $$(patsubst $(FIXPATH), , $(CC))))
175

176
    # Sidestep annoying issue of WSL path conversion not working properly with true
177
    # Unix paths. Eclipse can't run the WSL make by itself anyway, even if we could
178
    # properly convert the path.
179
    ifeq ($$(call isBuildOsEnv, windows.wsl1 windows.wsl2), true)
180
      $1_MAKE := wsl.exe $(MAKE)
181
    else
182
      $1_MAKE := $$(call FixPath, $(MAKE))
183
    endif
184

185
    # make reconfigure omitted since it is sensitive to which make was used
186
    # make dist-clean omitted since it would delete the Workspace as well
187
    $1_MATCHING_MAKE_TARGETS :=
188
    $1_PLAIN_MAKE_TARGETS := update-build-docs docs gensrc gendata copy java \
189
        launchers libs hotspot jdk product-images product-bundles all-images test-image clean
190

191
    $1_MATCHING_MAKE_TARGETS += $$(foreach name,$$($1_PLAIN_MAKE_TARGETS), \
192
      <target name="$$(strip $$(name))" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> \
193
          <buildCommand>$$($1_MAKE)</buildCommand> \
194
          <buildArguments>-C $$(call FixPath, $(TOPDIR))</buildArguments> \
195
          <buildTarget>$$(strip $$(name))</buildTarget> \
196
          <stopOnError>true</stopOnError> \
197
          <useDefaultCommand>false</useDefaultCommand> \
198
          <runAllBuilders>true</runAllBuilders> \
199
      </target>$$(NEWLINE))
200

201
    $$(eval $$(call SetupTextFileProcessing, $1_CREATE_NATIVE_FILE, \
202
        SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/native.template, \
203
        OUTPUT_FILE := $$($1_NATIVE_FILE), \
204
        REPLACEMENTS := \
205
            @@DIR@@ => $$(call FixPath, $(TOPDIR)) ; \
206
            @@ENV@@ => $$($1_ENV) ; \
207
            @@WORKSPACE@@ => $$($1_WORKSPACE_MAJOR) ; \
208
            @@MINOR@@ =>  $$($1_WORKSPACE_MINOR) ; \
209
            @@MAKE@@ => $$($1_MAKE) ; \
210
            @@SRC@@ => $$($1_NATIVE_SRCS) ; \
211
            @@MAKE_TARGETS@@ => $$($1_MATCHING_MAKE_TARGETS), \
212
    ))
213

214
    TARGETS += $$($1_CREATE_NATIVE_FILE)
215

216
    $$(call MakeDir, $$($1_IDE_OUTPUTDIR)/.settings)
217

218
    $1_CSETTINGS :=
219
    $1_CXXSETTINGS :=
220

221
    ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
222
      $1_CSETTINGS += $$(foreach module, $$(call FindAllModules), $$(if $$(call FindJavaHeaderDir, $$(module)), \
223
          $$(foreach dirs, $$(strip $$(patsubst $(TOPDIR)/%,%,$$(call FindModuleNativeDirs, $$(module)))), \
224
              <resource project-relative-path="$$(dirs)"> \
225
                  <entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(call FindJavaHeaderDir, $$(module)))"/> \
226
                  $$(if $$(findstring jdk.sctp,$$(module)),    <entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(call FindJavaHeaderDir, java.base))"/>) \
227
              </resource>$$(NEWLINE))))
228

229
      # main.c source file used for generic launchers
230
      $1_CSETTINGS += \
231
          <resource project-relative-path="src/java.base/share/native/launcher/main.c"> \
232
              <entry kind="macro" name="LAUNCHER_NAME" value="&quot;$(LAUNCHER_NAME)&quot;"/> \
233
          </resource>$$(NEWLINE)
234
    endif
235

236
    # HotSpot first
237
    $1_CXXSETTINGS += <resource project-relative-path="src/hotspot">$$(NEWLINE)
238

239
    # If only the Java Virtual Machine sources were requested, headers from other parts of
240
    # the native source that it needs will not be available. Add them as include paths here
241
    # instead.
242
    ifeq ($$($1_NATURE), HOTSPOT)
243
      $1_CXXSETTINGS += $$(foreach src, $$(strip $$(patsubst %,%/include,$$(call FindModuleNativeDirs, java.base))), \
244
          $(X)    $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(src))"/>$$(NEWLINE))
245
      $1_CXXSETTINGS += $(X)    $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $(TOPDIR)/src/java.base/share/native/libjimage)"/>$$(NEWLINE)
246
    endif
247

248
    $1_CXXSETTINGS += $(X)    $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $(JVM_VARIANT_OUTPUTDIR)/gensrc)"/>$$(NEWLINE)
249

250
    ifeq ($$(call check-jvm-feature, compiler2), true)
251
      $1_CXXSETTINGS += $(X)    $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles)"/>$$(NEWLINE)
252
    endif
253

254
    $1_CXXSETTINGS += </resource>$$(NEWLINE)
255

256
    $1_CXXSETTINGS += \
257
        <resource project-relative-path="src/hotspot/share/runtime/abstract_vm_version.cpp"> \
258
            <entry kind="macro" name="HOTSPOT_VERSION_STRING" value="&quot;$(VERSION_STRING)&quot;"/> \
259
            <entry kind="macro" name="DEBUG_LEVEL" value="&quot;$(DEBUG_LEVEL)&quot;"/> \
260
            <entry kind="macro" name="HOTSPOT_VM_DISTRO" value="&quot;$(HOTSPOT_VM_DISTRO)&quot;"/> \
261
            <entry kind="macro" name="CPU" value="&quot;$(OPENJDK_TARGET_CPU_VM_VERSION)&quot;"/> \
262
            <entry kind="macro" name="HOTSPOT_BUILD_TIME" value="&quot;$(if $(HOTSPOT_BUILD_TIME),$(HOTSPOT_BUILD_TIME),$(call EpochToISO8601,$(shell $(DATE) +"%s")))&quot;"/> \
263
        </resource> \
264
        <resource project-relative-path="src/hotspot/share/runtime/arguments.cpp"> \
265
            <entry kind="macro" name="HOTSPOT_VERSION_STRING" value="&quot;$(VERSION_STRING)&quot;"/> \
266
            <entry kind="macro" name="DEBUG_LEVEL" value="&quot;$(DEBUG_LEVEL)&quot;"/> \
267
            <entry kind="macro" name="HOTSPOT_VM_DISTRO" value="&quot;$(HOTSPOT_VM_DISTRO)&quot;"/> \
268
            <entry kind="macro" name="CPU" value="&quot;$(OPENJDK_TARGET_CPU_VM_VERSION)&quot;"/> \
269
            <entry kind="macro" name="HOTSPOT_BUILD_TIME" value="&quot;$(if $(HOTSPOT_BUILD_TIME),$(HOTSPOT_BUILD_TIME),$(call EpochToISO8601,$(shell $(DATE) +"%s")))&quot;"/> \
270
        </resource>$$(NEWLINE)
271

272
    # Now the rest of the C++ sources in the codebase
273
    ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
274
      $1_CXXSETTINGS += $$(foreach module, $$(call FindAllModules), $$(if $$(call FindJavaHeaderDir, $$(module)), \
275
          $$(foreach dirs, $$(strip $$(patsubst $(TOPDIR)/%,%,$$(call FindModuleNativeDirs, $$(module)))), \
276
              <resource project-relative-path="$$(dirs)"> \
277
                  <entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(call FindJavaHeaderDir, $$(module)))"/> \
278
              </resource>$$(NEWLINE))))
279
    endif
280

281
    $$(eval $$(call SetupTextFileProcessing, $1_CREATE_SETTINGS_FILE, \
282
        SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/settings.template, \
283
        OUTPUT_FILE := $$($1_SETTINGS_FILE), \
284
        REPLACEMENTS := \
285
            @@WORKSPACE@@ => $$($1_WORKSPACE_MAJOR) ; \
286
            @@CSETTINGS@@ => $$($1_CSETTINGS) ; \
287
            @@CXXSETTINGS@@ => $$($1_CXXSETTINGS), \
288
    ))
289

290
    TARGETS += $$($1_CREATE_SETTINGS_FILE)
291

292
  endif
293

294
  ifneq ($$(findstring $$($1_NATURE), JAVA MIXED), )
295
    $1_LINKED_RESOURCES += $$(foreach src,$(JAVA_DIRS), \
296
        <link> \
297
            <name>$$(strip $$(src))</name> \
298
            <type>2</type> \
299
            <location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/$$(src)))</location> \
300
        </link>$$(NEWLINE))
301
  endif
302

303
  ifneq ($$(findstring $$($1_NATURE), HOTSPOT NATIVE MIXED), )
304
    # CDT includes a Makefile editor, so if CDT support was indicated there's no harm in
305
    # including the make sources as well, since the cost of indexing them is miniscule
306
    $1_LINKED_RESOURCES += \
307
        <link> \
308
            <name>make</name> \
309
            <type>2</type> \
310
            <location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/make))</location> \
311
        </link> \
312
        <link> \
313
            <name>src/hotspot</name> \
314
            <type>2</type> \
315
            <location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/src/hotspot))</location> \
316
        </link>$$(NEWLINE)
317
  endif
318

319
  ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
320
    $1_LINKED_RESOURCES += $$(foreach src,$(NATIVE_DIRS), \
321
        <link> \
322
            <name>$$(strip $$(src))</name> \
323
            <type>2</type> \
324
            <location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/$$(src)))</location> \
325
        </link>$$(NEWLINE))
326
  endif
327

328
  $$(eval $$(call SetupTextFileProcessing, $1_CREATE_WORKSPACE_FILE, \
329
      SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/workspace.template, \
330
      OUTPUT_FILE := $$($1_WORKSPACE_FILE), \
331
      REPLACEMENTS := \
332
          @@BUILD_MANAGERS@@ => $$($1_BUILD_MANAGERS) ; \
333
          @@NATURES@@ => $$($1_NATURES) ; \
334
          @@LINKED_RESOURCES@@ => $$($1_LINKED_RESOURCES), \
335
  ))
336

337
  TARGETS += $$($1_CREATE_WORKSPACE_FILE)
338

339
endef
340

341
ifeq ($(WORKSPACE), java)
342
  $(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
343
      NATURE := JAVA, \
344
  ))
345
else ifeq ($(WORKSPACE), hotspot)
346
  $(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
347
      NATURE := HOTSPOT, \
348
  ))
349
else ifeq ($(WORKSPACE), native)
350
  $(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
351
      NATURE := NATIVE, \
352
  ))
353
else
354
  $(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
355
      NATURE := MIXED, \
356
  ))
357
endif
358

359
all: $(TARGETS)
360

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

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

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

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