|
1 # |
|
2 # Copyright (c) 2018, 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 # This must be the first rule |
|
27 default: all |
|
28 |
|
29 include $(SPEC) |
|
30 include MakeBase.gmk |
|
31 include JavaCompilation.gmk |
|
32 include SetupJavaCompilers.gmk |
|
33 |
|
34 # Hook to include the corresponding custom Makefile, if present. |
|
35 $(eval $(call IncludeCustomExtension, benchmark, BuildMicrobenchmark.gmk)) |
|
36 |
|
37 #### Variables |
|
38 |
|
39 MICROBENCHMARK_SRC := $(TOPDIR)/test/micro/src/classes |
|
40 MICROBENCHMARK_OUTPUT := $(OUTPUTDIR)/micro |
|
41 MICROBENCHMARK_DIST := $(OUTPUTDIR)/micro/dist |
|
42 |
|
43 # Uncomment MICROBENCHMARK_RESOURCES when resources are added |
|
44 #MICROBENCHMARK_RESOURCES += $(TOPDIR)/test/micro/src/resources |
|
45 MICROBENCHMARK_CLASSES := $(OUTPUTDIR)/micro/classes |
|
46 MICROBENCHMARK_GENERATED_SRC := $(MICROBENCHMARK_CLASSES)_generated |
|
47 MICROBENCHMARK_JAR := $(MICROBENCHMARK_DIST)/benchmarks.jar |
|
48 |
|
49 JMH_UNPACKED := $(MICROBENCHMARK_OUTPUT)/jmh_unpacked |
|
50 |
|
51 #### Compile Targets |
|
52 |
|
53 # Create separate directories for generated files |
|
54 # Avoids copying .java files into JARs later |
|
55 $(MICROBENCHMARK_GENERATED_SRC)/_generated.state: |
|
56 $(RM) -r $(MICROBENCHMARK_GENERATED_SRC) |
|
57 $(MKDIR) -p $(MICROBENCHMARK_GENERATED_SRC) |
|
58 $(TOUCH) $@ |
|
59 |
|
60 $(call PrintVar, JMH_COMPILE_JARS) |
|
61 $(call PrintVar, JMH_RUNTIME_JARS) |
|
62 |
|
63 ENABLE_JAVAC_SERVER := false |
|
64 |
|
65 # Building microbenchmark requires the jdk.unsupported and java.management modules |
|
66 $(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE_UNSUPPORTED, \ |
|
67 JVM := $(JAVA_SMALL) --add-modules jdk.unsupported --limit-modules java.management, \ |
|
68 JAVAC := $(NEW_JAVAC), \ |
|
69 FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none $(DISABLE_WARNINGS), \ |
|
70 SERVER_DIR := $(SJAVAC_SERVER_DIR), \ |
|
71 SERVER_JVM := $(SJAVAC_SERVER_JAVA))) |
|
72 |
|
73 # Build microbenchmark suite for the current JDK |
|
74 $(eval $(call SetupJavaCompilation,BUILD_JDK_MICROBENCHMARK, \ |
|
75 SETUP := GENERATE_USINGJDKBYTECODE_UNSUPPORTED, \ |
|
76 DISABLE_SJAVAC := true, \ |
|
77 ADD_JAVAC_FLAGS := -cp $(call PathList, $(JMH_COMPILE_JARS)) \ |
|
78 -s $(MICROBENCHMARK_GENERATED_SRC) \ |
|
79 -Xlint -Werror, \ |
|
80 SRC := $(MICROBENCHMARK_SRC), \ |
|
81 BIN := $(MICROBENCHMARK_CLASSES))) |
|
82 |
|
83 $(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS) $(MICROBENCHMARK_GENERATED_SRC)/_generated.state |
|
84 |
|
85 #### Package Targets |
|
86 |
|
87 # Unpacking dependencies for inclusion in the benchmark JARs |
|
88 $(JMH_UNPACKED)/_unpacked.state: $(JMH_RUNTIME_JARS) |
|
89 $(RM) -r $(JMH_UNPACKED) |
|
90 $(MKDIR) -p $(JMH_UNPACKED) |
|
91 $(foreach jar, $(JMH_RUNTIME_JARS), \ |
|
92 $$($(UNZIP) -oq $(jar) -d $(JMH_UNPACKED))) |
|
93 $(RM) -r $(JMH_UNPACKED)/META-INF |
|
94 $(RM) $(JMH_UNPACKED)/*.xml |
|
95 $(TOUCH) $@ |
|
96 |
|
97 # Need double \n to get new lines and no trailing spaces |
|
98 MANIFEST_ATTRIBUTES := Build: $(FULL_VERSION)\n\ |
|
99 \nJMH-Version: $(JMH_VERSION)\n\ |
|
100 \nName: OpenJDK Microbenchmark Suite |
|
101 |
|
102 # Create benchmarks JAR file with benchmarks for both the old and new JDK |
|
103 $(eval $(call SetupJarArchive,BUILD_JDK_JAR, \ |
|
104 DEPENDENCIES := $(BUILD_JDK_MICROBENCHMARK) \ |
|
105 $(JMH_UNPACKED)/_unpacked.state, \ |
|
106 SRCS := $(JMH_UNPACKED) $(MICROBENCHMARK_CLASSES) $(MICROBENCHMARK_RESOURCES), \ |
|
107 SUFFIXES := .*, \ |
|
108 EXCLUDE_FILES:= _the.BUILD_JDK_MICROBENCHMARK_batch \ |
|
109 _the.BUILD_JDK_MICROBENCHMARK.vardeps _unpacked.state, \ |
|
110 EXTRA_MANIFEST_ATTR := $(MANIFEST_ATTRIBUTES), \ |
|
111 JARMAIN := org.openjdk.jmh.Main, \ |
|
112 JAR := $(MICROBENCHMARK_JAR))) |
|
113 |
|
114 all: $(MICROBENCHMARK_JAR) |
|
115 |
|
116 .PHONY: all |