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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
|
#
# Copyright (c) 2016, 2022, 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.
#
default: all
include $(SPEC)
include MakeBase.gmk
include TextFileProcessing.gmk
include Utils.gmk
include Modules.gmk
JVM_VARIANT := $(JVM_VARIANT_MAIN)
include hotspot/HotspotCommon.gmk
include hotspot/lib/JvmFeatures.gmk
include hotspot/lib/JvmOverrideFiles.gmk
include hotspot/lib/JvmFlags.gmk
# Random number generation, with the amount of specified digits
# No need to check if the parameter passed is a valid number, the shell will
# be more than happy to complain if it isn't ;)
RandomDigits = \
$(shell od -An -N8 -d /dev/urandom | sed -e 's| ||g' -e 's|\(.\{$(strip $1)\}\).*|\1|')
# Modified version of utility from JdkNativeCompilation.gmk
# The full path could be omitted, but it was chosen not to so wildcard
# can work properly for existing directories. The pathsubst below that
# this necessitates is a relatively small price to pay.
FindModuleNativeDirs = \
$(call uniq, $(wildcard \
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native \
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native \
$(TOPDIR)/src/$(strip $1)/share/native))
# Taken from JdkNativeCompilation.gmk
FindJavaHeaderDir = \
$(if $(strip $1),$(wildcard $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)))
JAVA_DIRS := $(strip $(foreach module, $(call FindAllModules), \
$(patsubst $(TOPDIR)/%,%,$(filter-out $(OUTPUTDIR)%, \
$(call FindModuleSrcDirs, $(module))))))
NATIVE_DIRS := $(strip $(foreach module, $(call FindAllModules), \
$(patsubst $(TOPDIR)/%,%,$(call FindModuleNativeDirs, $(module)))))
# Emit the defines extracted from the list of options specified in the first parameter into
# the language settings file, in Eclipse format.
EmitExtractedDefines = \
$(shell echo $(1) | grep -o "\-D\s\?")
################################################################################
# Create an Eclipse Workspace with the specified nature
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameter(s) are named arguments:
# NATURE - Which Eclipse Workspace nature to generate for the Workspace. Can
# be one of JAVA, HOTSPOT, NATIVE, or MIXED.
# SHARED - Workspace will share the same directory as the JDK if true. Can be
# either true or false. Defaults to false if not specified.
SetupEclipseWorkspace = $(NamedParamsMacroTemplate)
define SetupEclipseWorkspaceBody
$1_NATURES :=
$1_BUILD_MANAGERS :=
$1_LINKED_RESOURCES :=
ifeq ($$($1_NATURE), )
$$(error No nature specified for Eclipse Workspace, cannot continue)
endif
ifeq ($$(findstring $$($1_NATURE), JAVA HOTSPOT NATIVE MIXED), )
$$(error Unrecognised nature $$($1_NATURE) specified for Eclipse Workspace)
endif
ifeq ($$($1_SHARED), )
$$(info Workspace sharing option not given, assuming non-shared Eclipse Workspace)
$1_SHARED := false
else ifeq ($$(findstring $$($1_SHARED), true false), )
$$(error $$($1_NATURE) is not a boolean word)
endif
ifeq ($$($1_SHARED), true)
$1_CLASSPATH_FILE := $(TOPDIR)/.classpath
$1_WORKSPACE_FILE := $(TOPDIR)/.project
$1_NATIVE_FILE := $(TOPDIR)/.cproject
$1_SETTINGS_FILE := $(TOPDIR)/.settings/language.settings.xml
else
$1_IDE_OUTPUTDIR := $(OUTPUTDIR)/ide/eclipse
$1_CLASSPATH_FILE := $$($1_IDE_OUTPUTDIR)/.classpath
$1_WORKSPACE_FILE := $$($1_IDE_OUTPUTDIR)/.project
$1_NATIVE_FILE := $$($1_IDE_OUTPUTDIR)/.cproject
$1_SETTINGS_FILE := $$($1_IDE_OUTPUTDIR)/.settings/language.settings.xml
$$(call MakeDir, $$($1_IDE_OUTPUTDIR))
endif
ifneq ($$(findstring $$($1_NATURE), HOTSPOT NATIVE MIXED), )
ifeq ($$(call isCompiler, microsoft), true)
$$(error Visual C++ is not yet supported as an indexer for Native Workspaces!)
endif
endif
ifneq ($$(findstring $$($1_NATURE), JAVA MIXED), )
$1_CLASSPATH :=
# Eclipse crashes when processing multiple module-info.java files
# This is an annoying bug that has not been fixed for some time now
$1_CLASSPATH += $$(foreach src,$(JAVA_DIRS), \
<classpathentry excluding="module-info.java|module-info.java.extra" kind="src" path="$$(src)"/>$$(NEWLINE))
$$(eval $$(call SetupTextFileProcessing, $1_CREATE_CLASSPATH_FILE, \
SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/classpath.template, \
OUTPUT_FILE := $$($1_CLASSPATH_FILE), \
REPLACEMENTS := \
@@CLASSPATH@@ => $$($1_CLASSPATH), \
))
TARGETS += $$($1_CREATE_CLASSPATH_FILE)
$1_NATURES += <nature>org.eclipse.jdt.core.javanature</nature>$$(NEWLINE)
endif
ifneq ($$(findstring $$($1_NATURE), HOTSPOT NATIVE MIXED), )
$1_NATIVE_SRCS :=
$1_BUILD_MANAGERS += \
<buildCommand> \
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> \
<triggers>clean$$(COMMA)full$$(COMMA)incremental$$(COMMA)</triggers> \
<arguments> \
</arguments> \
</buildCommand> \
<buildCommand> \
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> \
<triggers>full$$(COMMA)incremental$$(COMMA)</triggers> \
<arguments> \
</arguments> \
</buildCommand>$$(NEWLINE)
$1_NATURES += \
<nature>org.eclipse.cdt.core.cnature</nature> \
<nature>org.eclipse.cdt.core.ccnature</nature> \
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> \
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>$$(NEWLINE)
# This is always emitted, no matter which of the 3 natures were selected
$1_NATIVE_SRCS += \
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/hotspot"/>$$(NEWLINE)
ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
$1_NATIVE_SRCS += $$(foreach src,$(NATIVE_DIRS), \
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="$$(strip $$(src))"/>$$(NEWLINE))
endif
$1_WORKSPACE_MAJOR := $$(call RandomDigits, 10)
$1_WORKSPACE_MINOR := $$(call RandomDigits, 9)
# FixPath already removes $(FIXPATH) automatically, but if we rely on FixPath
# to do it for us dir won't be able to handle the converted path (if on Windows).
# Reversing the order causes dir to mangle the preceeding $(FIXPATH) which breaks
# the ability of FixPath to remove it, so it has to be manually removed here.
#
# Note that the workspace setup system currently does not support Visual C++ when
# extracting compiler and/or system headers vital to the build!
$1_ENV := $$(call FixPath, $$(dir $$(patsubst $(FIXPATH), , $(CC))))
# Sidestep annoying issue of WSL path conversion not working properly with true
# Unix paths. Eclipse can't run the WSL make by itself anyway, even if we could
# properly convert the path.
ifeq ($$(call isBuildOsEnv, windows.wsl1 windows.wsl2), true)
$1_MAKE := wsl.exe $(MAKE)
else
$1_MAKE := $$(call FixPath, $(MAKE))
endif
$1_MATCHING_MAKE_TARGETS :=
$1_PLAIN_MAKE_TARGETS := update-build-docs docs gensrc gendata \
copy java launchers libs hotspot jdk product-images all-images test-image clean
# make reconfigure omitted since it is sensitive to which make was used
ifeq ($$($1_SHARED), true)
$1_PLAIN_MAKE_TARGETS += dist-clean
endif
$1_MATCHING_MAKE_TARGETS += $$(foreach name,$$($1_PLAIN_MAKE_TARGETS), \
<target name="$$(strip $$(name))" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> \
<buildCommand>$$($1_MAKE)</buildCommand> \
<buildArguments>-C $$(call FixPath, $(TOPDIR))</buildArguments> \
<buildTarget>$$(strip $$(name))</buildTarget> \
<stopOnError>true</stopOnError> \
<useDefaultCommand>false</useDefaultCommand> \
<runAllBuilders>true</runAllBuilders> \
</target>$$(NEWLINE))
$$(eval $$(call SetupTextFileProcessing, $1_CREATE_NATIVE_FILE, \
SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/native.template, \
OUTPUT_FILE := $$($1_NATIVE_FILE), \
REPLACEMENTS := \
@@DIR@@ => $$(call FixPath, $(TOPDIR)) ; \
@@ENV@@ => $$($1_ENV) ; \
@@WORKSPACE@@ => $$($1_WORKSPACE_MAJOR) ; \
@@MINOR@@ => $$($1_WORKSPACE_MINOR) ; \
@@MAKE@@ => $$($1_MAKE) ; \
@@SRC@@ => $$($1_NATIVE_SRCS) ; \
@@MAKE_TARGETS@@ => $$($1_MATCHING_MAKE_TARGETS), \
))
TARGETS += $$($1_CREATE_NATIVE_FILE)
ifeq ($$($1_SHARED), true)
$$(call MakeDir, $(TOPDIR)/.settings)
else
$$(call MakeDir, $$($1_IDE_OUTPUTDIR)/.settings)
endif
$1_CSETTINGS :=
$1_CXXSETTINGS :=
ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
$1_CSETTINGS += $$(foreach module, $$(call FindAllModules), $$(if $$(call FindJavaHeaderDir, $$(module)), \
$$(foreach dirs, $$(strip $$(patsubst $(TOPDIR)/%,%,$$(call FindModuleNativeDirs, $$(module)))), \
<resource project-relative-path="$$(dirs)"> \
<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(call FindJavaHeaderDir, $$(module)))"/> \
$$(if $$(findstring jdk.sctp,$$(module)), <entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(call FindJavaHeaderDir, java.base))"/>) \
</resource>$$(NEWLINE))))
# main.c source file used for generic launchers
$1_CSETTINGS += \
<resource project-relative-path="src/java.base/share/native/launcher/main.c"> \
<entry kind="macro" name="LAUNCHER_NAME" value=""$(LAUNCHER_NAME)""/> \
</resource>$$(NEWLINE)
endif
# HotSpot first
$1_CXXSETTINGS += <resource project-relative-path="src/hotspot">$$(NEWLINE)
# If only the Java Virtual Machine sources were requested, headers from other parts of
# the native source that it needs will not be available. Add them as include paths here
# instead.
ifeq ($$($1_NATURE), HOTSPOT)
$1_CXXSETTINGS += $$(foreach src, $$(strip $$(patsubst %,%/include,$$(call FindModuleNativeDirs, java.base))), \
$(X) $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(src))"/>$$(NEWLINE))
$1_CXXSETTINGS += $(X) $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $(TOPDIR)/src/java.base/share/native/libjimage)"/>$$(NEWLINE)
endif
$1_CXXSETTINGS += $(X) $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $(JVM_VARIANT_OUTPUTDIR)/gensrc)"/>$$(NEWLINE)
ifeq ($$(call check-jvm-feature, compiler2), true)
$1_CXXSETTINGS += $(X) $(X)<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles)"/>$$(NEWLINE)
endif
$1_CXXSETTINGS += </resource>$$(NEWLINE)
$1_CXXSETTINGS += \
<resource project-relative-path="src/hotspot/share/runtime/abstract_vm_version.cpp"> \
<entry kind="macro" name="HOTSPOT_VERSION_STRING" value=""$(VERSION_STRING)""/> \
<entry kind="macro" name="DEBUG_LEVEL" value=""$(DEBUG_LEVEL)""/> \
<entry kind="macro" name="HOTSPOT_BUILD_USER" value=""$(USERNAME)""/> \
<entry kind="macro" name="HOTSPOT_VM_DISTRO" value=""$(HOTSPOT_VM_DISTRO)""/> \
<entry kind="macro" name="CPU" value=""$(OPENJDK_TARGET_CPU_VM_VERSION)""/> \
<entry kind="macro" name="HOTSPOT_BUILD_TIME" value=""$(if $(HOTSPOT_BUILD_TIME),$(HOTSPOT_BUILD_TIME),$(call EpochToISO8601,$(shell $(DATE) +"%s")))""/> \
</resource> \
<resource project-relative-path="src/hotspot/share/runtime/arguments.cpp"> \
<entry kind="macro" name="HOTSPOT_VERSION_STRING" value=""$(VERSION_STRING)""/> \
<entry kind="macro" name="DEBUG_LEVEL" value=""$(DEBUG_LEVEL)""/> \
<entry kind="macro" name="HOTSPOT_BUILD_USER" value=""$(USERNAME)""/> \
<entry kind="macro" name="HOTSPOT_VM_DISTRO" value=""$(HOTSPOT_VM_DISTRO)""/> \
<entry kind="macro" name="CPU" value=""$(OPENJDK_TARGET_CPU_VM_VERSION)""/> \
<entry kind="macro" name="HOTSPOT_BUILD_TIME" value=""$(if $(HOTSPOT_BUILD_TIME),$(HOTSPOT_BUILD_TIME),$(call EpochToISO8601,$(shell $(DATE) +"%s")))""/> \
</resource>$$(NEWLINE)
# Now the rest of the C++ sources in the codebase
ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
$1_CXXSETTINGS += $$(foreach module, $$(call FindAllModules), $$(if $$(call FindJavaHeaderDir, $$(module)), \
$$(foreach dirs, $$(strip $$(patsubst $(TOPDIR)/%,%,$$(call FindModuleNativeDirs, $$(module)))), \
<resource project-relative-path="$$(dirs)"> \
<entry flags="LOCAL" kind="includePath" name="$$(call FixPath, $$(call FindJavaHeaderDir, $$(module)))"/> \
</resource>$$(NEWLINE))))
endif
$$(eval $$(call SetupTextFileProcessing, $1_CREATE_SETTINGS_FILE, \
SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/settings.template, \
OUTPUT_FILE := $$($1_SETTINGS_FILE), \
REPLACEMENTS := \
@@WORKSPACE@@ => $$($1_WORKSPACE_MAJOR) ; \
@@CSETTINGS@@ => $$($1_CSETTINGS) ; \
@@CXXSETTINGS@@ => $$($1_CXXSETTINGS), \
))
TARGETS += $$($1_CREATE_SETTINGS_FILE)
endif
ifeq ($$($1_SHARED), false)
ifneq ($$(findstring $$($1_NATURE), JAVA MIXED), )
$1_LINKED_RESOURCES += $$(foreach src,$(JAVA_DIRS), \
<link> \
<name>$$(strip $$(src))</name> \
<type>2</type> \
<location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/$$(src)))</location> \
</link>$$(NEWLINE))
endif
ifneq ($$(findstring $$($1_NATURE), HOTSPOT NATIVE MIXED), )
# CDT includes a Makefile editor, so if CDT support was indicated there's no harm in
# including the make sources as well, since the cost of indexing them is miniscule
$1_LINKED_RESOURCES += \
<link> \
<name>make</name> \
<type>2</type> \
<location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/make))</location> \
</link> \
<link> \
<name>src/hotspot</name> \
<type>2</type> \
<location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/src/hotspot))</location> \
</link>$$(NEWLINE)
endif
ifneq ($$(findstring $$($1_NATURE), NATIVE MIXED), )
$1_LINKED_RESOURCES += $$(foreach src,$(NATIVE_DIRS), \
<link> \
<name>$$(strip $$(src))</name> \
<type>2</type> \
<location>$$(subst \\,/,$$(call FixPath, $(TOPDIR)/$$(src)))</location> \
</link>$$(NEWLINE))
endif
endif
$$(eval $$(call SetupTextFileProcessing, $1_CREATE_WORKSPACE_FILE, \
SOURCE_FILES := $(TOPDIR)/make/ide/eclipse/workspace.template, \
OUTPUT_FILE := $$($1_WORKSPACE_FILE), \
REPLACEMENTS := \
@@BUILD_MANAGERS@@ => $$($1_BUILD_MANAGERS) ; \
@@NATURES@@ => $$($1_NATURES) ; \
@@LINKED_RESOURCES@@ => $$($1_LINKED_RESOURCES), \
))
TARGETS += $$($1_CREATE_WORKSPACE_FILE)
endef
ifeq ($(WORKSPACE), java)
$(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
NATURE := JAVA, \
SHARED := $(SHARED), \
))
else ifeq ($(WORKSPACE), hotspot)
$(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
NATURE := HOTSPOT, \
SHARED := $(SHARED), \
))
else ifeq ($(WORKSPACE), native)
$(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
NATURE := NATIVE, \
SHARED := $(SHARED), \
))
else
$(eval $(call SetupEclipseWorkspace, SETUP_WORKSPACE, \
NATURE := MIXED, \
SHARED := $(SHARED), \
))
endif
all: $(TARGETS)
|