view make/gensrc/GensrcJvmti.gmk @ 12199:d87d5d430c42

8063154: Checked in jvmti.h not in sync with generated jvmti.h Reviewed-by: tbell
author erikj
date Wed, 02 Nov 2016 10:43:23 +0100
parents bf6f88c2c086
children fe25e12bd841
line wrap: on
line source
#
# Copyright (c) 2013, 2016, 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.
#

$(eval $(call IncludeCustomExtension, hotspot, gensrc/GensrcJvmti.gmk))

################################################################################
# Build tools needed for the JVMTI source code generation

JVMTI_TOOLS_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/prims
JVMTI_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jvmti

$(eval $(call SetupJavaCompiler, GENERATE_OLDBYTECODE, \
    JAVAC := $(JAVAC), \
    FLAGS := $(DISABLE_WARNINGS), \
    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
    SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
    DISABLE_SJAVAC := true, \
))

$(eval $(call SetupJavaCompilation, BUILD_JVMTI_TOOLS, \
    SETUP := GENERATE_OLDBYTECODE, \
    SRC := $(JVMTI_TOOLS_SRCDIR), \
    INCLUDE_FILES := jvmtiGen.java jvmtiEnvFill.java, \
    BIN := $(JVMTI_TOOLS_OUTPUTDIR), \
))

TOOL_JVMTI_GEN := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiGen
TOOL_JVMTI_ENV_FILL := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiEnvFill

################################################################################
# Setup make rules for an xml transform for jvmti/trace file generation.
#
# 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. This name is
# also used as the name of the output file.
#
# Remaining parameters are named arguments. These include:
#   XML_FILE -- The input source file to use
#   XSL_FILE -- The xsl file to use
#   OUTPUT_DIR -- The directory to put the generated file in
#   ARGS -- Additional arguments to the jvmtiGen tool
#   DEPS -- Additional dependencies
SetupXslTransform = $(NamedParamsMacroTemplate)
define SetupXslTransformBody
  $$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS)
	$$(call LogInfo, Generating $$(@F))
	$$(call MakeDir, $$(@D))
	$$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
	    -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
        # jvmtiGen does not return error code properly on fail.
        # NOTE: We should really fix jvmtiGen.java instead.
	test -f $$@

  TARGETS += $$($1_OUTPUT_DIR)/$1
endef

################################################################################
# Create JVMTI files in gensrc/jvmtifiles

JVMTI_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/prims
JVMTI_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles

# Setup rule for generating a jvmti file
#
# $1 is generated source file name in $(JVMTI_OUTPUTDIR)
# $2 is XSL file to use in $(JVMTI_SRCDIR)
# $3 is optional extra arguments to jvmtiGen
define SetupJvmtiGeneration
  $$(eval $$(call SetupXslTransform, $1, \
      XML_FILE := $$(JVMTI_SRCDIR)/jvmti.xml, \
      XSL_FILE := $$(JVMTI_SRCDIR)/$(strip $2), \
      OUTPUT_DIR := $$(JVMTI_OUTPUTDIR), \
      ARGS := $3, \
      DEPS := $$(JVMTI_SRCDIR)/jvmtiLib.xsl, \
  ))
endef

$(eval $(call SetupJvmtiGeneration, jvmtiEnter.cpp, jvmtiEnter.xsl, \
    -PARAM interface jvmti))
$(eval $(call SetupJvmtiGeneration, jvmtiEnterTrace.cpp, jvmtiEnter.xsl, \
    -PARAM interface jvmti -PARAM trace Trace))
$(eval $(call SetupJvmtiGeneration, jvmtiEnv.hpp, jvmtiHpp.xsl))
$(eval $(call SetupJvmtiGeneration, jvmti.h, jvmtiH.xsl))
$(eval $(call SetupJvmtiGeneration, jvmti.html, jvmti.xsl))
$(eval $(call SetupJvmtiGeneration, jvmtiEnvStub.cpp, jvmtiEnv.xsl))

JVMTI_BC_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/interpreter

$(eval $(call SetupXslTransform, bytecodeInterpreterWithChecks.cpp, \
    XML_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xml, \
    XSL_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xsl, \
    OUTPUT_DIR := $(JVMTI_OUTPUTDIR), \
    DEPS := $(JVMTI_BC_SRCDIR)/bytecodeInterpreter.cpp, \
))

# We need $(JVMTI_OUTPUTDIR)/jvmtiEnvStub.cpp (generated above) as input
$(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp: $(JVMTI_SRCDIR)/jvmtiEnv.cpp \
    $(JVMTI_OUTPUTDIR)/jvmtiEnvStub.cpp $(BUILD_JVMTI_TOOLS)
	$(call LogInfo, Generating $(@F))
	$(call MakeDir, $(@D))
	$(call ExecuteWithLog, $@, $(TOOL_JVMTI_ENV_FILL) $(JVMTI_SRCDIR)/jvmtiEnv.cpp \
	    $(JVMTI_OUTPUTDIR)/jvmtiEnvStub.cpp \
	    $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp)
        # jvmtiEnvFill does not necessarily return an error code on failure.
        # NOTE: We should really fix jvmtiEnvFill.java instead.
	test -f $@

TARGETS += $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp

################################################################################
# Disable copy of jvmti.h from hotspot until this has been cleared up. The file
# is currently being copied from the jdk repository. See JDK-8167078.
# Copy jvmti.h to include dir

# The file is the same regardless of jvm variant. Only let one do the copy.
ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
  $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
      DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \
      FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \
  ))

  TARGETS += $(COPY_JVMTI_H)
endif

################################################################################
# Create trace files in gensrc/tracefiles

TRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles
TRACE_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/trace

# Append list of XSL files to search (might have been set by custom extensions)
TRACE_XSL_FILES += $(wildcard $(TRACE_SRCDIR)/*.xsl)

TRACE_XML ?= $(TRACE_SRCDIR)/trace.xml

# Changing these will trigger a rebuild of generated trace files.
TRACE_DEPS += \
    $(TRACE_XML) \
    $(TRACE_SRCDIR)/tracetypes.xml \
    $(TRACE_SRCDIR)/tracerelationdecls.xml \
    $(TRACE_SRCDIR)/traceevents.xml \
    $(TRACE_SRCDIR)/trace.dtd \
    $(TRACE_SRCDIR)/xinclude.mod \
    #

# Setup rule for generating a trace file
#
# $1 is generated source file name in $(TRACE_OUTPUTDIR)
define SetupTraceGeneration
  $$(eval $$(call SetupXslTransform, $1, \
      XML_FILE := $$(TRACE_XML), \
      XSL_FILE := $$(firstword $$(filter %/$$(basename $1).xsl, $$(TRACE_XSL_FILES))), \
      OUTPUT_DIR := $$(TRACE_OUTPUTDIR), \
      DEPS := $$(TRACE_DEPS), \
  ))
endef

# Append files to generated (might have been set by custom extensions)
TRACE_GENSRC_FILES += \
    traceEventClasses.hpp \
    traceEventIds.hpp \
    traceTypes.hpp \
    #

# Call SetupTraceGeneration for all trace gensrc files
$(foreach tracefile, $(TRACE_GENSRC_FILES), \
  $(eval $(call SetupTraceGeneration, $(tracefile))) \
)