1#
2# Copyright (c) 2013, 2020, 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$(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcJvmti.gmk))
27
28################################################################################
29# Build tools needed for the JVMTI source code generation
30
31# FIXME: jvmtiGen.java should move to make/src, jvmtiEnvFill.java should be removed.
32JVMTI_TOOLS_SRCDIR := $(TOPDIR)/src/hotspot/share/prims
33JVMTI_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jvmti
34
35$(eval $(call SetupJavaCompilation, BUILD_JVMTI_TOOLS, \
36    COMPILER := bootjdk, \
37    SMALL_JAVA := false, \
38    SRC := $(JVMTI_TOOLS_SRCDIR), \
39    DISABLED_WARNINGS := rawtypes cast, \
40    INCLUDE_FILES := jvmtiGen.java jvmtiEnvFill.java, \
41    BIN := $(JVMTI_TOOLS_OUTPUTDIR), \
42))
43
44TOOL_JVMTI_GEN := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiGen
45TOOL_JVMTI_ENV_FILL := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiEnvFill
46
47################################################################################
48# Setup make rules for an xml transform for jvmti file generation.
49#
50# Parameter 1 is the name of the rule. This name is used as variable prefix,
51# and the targets generated are listed in a variable by that name. This name is
52# also used as the name of the output file.
53#
54# Remaining parameters are named arguments. These include:
55#   XML_FILE -- The input source file to use
56#   XSL_FILE -- The xsl file to use
57#   OUTPUT_DIR -- The directory to put the generated file in
58#   ARGS -- Additional arguments to the jvmtiGen tool
59#   DEPS -- Additional dependencies
60SetupXslTransform = $(NamedParamsMacroTemplate)
61define SetupXslTransformBody
62  $1_OUTPUT_FILE := $$($1_OUTPUT_DIR)/$1
63
64  $$(eval $$(call SetupExecute, jvmti_gen_$1, \
65      INFO := Generating jvmti file $1, \
66      DEPS := $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS), \
67      OUTPUT_FILE := $$($1_OUTPUT_FILE), \
68      COMMAND := $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
69          -XSL $$($1_XSL_FILE) -OUT $$($1_OUTPUT_FILE) $$($1_ARGS), \
70  ))
71
72  TARGETS += $$(jvmti_gen_$1_TARGET)
73endef
74
75################################################################################
76# Create JVMTI files in gensrc/jvmtifiles
77
78JVMTI_SRCDIR := $(TOPDIR)/src/hotspot/share/prims
79JVMTI_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles
80
81# Setup rule for generating a jvmti file
82#
83# $1 is generated source file name in $(JVMTI_OUTPUTDIR)
84# $2 is XSL file to use in $(JVMTI_SRCDIR)
85# $3 is optional extra arguments to jvmtiGen
86define SetupJvmtiGeneration
87  $$(eval $$(call SetupXslTransform, $1, \
88      XML_FILE := $$(JVMTI_SRCDIR)/jvmti.xml, \
89      XSL_FILE := $$(JVMTI_SRCDIR)/$(strip $2), \
90      OUTPUT_DIR := $$(JVMTI_OUTPUTDIR), \
91      ARGS := $3, \
92      DEPS := $$(JVMTI_SRCDIR)/jvmtiLib.xsl, \
93  ))
94endef
95
96$(eval $(call SetupJvmtiGeneration, jvmtiEnter.cpp, jvmtiEnter.xsl, \
97    -PARAM majorversion $(VERSION_FEATURE) \
98    -PARAM interface jvmti))
99$(eval $(call SetupJvmtiGeneration, jvmtiEnterTrace.cpp, jvmtiEnter.xsl, \
100    -PARAM majorversion $(VERSION_FEATURE) \
101    -PARAM interface jvmti -PARAM trace Trace))
102$(eval $(call SetupJvmtiGeneration, jvmtiEnv.hpp, jvmtiHpp.xsl, \
103    -PARAM majorversion $(VERSION_FEATURE)))
104$(eval $(call SetupJvmtiGeneration, jvmti.h, jvmtiH.xsl, \
105    -PARAM majorversion $(VERSION_FEATURE)))
106$(eval $(call SetupJvmtiGeneration, jvmti.html, jvmti.xsl, \
107    -PARAM majorversion $(VERSION_FEATURE)))
108
109################################################################################
110# Copy jvmti.h to include dir
111
112# The file is the same regardless of jvm variant. Only let one do the copy.
113ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
114  $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
115      DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \
116      FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \
117  ))
118
119  TARGETS += $(COPY_JVMTI_H)
120endif
121