make/test/BuildMicrobenchmark.gmk
author redestad
Fri, 19 Oct 2018 12:20:44 +0200
branchJEP-230-microbenchmarks-branch
changeset 56991 924fbbfdf07a
parent 56930 079075866d11
permissions -rw-r--r--
JAVA_SMALL -> JAVA, comment out MICROBENCHMARK_RES
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     1
#
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     2
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     4
#
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    10
#
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    15
# accompanied this code).
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    16
#
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    20
#
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    23
# questions.
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    24
#
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    25
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    26
# This must be the first rule
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    27
default: all
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    28
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    29
include $(SPEC)
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    30
include MakeBase.gmk
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    31
include JavaCompilation.gmk
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    32
include SetupJavaCompilers.gmk
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    33
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    34
ifeq ($(JMH_CORE_JAR), )
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    35
  $(info Error: JMH is missing. Please use configure --with-jmh.)
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    36
  $(error Cannot continue)
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    37
endif
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    38
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    39
#### Variables
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    40
56930
079075866d11 Reorganize micro sources (classes/resources), add tests using resources as a PoC
redestad
parents: 56919
diff changeset
    41
MICROBENCHMARK_SRC := $(TOPDIR)/test/micro/classes
56991
924fbbfdf07a JAVA_SMALL -> JAVA, comment out MICROBENCHMARK_RES
redestad
parents: 56930
diff changeset
    42
# Uncomment this if/when resources are added
924fbbfdf07a JAVA_SMALL -> JAVA, comment out MICROBENCHMARK_RES
redestad
parents: 56930
diff changeset
    43
#MICROBENCHMARK_RES := $(TOPDIR)/test/micro/resources
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    44
MICROBENCHMARK_JAR := $(IMAGES_OUTPUTDIR)/test/micro/microbenchmarks.jar
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    45
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    46
MICROBENCHMARK_OUTPUT := $(SUPPORT_OUTPUTDIR)/test/micro
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    47
MICROBENCHMARK_CLASSES := $(MICROBENCHMARK_OUTPUT)/classes
56918
c331ac5bc80a Only output resulting jar, not build support files, in image.
ihse
parents: 56913
diff changeset
    48
MICROBENCHMARK_JAR_BIN := $(MICROBENCHMARK_OUTPUT)/jar
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    49
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    50
JMH_UNPACKED_DIR := $(MICROBENCHMARK_OUTPUT)/jmh_jars
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    51
JMH_UNPACKED_JARS_DONE := $(JMH_UNPACKED_DIR)/_unpacked.marker
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    52
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    53
# External dependencies
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    54
JMH_COMPILE_JARS := $(JMH_CORE_JAR) $(JMH_GENERATOR_JAR)
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    55
JMH_RUNTIME_JARS := $(JMH_CORE_JAR) $(JMH_COMMONS_MATH_JAR) $(JMH_JOPT_SIMPLE_JAR)
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    56
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    57
MICROBENCHMARK_CLASSPATH := $(call PathList, $(JMH_COMPILE_JARS))
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    58
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    59
###
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    60
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    61
# Need double \n to get new lines and no trailing spaces
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    62
MICROBENCHMARK_MANIFEST := Build: $(FULL_VERSION)\n\
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    63
\nJMH-Version: $(JMH_VERSION)\n\
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    64
\nName: OpenJDK Microbenchmark Suite
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    65
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    66
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    67
#### Compile Targets
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    68
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    69
# Building microbenchmark requires the jdk.unsupported and java.management modules,
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    70
# and to have sjavac disabled.
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    71
$(eval $(call SetupJavaCompiler, MICROBENCHMARK_JAVA_COMPILER, \
56991
924fbbfdf07a JAVA_SMALL -> JAVA, comment out MICROBENCHMARK_RES
redestad
parents: 56930
diff changeset
    72
    JVM := $(JAVA) --add-modules jdk.unsupported --limit-modules java.management, \
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    73
    JAVAC := $(NEW_JAVAC), \
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    74
    DISABLE_SJAVAC := true, \
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    75
    FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none $(DISABLE_WARNINGS), \
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    76
    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    77
    SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    78
))
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    79
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    80
# Build microbenchmark suite for the current JDK
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    81
$(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    82
    SETUP := MICROBENCHMARK_JAVA_COMPILER, \
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    83
    ADD_JAVAC_FLAGS := -cp $(MICROBENCHMARK_CLASSPATH) -Xlint -Werror, \
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    84
    SRC := $(MICROBENCHMARK_SRC), \
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    85
    BIN := $(MICROBENCHMARK_CLASSES), \
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    86
))
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    87
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    88
$(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS)
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    89
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    90
# Unpacking dependencies for inclusion in the benchmark JARs
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    91
$(JMH_UNPACKED_JARS_DONE): $(JMH_RUNTIME_JARS)
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    92
	$(RM) -r $(JMH_UNPACKED_DIR)
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    93
	$(MKDIR) -p $(JMH_UNPACKED_DIR)
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    94
	$(foreach jar, $(JMH_RUNTIME_JARS), \
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    95
            $$($(UNZIP) -oq $(jar) -d $(JMH_UNPACKED_DIR)))
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    96
	$(RM) -r $(JMH_UNPACKED_DIR)/META-INF
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
    97
	$(RM) $(JMH_UNPACKED_DIR)/*.xml
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    98
	$(TOUCH) $@
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
    99
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   100
# Create benchmarks JAR file with benchmarks for both the old and new JDK
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
   101
$(eval $(call SetupJarArchive, BUILD_JDK_JAR, \
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
   102
    DEPENDENCIES := $(BUILD_JDK_MICROBENCHMARK) $(JMH_UNPACKED_JARS_DONE), \
56930
079075866d11 Reorganize micro sources (classes/resources), add tests using resources as a PoC
redestad
parents: 56919
diff changeset
   103
    SRCS := $(MICROBENCHMARK_CLASSES) $(JMH_UNPACKED_DIR) $(MICROBENCHMARK_RES), \
56918
c331ac5bc80a Only output resulting jar, not build support files, in image.
ihse
parents: 56913
diff changeset
   104
    BIN := $(MICROBENCHMARK_JAR_BIN), \
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   105
    SUFFIXES := .*, \
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   106
    EXCLUDE_FILES:= _the.BUILD_JDK_MICROBENCHMARK_batch \
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
   107
        _the.BUILD_JDK_MICROBENCHMARK.vardeps _unpacked.marker, \
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
   108
    EXTRA_MANIFEST_ATTR := $(MICROBENCHMARK_MANIFEST), \
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   109
    JARMAIN := org.openjdk.jmh.Main, \
56907
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
   110
    JAR := $(MICROBENCHMARK_JAR), \
040e5da15709 Update building as well.
ihse
parents: 56905
diff changeset
   111
))
56905
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   112
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   113
all: $(MICROBENCHMARK_JAR)
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   114
d4ab0656f48e Initial import of Claes work.
ihse
parents:
diff changeset
   115
.PHONY: all