make/BuildLangtools.gmk

Sat, 07 Nov 2020 10:05:19 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:05:19 +0800
changeset 3937
eb6ee6a5f2fe
parent 2525
2eb010b6cb22
permissions
-rw-r--r--

Merge

aoqi@0 1 #
aoqi@0 2 # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 #
aoqi@0 5 # This code is free software; you can redistribute it and/or modify it
aoqi@0 6 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 # published by the Free Software Foundation. Oracle designates this
aoqi@0 8 # particular file as subject to the "Classpath" exception as provided
aoqi@0 9 # by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 #
aoqi@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 # accompanied this code).
aoqi@0 16 #
aoqi@0 17 # You should have received a copy of the GNU General Public License version
aoqi@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 #
aoqi@0 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 # or visit www.oracle.com if you need additional information or have any
aoqi@0 23 # questions.
aoqi@0 24 #
aoqi@0 25
aoqi@0 26 # This must be the first rule
aoqi@0 27 default: all
aoqi@0 28
aoqi@0 29 include $(SPEC)
aoqi@0 30 include MakeBase.gmk
aoqi@0 31 include JavaCompilation.gmk
aoqi@0 32
aoqi@0 33 # The BOOT_JAVAC setup uses the bootdir compiler to compile the tools
aoqi@0 34 # and the bootstrap javac, to be run by the bootdir jvm.
aoqi@0 35 $(eval $(call SetupJavaCompiler,BOOT_JAVAC, \
aoqi@0 36 JAVAC := $(JAVAC), \
aoqi@0 37 SERVER_DIR := $(SJAVAC_SERVER_DIR), \
aoqi@0 38 SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
aoqi@0 39 FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror))
aoqi@0 40
aoqi@0 41 # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
aoqi@0 42 RESOURCE_SUFFIXES := .gif .xml .css .js javax.tools.JavaCompilerTool
aoqi@0 43
aoqi@0 44 # Now setup the compilation of the properties compilation tool. You can depend
aoqi@0 45 # upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we
aoqi@0 46 # add src/share/classes to the sourcepath. This is necessary since the GenStubs
aoqi@0 47 # program needs to be linked and run towards the new javac sources.
aoqi@0 48 $(eval $(call SetupJavaCompilation,BUILD_TOOLS, \
aoqi@0 49 SETUP := BOOT_JAVAC, \
aoqi@0 50 DISABLE_SJAVAC := true, \
aoqi@0 51 ADD_JAVAC_FLAGS := -Xprefer:source, \
aoqi@0 52 SRC := $(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes, \
aoqi@0 53 INCLUDES := compileproperties genstubs, \
aoqi@0 54 BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses))
aoqi@0 55
aoqi@0 56 # The compileprops tools compiles a properties file into a resource bundle.
aoqi@0 57 TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet
aoqi@0 58
aoqi@0 59 # Lookup the properties that need to be compiled into resource bundles.
aoqi@0 60 PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties")
aoqi@0 61
aoqi@0 62 # Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN"
aoqi@0 63 PROPPATHS := $(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties, %, $(PROPSOURCES))
aoqi@0 64
aoqi@0 65 # Generate the list of java files to be created.
aoqi@0 66 PROPJAVAS := $(patsubst %, $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, $(PROPPATHS))
aoqi@0 67
aoqi@0 68 # Generate the package dirs for the tobe generated java files.
aoqi@0 69 PROPDIRS := $(dir $(PROPJAVAS))
aoqi@0 70
aoqi@0 71 # Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
aoqi@0 72 # suitable to be fed into the CompileProperties command.
aoqi@0 73 PROPCMDLINE := $(subst _SPACE_, $(SPACE), $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \
aoqi@0 74 $(addsuffix _SPACE_java.util.ListResourceBundle, $(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/, $(addsuffix .java, $(PROPPATHS))))))
aoqi@0 75
aoqi@0 76 # Now setup the rule for the generation of the resource bundles.
aoqi@0 77 $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d: $(PROPSOURCES) $(BUILD_TOOLS)
aoqi@0 78 $(RM) -r $(@D)/*
aoqi@0 79 $(MKDIR) -p $(@D) $(PROPDIRS)
aoqi@0 80 $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties
aoqi@0 81 $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties
aoqi@0 82 $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties
aoqi@0 83 $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties
aoqi@0 84 $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties
aoqi@0 85 $(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
aoqi@0 86 $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
aoqi@0 87 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \
aoqi@0 88 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \
aoqi@0 89 java.util.ListResourceBundle \
aoqi@0 90 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \
aoqi@0 91 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \
aoqi@0 92 java.util.ListResourceBundle \
aoqi@0 93 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \
aoqi@0 94 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \
aoqi@0 95 java.util.ListResourceBundle \
aoqi@0 96 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \
aoqi@0 97 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \
aoqi@0 98 java.util.ListResourceBundle \
aoqi@0 99 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \
aoqi@0 100 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \
aoqi@0 101 java.util.ListResourceBundle
aoqi@0 102 $(ECHO) PROPS_ARE_CREATED = yes > $@
aoqi@0 103
aoqi@0 104 # Trigger the generation of the resource bundles. After the resource bundles have
aoqi@0 105 # been compiled, then the makefile will restart and the newly created java files
aoqi@0 106 # will become part of the build further along in the makefile.
aoqi@0 107 -include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
aoqi@0 108
aoqi@0 109 ifeq ($(PROPS_ARE_CREATED), yes)
aoqi@0 110 # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac
aoqi@0 111 # that can be compiled with an old javac. The intermediate javac is then used
aoqi@0 112 # to compile javac again and to build the complete new jdk.
aoqi@0 113 $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS, \
aoqi@0 114 SETUP := BOOT_JAVAC, \
aoqi@0 115 DISABLE_SJAVAC := true, \
aoqi@0 116 SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \
aoqi@0 117 EXCLUDES := com/sun/tools/javac/nio, \
aoqi@0 118 COPY := $(RESOURCE_SUFFIXES), \
aoqi@0 119 BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap))
aoqi@0 120
aoqi@0 121 $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC, $(BUILD_BOOTSTRAP_LANGTOOLS), \
aoqi@0 122 SRCS := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap, \
aoqi@0 123 JAR := $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar, \
aoqi@0 124 SUFFIXES := .class $(RESOURCE_SUFFIXES)))
aoqi@0 125
aoqi@0 126 # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not
aoqi@0 127 # yet built. It is currently not needed but might be again in the future. The following
aoqi@0 128 # exercises the functionality to verify that it works.
aoqi@0 129 TOOL_GENSTUBS_CMD = $(JAVA) \
aoqi@0 130 "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
aoqi@0 131 -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \
aoqi@0 132 genstubs.GenStubs
aoqi@0 133
aoqi@0 134 # We fetch source from the JDK...
aoqi@0 135 JDKS = $(JDK_TOPDIR)/src/share/classes
aoqi@0 136
aoqi@0 137 # Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't
aoqi@0 138 # currently needed, but is used as a demo for now.
aoqi@0 139
aoqi@0 140 STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \
aoqi@0 141 -e "$(JDKS)/java/util/function/Predicate.java")
aoqi@0 142
aoqi@0 143 # Rewrite the file names into class names because the GenStubs tool require this.
aoqi@0 144 STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES)))
aoqi@0 145
aoqi@0 146 # Now setup the build recipe for genstubs.
aoqi@0 147 $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d: $(STUBSOURCES) $(BUILD_TOOLS) \
aoqi@0 148 $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
aoqi@0 149 $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
aoqi@0 150 $(MKDIR) -p $(@D)
aoqi@0 151 $(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs
aoqi@0 152 $(ECHO) $(LOG_INFO) Generating stubs from JDK sources.
aoqi@0 153 ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && $(ECHO) STUBS_ARE_CREATED = yes > $@)
aoqi@0 154 if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \
aoqi@0 155 $(ECHO) $(LOG_INFO) No changes in the stubs!; \
aoqi@0 156 $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \
aoqi@0 157 else \
aoqi@0 158 $(ECHO) $(LOG_INFO) Changes in stubs detected!; \
aoqi@0 159 $(RM) -r $(@D); \
aoqi@0 160 $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \
aoqi@0 161 fi
aoqi@0 162 $(ECHO) STUBS_ARE_CREATED = yes > $@
aoqi@0 163
aoqi@0 164 # Trigger a generation of the genstubs java source code and a restart
aoqi@0 165 # of the makefile to make sure that the following build setup use the
aoqi@0 166 # newly created java files.
aoqi@0 167 -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d
aoqi@0 168
aoqi@0 169 ifeq ($(STUBS_ARE_CREATED), yes)
aoqi@0 170 # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar
aoqi@0 171 # that generates code for the new jdk that is being built.
aoqi@0 172 # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm.
aoqi@0 173 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \
aoqi@0 174 JVM := $(JAVA), \
aoqi@0 175 JAVAC := "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
aoqi@0 176 -cp $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
aoqi@0 177 com.sun.tools.javac.Main, \
aoqi@0 178 FLAGS := -XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror, \
aoqi@0 179 SERVER_DIR := $(SJAVAC_SERVER_DIR), \
aoqi@0 180 SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
aoqi@0 181
aoqi@0 182 $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC, \
aoqi@0 183 SETUP := GENERATE_NEWBYTECODE, \
aoqi@0 184 SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \
aoqi@0 185 $(LANGTOOLS_OUTPUTDIR)/genstubs, \
aoqi@0 186 EXCLUDES := java/util java/io java/nio, \
aoqi@0 187 COPY := $(RESOURCE_SUFFIXES), \
aoqi@0 188 BIN := $(LANGTOOLS_OUTPUTDIR)/classes))
aoqi@0 189
aoqi@0 190 $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC, $(BUILD_FULL_JAVAC), \
aoqi@0 191 SETUP := GENERATE_NEWBYTECODE, \
aoqi@0 192 SRCS := $(LANGTOOLS_OUTPUTDIR)/classes, \
aoqi@0 193 SUFFIXES := .class $(RESOURCE_SUFFIXES), \
aoqi@0 194 JAR := $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar))
aoqi@0 195
aoqi@0 196 $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE, \
aoqi@0 197 SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \
aoqi@0 198 ZIP := $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip))
aoqi@0 199
aoqi@0 200 all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \
aoqi@0 201 $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \
aoqi@0 202 $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar
aoqi@0 203
aoqi@0 204 endif
aoqi@0 205 endif

mercurial