langtools/make/GensrcLangtools.gmk
author jlahoda
Wed, 03 Dec 2014 13:46:12 +0100
changeset 27857 7e913a535736
parent 25874 83c19f00452c
permissions -rw-r--r--
7101822: Compiling depends on order of imports 7177813: Static import to local nested class fails Summary: MemberEnter overhaul - TypeEnter is split out of MemberEnter; the TypeEnter consists of several Phases which ensure actions are done in the correct order. Reviewed-by: mcimadamore, jfranck, aeremeev Contributed-by: jan.lahoda@oracle.com, maurizio.cimadamore@oracle.com

#
# Copyright (c) 2014, 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.
#

# This must be the first rule
default: all

include $(SPEC)
include MakeBase.gmk
include JavaCompilation.gmk

include CommonLangtools.gmk

################################################################################
# Setup the compilation of the properties compilation tool. You can depend
# upon $(BUILD_TOOLS_LANGTOOLS) to trigger a compilation of the tools. Note that 
# we add src/share/classes to the sourcepath. This is necessary since the 
# GenStubs program needs to be linked and run with the new javac sources.
$(eval $(call SetupJavaCompilation,BUILD_TOOLS_LANGTOOLS, \
    SETUP := BOOT_JAVAC, \
    DISABLE_SJAVAC := true, \
    ADD_JAVAC_FLAGS := -Xprefer:source, \
    SRC := $(LANGTOOLS_TOPDIR)/make/tools, \
    INCLUDES := compileproperties, \
    BIN := $(LANGTOOLS_OUTPUTDIR)/buildtools_classes))

################################################################################
# The compileprops tools compiles a properties file into a resource bundle.
TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/buildtools_classes \
    compileproperties.CompileProperties -quiet

# Lookup the properties that need to be compiled into resource bundles.
PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/*/share/classes -name "*.properties")

# Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
# to .../langtools/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
# Strip away prefix and suffix, leaving for example only: 
# "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
PROPJAVAS := $(patsubst $(LANGTOOLS_TOPDIR)/src/%.properties, \
    $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, \
    $(subst /share/classes,,$(PROPSOURCES)))

# Generate the package dirs for the tobe generated java files. Sort to remove
# duplicates.
PROPDIRS := $(sort $(dir $(PROPJAVAS)))

# Now generate a sequence of:
# "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
# suitable to be fed into the CompileProperties command.
PROPCMDLINE := $(subst _SPACE_, $(SPACE), \
    $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \
    $(addsuffix _SPACE_java.util.ListResourceBundle, \
    $(addprefix _SPACE_, $(PROPJAVAS)))))

# Now setup the rule for the generation of the resource bundles.
$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props: $(PROPSOURCES) $(BUILD_TOOLS_LANGTOOLS)
	$(RM) -r $(@D)/*
	$(MKDIR) -p $(@D) $(PROPDIRS)
	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javah/resources/version.properties
	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javap/resources/version.properties
	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javac/resources/version.properties
	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.dev/com/sun/tools/jdeps/resources/version.properties
	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.javadoc/com/sun/tools/javadoc/resources/version.properties
	$(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
	$(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javah/resources/version.properties \
	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javah/resources/version.java \
	        java.util.ListResourceBundle \
	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javap/resources/version.properties \
	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javap/resources/version.java \
	        java.util.ListResourceBundle \
	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javac/resources/version.properties \
	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javac/resources/version.java \
	        java.util.ListResourceBundle \
	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.dev/com/sun/tools/jdeps/resources/version.properties \
	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.dev/com/sun/tools/jdeps/resources/version.java \
	        java.util.ListResourceBundle \
	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.javadoc/com/sun/tools/javadoc/resources/version.properties \
	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.javadoc/com/sun/tools/javadoc/resources/version.java \
	        java.util.ListResourceBundle
	$(TOUCH) $@

all: $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props

################################################################################