8214309: Enhance makefiles to allow generating JCov instrumented build

Reviewed-by: erikj
This commit is contained in:
Alexandre Iline 2018-11-29 06:34:46 -08:00
parent e6eddb6739
commit 4dfa364ff1
6 changed files with 137 additions and 5 deletions

View File

@ -262,6 +262,21 @@ endif
################################################################################ ################################################################################
ifneq ($(filter jcov-bundles, $(MAKECMDGOALS)), )
JCOV_BUNDLE_FILES := $(call CacheFind, $(JCOV_IMAGE_DIR))
$(eval $(call SetupBundleFile, BUILD_JCOV_BUNDLE, \
BUNDLE_NAME := $(JCOV_BUNDLE_NAME), \
FILES := $(JCOV_BUNDLE_FILES), \
BASE_DIRS := $(JCOV_IMAGE_DIR), \
SUBDIR := $(JDK_BUNDLE_SUBDIR), \
))
JCOV_TARGETS += $(BUILD_JCOV_BUNDLE)
endif
################################################################################
# Hook to include the corresponding custom file, if present. # Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, Bundles.gmk)) $(eval $(call IncludeCustomExtension, Bundles.gmk))
@ -270,5 +285,6 @@ $(eval $(call IncludeCustomExtension, Bundles.gmk))
product-bundles: $(PRODUCT_TARGETS) product-bundles: $(PRODUCT_TARGETS)
test-bundles: $(TEST_TARGETS) test-bundles: $(TEST_TARGETS)
docs-bundles: $(DOCS_TARGETS) docs-bundles: $(DOCS_TARGETS)
jcov-bundles: $(JCOV_TARGETS)
.PHONY: all default product-bundles test-bundles docs-bundles .PHONY: all default product-bundles test-bundles docs-bundles jcov-bundles

56
make/Coverage.gmk Normal file
View File

@ -0,0 +1,56 @@
#
# Copyright (c) 2018, 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.
include $(SPEC)
include MakeBase.gmk
################################################################################
JCOV_INPUT_IMAGE_DIR :=
ifneq ($(JCOV_INPUT_JDK), )
JCOV_INPUT_IMAGE_DIR := $(JCOV_INPUT_JDK)
else
JCOV_INPUT_IMAGE_DIR := $(JDK_IMAGE_DIR)
endif
#moving instrumented jdk image in and out of jcov_temp because of CODETOOLS-7902299
JCOV_TEMP := $(SUPPORT_OUTPUTDIR)/jcov_temp
$(JCOV_IMAGE_DIR)/release: $(JCOV_INPUT_IMAGE_DIR)/release
$(call LogWarn, Creating instrumented jdk image with JCov)
$(call MakeDir, $(JCOV_TEMP) $(IMAGES_OUTPUTDIR))
$(RM) -r $(JCOV_IMAGE_DIR) $(JCOV_TEMP)/*
$(CP) -r $(JCOV_INPUT_IMAGE_DIR) $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR)
$(JAVA) -Xmx3g -jar $(JCOV_HOME)/lib/jcov.jar JREInstr \
-t $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR)/template.xml \
-rt $(JCOV_HOME)/lib/jcov_network_saver.jar \
-exclude 'java.lang.Object' \
-exclude 'jdk.internal.org.objectweb.**' \
-exclude jdk.test.Main -exclude '**\$Proxy*' \
$(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR)
$(MV) $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR) $(JCOV_IMAGE_DIR)
$(RMDIR) $(JCOV_TEMP)
jcov-image: $(JCOV_IMAGE_DIR)/release

View File

@ -371,10 +371,15 @@ release-file:
exploded-image-optimize: exploded-image-optimize:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk) +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk)
ifeq ($(JCOV_ENABLED), true)
jcov-image:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Coverage.gmk jcov-image)
endif
ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \ ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \
zip-source jrtfs-jar jdk-image legacy-jre-image \ zip-source jrtfs-jar jdk-image legacy-jre-image \
symbols-image mac-jdk-bundle mac-legacy-jre-bundle \ symbols-image mac-jdk-bundle mac-legacy-jre-bundle \
release-file exploded-image-optimize release-file exploded-image-optimize jcov-image
################################################################################ ################################################################################
# Docs targets # Docs targets
@ -577,7 +582,12 @@ test-bundles:
docs-bundles: docs-bundles:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles) +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)
ALL_TARGETS += product-bundles test-bundles docs-bundles ifeq ($(JCOV_ENABLED), true)
jcov-bundles:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk jcov-bundles)
endif
ALL_TARGETS += product-bundles test-bundles docs-bundles jcov-bundles
################################################################################ ################################################################################
# Install targets # Install targets
@ -820,6 +830,10 @@ else
mac-jdk-bundle: jdk-image mac-jdk-bundle: jdk-image
mac-legacy-jre-bundle: legacy-jre-image mac-legacy-jre-bundle: legacy-jre-image
ifeq ($(JCOV_INPUT_JDK), )
jcov-image: jdk-image
endif
# The optimize target can run as soon as the modules dir has been completely # The optimize target can run as soon as the modules dir has been completely
# populated (java, copy and gendata targets) and the basic libs and launchers # populated (java, copy and gendata targets) and the basic libs and launchers
# have been built. # have been built.
@ -900,6 +914,8 @@ else
docs-bundles: docs-image docs-bundles: docs-image
jcov-bundles: jcov-image
generate-summary: jmods buildtools-modules generate-summary: jmods buildtools-modules
update-x11wrappers: java.base-copy buildtools-jdk update-x11wrappers: java.base-copy buildtools-jdk

View File

@ -395,8 +395,37 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
elif test "x$enable_native_coverage" != "x"; then elif test "x$enable_native_coverage" != "x"; then
AC_MSG_ERROR([--enable-native-coverage can only be assigned "yes" or "no"]) AC_MSG_ERROR([--enable-native-coverage can only be assigned "yes" or "no"])
fi fi
AC_SUBST(GCOV_ENABLED) AC_SUBST(GCOV_ENABLED)
AC_ARG_WITH(jcov, [AS_HELP_STRING([--with-jcov],
[jcov library location])])
AC_ARG_WITH(jcov-input-jdk, [AS_HELP_STRING([--with-jcov-input-jdk],
[jdk image to instrument])])
JCOV_HOME=
JCOV_INPUT_JDK=
JCOV_ENABLED=
if test "x$with_jcov" = "x" ; then
JCOV_ENABLED="false"
else
JCOV_HOME="$with_jcov"
if test ! -f "$JCOV_HOME/lib/jcov.jar"; then
AC_MSG_RESULT([fail])
AC_MSG_ERROR([Invalid JCov bundle: "$JCOV_HOME/lib/jcov.jar" does not exist])
fi
JCOV_ENABLED="true"
BASIC_FIXUP_PATH(JCOV_HOME)
if test "x$with_jcov_input_jdk" != "x" ; then
JCOV_INPUT_JDK="$with_jcov_input_jdk"
if test ! -f "$JCOV_INPUT_JDK/bin/java$EXE_SUFFIX"; then
AC_MSG_RESULT([fail])
AC_MSG_ERROR([Invalid JDK bundle: "$JCOV_INPUT_JDK/bin/java$EXE_SUFFIX" does not exist])
fi
BASIC_FIXUP_PATH(JCOV_INPUT_JDK)
fi
fi
AC_SUBST(JCOV_ENABLED)
AC_SUBST(JCOV_HOME)
AC_SUBST(JCOV_INPUT_JDK)
]) ])
############################################################################### ###############################################################################

View File

@ -372,6 +372,9 @@ CACERTS_FILE=@CACERTS_FILE@
UNLIMITED_CRYPTO=@UNLIMITED_CRYPTO@ UNLIMITED_CRYPTO=@UNLIMITED_CRYPTO@
GCOV_ENABLED=@GCOV_ENABLED@ GCOV_ENABLED=@GCOV_ENABLED@
JCOV_ENABLED=@JCOV_ENABLED@
JCOV_HOME=@JCOV_HOME@
JCOV_INPUT_JDK=@JCOV_INPUT_JDK@
# AddressSanitizer # AddressSanitizer
export ASAN_ENABLED:=@ASAN_ENABLED@ export ASAN_ENABLED:=@ASAN_ENABLED@
@ -839,10 +842,12 @@ OS_VERSION_MICRO:=@OS_VERSION_MICRO@
# Images directory definitions # Images directory definitions
JDK_IMAGE_SUBDIR:=jdk JDK_IMAGE_SUBDIR:=jdk
JRE_IMAGE_SUBDIR:=jre JRE_IMAGE_SUBDIR:=jre
JCOV_IMAGE_SUBDIR := jdk-jcov
# Colon left out to be able to override output dir for bootcycle-images # Colon left out to be able to override output dir for bootcycle-images
JDK_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR) JDK_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR)
JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR) JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR)
JCOV_IMAGE_DIR = $(IMAGES_OUTPUTDIR)/$(JCOV_IMAGE_SUBDIR)
# Test image, as above # Test image, as above
TEST_IMAGE_SUBDIR:=test TEST_IMAGE_SUBDIR:=test
@ -889,12 +894,14 @@ JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
TEST_DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests-demos$(DEBUG_PART).tar.gz TEST_DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests-demos$(DEBUG_PART).tar.gz
TEST_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests$(DEBUG_PART).tar.gz TEST_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests$(DEBUG_PART).tar.gz
DOCS_BUNDLE_NAME := jdk-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz DOCS_BUNDLE_NAME := jdk-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz
JCOV_BUNDLE_NAME := jdk-jcov-$(BASE_NAME)_bin$(DEBUG_PART).$(JDK_BUNDLE_EXTENSION)
JDK_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_BUNDLE_NAME) JDK_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_BUNDLE_NAME)
JDK_SYMBOLS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_SYMBOLS_BUNDLE_NAME) JDK_SYMBOLS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_SYMBOLS_BUNDLE_NAME)
TEST_DEMOS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(TEST_DEMOS_BUNDLE_NAME) TEST_DEMOS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(TEST_DEMOS_BUNDLE_NAME)
TEST_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(TEST_BUNDLE_NAME) TEST_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(TEST_BUNDLE_NAME)
DOCS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(DOCS_BUNDLE_NAME) DOCS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(DOCS_BUNDLE_NAME)
JCOV_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JCOV_BUNDLE_NAME)
# This macro is called to allow inclusion of closed source counterparts. # This macro is called to allow inclusion of closed source counterparts.
# Unless overridden in closed sources, it expands to nothing. # Unless overridden in closed sources, it expands to nothing.

View File

@ -243,7 +243,7 @@ var getJibProfilesCommon = function (input, data) {
// These are the base setttings for all the main build profiles. // These are the base setttings for all the main build profiles.
common.main_profile_base = { common.main_profile_base = {
dependencies: ["boot_jdk", "gnumake", "jtreg", "jib", "autoconf", "jmh"], dependencies: ["boot_jdk", "gnumake", "jtreg", "jib", "autoconf", "jmh", "jcov"],
default_make_targets: ["product-bundles", "test-bundles"], default_make_targets: ["product-bundles", "test-bundles"],
configure_args: concat(["--enable-jtreg-failure-handler"], configure_args: concat(["--enable-jtreg-failure-handler"],
"--with-exclude-translations=de,es,fr,it,ko,pt_BR,sv,ca,tr,cs,sk,ja_JP_A,ja_JP_HA,ja_JP_HI,ja_JP_I,zh_TW,zh_HK", "--with-exclude-translations=de,es,fr,it,ko,pt_BR,sv,ca,tr,cs,sk,ja_JP_A,ja_JP_HA,ja_JP_HI,ja_JP_I,zh_TW,zh_HK",
@ -898,6 +898,14 @@ var getJibProfilesDependencies = function (input, common) {
revision: "1.21+1.0" revision: "1.21+1.0"
}, },
jcov: {
server: "jpg",
product: "jcov",
version: "3.0",
build_number: "b07",
file: "bundles/jcov-3_0.zip",
},
gnumake: { gnumake: {
organization: common.organization, organization: common.organization,
ext: "tar.gz", ext: "tar.gz",