langtools/make/GensrcLangtools.gmk
changeset 27579 d1a63c99cdd5
parent 27578 d61af14a5cf7
child 27580 ca12cdda0551
equal deleted inserted replaced
27578:d61af14a5cf7 27579:d1a63c99cdd5
     1 #
       
     2 # Copyright (c) 2014, 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 
       
    33 include CommonLangtools.gmk
       
    34 
       
    35 ################################################################################
       
    36 # Setup the compilation of the properties compilation tool. You can depend
       
    37 # upon $(BUILD_TOOLS_LANGTOOLS) to trigger a compilation of the tools. Note that 
       
    38 # we add src/share/classes to the sourcepath. This is necessary since the 
       
    39 # GenStubs program needs to be linked and run with the new javac sources.
       
    40 $(eval $(call SetupJavaCompilation,BUILD_TOOLS_LANGTOOLS, \
       
    41     SETUP := BOOT_JAVAC, \
       
    42     DISABLE_SJAVAC := true, \
       
    43     ADD_JAVAC_FLAGS := -Xprefer:source, \
       
    44     SRC := $(LANGTOOLS_TOPDIR)/make/tools, \
       
    45     INCLUDES := compileproperties, \
       
    46     BIN := $(LANGTOOLS_OUTPUTDIR)/buildtools_classes))
       
    47 
       
    48 ################################################################################
       
    49 # The compileprops tools compiles a properties file into a resource bundle.
       
    50 TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/buildtools_classes \
       
    51     compileproperties.CompileProperties -quiet
       
    52 
       
    53 # Lookup the properties that need to be compiled into resource bundles.
       
    54 PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/*/share/classes -name "*.properties")
       
    55 
       
    56 # Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
       
    57 # to .../langtools/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
       
    58 # Strip away prefix and suffix, leaving for example only: 
       
    59 # "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
       
    60 PROPJAVAS := $(patsubst $(LANGTOOLS_TOPDIR)/src/%.properties, \
       
    61     $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, \
       
    62     $(subst /share/classes,,$(PROPSOURCES)))
       
    63 
       
    64 # Generate the package dirs for the tobe generated java files. Sort to remove
       
    65 # duplicates.
       
    66 PROPDIRS := $(sort $(dir $(PROPJAVAS)))
       
    67 
       
    68 # Now generate a sequence of:
       
    69 # "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
       
    70 # suitable to be fed into the CompileProperties command.
       
    71 PROPCMDLINE := $(subst _SPACE_, $(SPACE), \
       
    72     $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \
       
    73     $(addsuffix _SPACE_java.util.ListResourceBundle, \
       
    74     $(addprefix _SPACE_, $(PROPJAVAS)))))
       
    75 
       
    76 # Now setup the rule for the generation of the resource bundles.
       
    77 $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props: $(PROPSOURCES) $(BUILD_TOOLS_LANGTOOLS)
       
    78 	$(RM) -r $(@D)/*
       
    79 	$(MKDIR) -p $(@D) $(PROPDIRS)
       
    80 	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
       
    81 	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javah/resources/version.properties
       
    82 	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
       
    83 	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javap/resources/version.properties
       
    84 	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
       
    85 	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javac/resources/version.properties
       
    86 	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
       
    87 	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.dev/com/sun/tools/jdeps/resources/version.properties
       
    88 	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \
       
    89 	    > $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.javadoc/com/sun/tools/javadoc/resources/version.properties
       
    90 	$(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
       
    91 	$(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
       
    92 	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javah/resources/version.properties \
       
    93 	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javah/resources/version.java \
       
    94 	        java.util.ListResourceBundle \
       
    95 	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javap/resources/version.properties \
       
    96 	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javap/resources/version.java \
       
    97 	        java.util.ListResourceBundle \
       
    98 	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javac/resources/version.properties \
       
    99 	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.compiler/com/sun/tools/javac/resources/version.java \
       
   100 	        java.util.ListResourceBundle \
       
   101 	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.dev/com/sun/tools/jdeps/resources/version.properties \
       
   102 	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.dev/com/sun/tools/jdeps/resources/version.java \
       
   103 	        java.util.ListResourceBundle \
       
   104 	    -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.javadoc/com/sun/tools/javadoc/resources/version.properties \
       
   105 	        $(LANGTOOLS_OUTPUTDIR)/gensrc/jdk.javadoc/com/sun/tools/javadoc/resources/version.java \
       
   106 	        java.util.ListResourceBundle
       
   107 	$(TOUCH) $@
       
   108 
       
   109 all: $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props
       
   110 
       
   111 ################################################################################