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