jdk/makefiles/GensrcProperties.gmk
changeset 12317 9670c1610c53
child 12892 3ef14bab6254
equal deleted inserted replaced
12316:ba6b7a51e226 12317:9670c1610c53
       
     1 #
       
     2 # Copyright (c) 2011, 2012, 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 # All .properties files to be compiled are appended to this variable.
       
    27 ALL_COMPILED_PROPSOURCES:=
       
    28 # All generated .java files from compilation are appended to this variable.
       
    29 ALL_COMPILED_PROPJAVAS:=
       
    30 # The (very long) command line for compilation, stored in a file, prior to use.
       
    31 COMPILE_PROPCMDLINE:=
       
    32 
       
    33 # All .properties files to be cleaned are appended to this variable.
       
    34 ALL_CLEANED_PROPSOURCES:=
       
    35 # All generated cleaned .properties files from cleaning are appended to this variable.
       
    36 ALL_CLEANED_PROPOUTPUT:=
       
    37 # The (very long) command line for cleaning, stored in a file, prior to use.
       
    38 CLEAN_PROPCMDLINE:=
       
    39 
       
    40 define add_properties_to_compile
       
    41   # $1 is the name of the properties group
       
    42   # $2 is the files belonging to this group
       
    43   # $3 is the super class for the generated java file.
       
    44   # $4 is a from pattern for translating stripped name from source to target
       
    45   # $5 is the to pattern replacing $3 in the target
       
    46 
       
    47   # Strip away prefix and suffix,
       
    48   # leaving for example: sun/util/resources/CurrencyNames_sv
       
    49   $1_PROPPATHS:=$$(patsubst $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/classes/%.properties,%,\
       
    50                 $$(patsubst $(JDK_TOPDIR)/src/share/classes/%.properties,%,$2))
       
    51 
       
    52   # Apply optional name transformation, example: hz_TW -> hz_HK
       
    53   $(if $4,$1_PROPPATHS:=$$(patsubst $4,$5,$$($1_PROPPATHS)))
       
    54 
       
    55   # Accumulate all found properties files.
       
    56   ALL_COMPILED_PROPSOURCES+=$2
       
    57 
       
    58   # Generate the list of to be created java files.
       
    59   ALL_COMPILED_PROPJAVAS+=$$(patsubst %,$(JDK_OUTPUTDIR)/gensrc_properties/%.java,$$($1_PROPPATHS))
       
    60 
       
    61   # Now generate a sequence of "-compile ...CurrencyNames_sv.properties ...CurrencyNames_sv.java ListResourceBundle"
       
    62   # suitable to be fed into the CompileProperties command.
       
    63   COMPILE_PROPCMDLINE+=$$(subst _SPACE_,$(SPACE),$$(join $$(addprefix -compile_SPACE_,$2), \
       
    64 		$$(addsuffix _SPACE_$(strip $3),\
       
    65                     $$(addprefix _SPACE_$(JDK_OUTPUTDIR)/gensrc_properties/,\
       
    66                         $$(addsuffix .java,$$($1_PROPPATHS))))))
       
    67 endef
       
    68 
       
    69 define add_properties_to_clean
       
    70   # $1 is the name of the properties group
       
    71   # $2 is the files belonging to this group
       
    72   # $3 is a from pattern for translating stripped name from source to target
       
    73   # $4 is the to pattern replacing $3 in the target
       
    74   # $5 optional name of extra directory to put properties files in (ex: resources)
       
    75 
       
    76   # Strip away prefix and suffix,
       
    77   # leaving for example: sun/util/resources/CurrencyNames_sv
       
    78   $1_PROPPATHS:=$$(patsubst $(JDK_TOPDIR)/src/$(LEGACY_HOST_OS_API)/classes/%.properties,%,\
       
    79                 $$(patsubst $(JDK_TOPDIR)/src/share/classes/%.properties,%,$2))
       
    80 
       
    81   # Apply optional name transformation, example: hz_TW -> hz_HK
       
    82   $(if $3,$1_PROPPATHS:=$$(patsubst $3,$4,$$($1_PROPPATHS)))
       
    83 
       
    84   # Accumulate all found properties files.
       
    85   ALL_CLEANED_PROPSOURCES+=$2
       
    86 
       
    87   # Generate the list of to be created java files.
       
    88   $1_PROPOUTPUT:=$$(patsubst %,$(JDK_OUTPUTDIR)/newclasses/%.properties,$$($1_PROPPATHS))
       
    89   # If the properties target file isn't in a "resources" dir, add one.
       
    90   ifneq ($5,)
       
    91     $1_PROPOUTPUT:=$$(foreach p,$$($1_PROPOUTPUT), $$(dir $$p)$5/$$(notdir $$p))
       
    92   endif
       
    93 
       
    94   ALL_CLEANED_PROPOUTPUT+=$$($1_PROPOUTPUT)
       
    95 
       
    96   # Now generate a sequence of "-clean ...[src]...CurrencyNames_sv.properties ...[build]...CurrencyNames_sv.properties"
       
    97   # suitable to be fed into the StripProperties command.
       
    98   CLEAN_PROPCMDLINE+=$$(subst _SPACE_,$(SPACE),$$(join $$(addprefix -clean_SPACE_,$2), \
       
    99                     $$(addprefix _SPACE_,$$($1_PROPOUTPUT))))
       
   100 endef
       
   101 
       
   102 # Some packages contain pregenerated java files instead of properties files.
       
   103 # But unfortunately not all properties should be converted, some should be
       
   104 # copied....argggghhh.
       
   105 
       
   106 # For example:
       
   107 #    sun/applet/resources
       
   108 #    sun/misc/resources
       
   109 #    sun/text/resources
       
   110 #    sun/tools/jconsole/resources
       
   111 #    sun/tools/native2ascii/resources
       
   112 #    sun/util/resources
       
   113 
       
   114 # Some packages have properties that need to be converted to java source files.
       
   115 
       
   116 #com/sun/accessibility/internal/resources
       
   117 $(eval $(call add_properties_to_compile,COM_SUN_ACCESSIBILITY,\
       
   118 	$(shell find $(JDK_TOPDIR)/src/share/classes/com/sun/accessibility/internal/resources -name "*.properties"),\
       
   119 		ListResourceBundle))
       
   120 $(eval $(call add_properties_to_compile,COM_SUN_ACCESSIBILITY_HK,\
       
   121 	$(shell find $(JDK_TOPDIR)/src/share/classes/com/sun/accessibility/internal/resources -name "*.properties"),\
       
   122 		ListResourceBundle,%zh_TW,%zh_HK))
       
   123 #com/sun/imageio/plugins/common
       
   124 #com/sun/java/swing/plaf/gtk/resources
       
   125 #com/sun/java/swing/plaf/motif/resources
       
   126 #com/sun/java/swing/plaf/windows/resources
       
   127 #com/sun/java/util/jar/pack
       
   128 $(eval $(call add_properties_to_clean,JNDI_COSNAMING,\
       
   129 	$(JDK_TOPDIR)/src/share/classes/com/sun/java/util/jar/pack/intrinsic.properties))
       
   130 #com/sun/jndi/cosnaming
       
   131 $(eval $(call add_properties_to_clean,JNDI_COSNAMING,\
       
   132 	$(JDK_TOPDIR)/src/share/classes/com/sun/jndi/cosnaming/jndiprovider.properties))
       
   133 #com/sun/jndi/ldap
       
   134 $(eval $(call add_properties_to_clean,JNDI_COSNAMING,\
       
   135 	$(JDK_TOPDIR)/src/share/classes/com/sun/jndi/ldap/jndiprovider.properties))
       
   136 
       
   137 #com/sun/org/apache/xml/internal/security/resource
       
   138 #FIXME: The "xmlsecurity*.properties" pattern is not ideal; we might want to find
       
   139 #a better way to select the properties files that are needed.
       
   140 $(eval $(call add_properties_to_clean,XML_SECURITY,\
       
   141 	$(shell find $(JDK_TOPDIR)/src/share/classes/com/sun/org/apache/xml/internal/security/resource -name "xmlsecurity*.properties")))
       
   142 
       
   143 #com/sun/rowset
       
   144 $(eval $(call add_properties_to_clean,COM_SUN_ROWSET,\
       
   145 	$(shell find $(JDK_TOPDIR)/src/share/classes/com/sun/rowset -name "*.properties")))
       
   146 $(eval $(call add_properties_to_clean,COM_SUN_ROWSET_HK,\
       
   147 	$(shell find $(JDK_TOPDIR)/src/share/classes/com/sun/rowset -name "*zh_TW.properties"),\
       
   148 	%zh_TW,%zh_HK))
       
   149 
       
   150 #com/sun/servicetag/resources
       
   151 #com/sun/swing/internal/plaf/basic/resources
       
   152 #com/sun/swing/internal/plaf/metal/resources
       
   153 #com/sun/swing/internal/plaf/synth/resources
       
   154 
       
   155 #com/sun/tools/jdi/resources
       
   156 $(eval $(call add_properties_to_compile,COM_SUN_TOOLS_JDI,\
       
   157 	$(shell find $(JDK_TOPDIR)/src/share/classes/com/sun/tools/jdi/resources -name "*.properties"),\
       
   158 		ListResourceBundle))
       
   159 
       
   160 #com/sun/tools/script/shell
       
   161 #java/util
       
   162 #javax/sql/rowset
       
   163 #sun/awt/resources
       
   164 $(eval $(call add_properties_to_compile,SUN_AWT,\
       
   165 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/awt/resources -name "*.properties"),\
       
   166 		ListResourceBundle))
       
   167 $(eval $(call add_properties_to_compile,SUN_AWT_HK,\
       
   168 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/awt/resources -name "*.properties"),\
       
   169 		ListResourceBundle,%zh_TW,%zh_HK))
       
   170 #sun/launcher/resources
       
   171 $(eval $(call add_properties_to_compile,SUN_LAUNCHER,\
       
   172 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/launcher/resources -name "*.properties"),\
       
   173 		ListResourceBundle))
       
   174 $(eval $(call add_properties_to_compile,SUN_LAUNCHER_HK,\
       
   175 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/launcher/resources -name "*.properties"),\
       
   176 		ListResourceBundle,%zh_TW,%zh_HK))
       
   177 #sun/management/resources
       
   178 #sun/print
       
   179 #sun/print/resources
       
   180 $(eval $(call add_properties_to_compile,SUN_PRINT,\
       
   181 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/print/resources -name "*.properties"),\
       
   182 		ListResourceBundle))
       
   183 $(eval $(call add_properties_to_compile,SUN_PRINT_HK,\
       
   184 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/print/resources -name "*.properties"),\
       
   185 		ListResourceBundle,%zh_TW,%zh_HK))
       
   186 #sun/rmi/registry/resources
       
   187 $(eval $(call add_properties_to_clean,SUN_RMI_REGISTRY,\
       
   188 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/rmi/registry/resources -name "*.properties")))
       
   189 $(eval $(call add_properties_to_clean,SUN_RMI_REGISTRY_HK,\
       
   190 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/rmi/registry/resources -name "*zh_TW.properties"),\
       
   191 	%zh_TW,%zh_HK))
       
   192 
       
   193 #sun/rmi/rmic/resources
       
   194 $(eval $(call add_properties_to_clean,SUN_RMI_RMIC,\
       
   195 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/rmi/rmic/resources -name "*.properties")))
       
   196 
       
   197 #sun/rmi/server/resources
       
   198 $(eval $(call add_properties_to_clean,SUN_RMI_SERVER,\
       
   199 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/rmi/server/resources -name "*.properties")))
       
   200 $(eval $(call add_properties_to_clean,SUN_RMI_SERVER_HK,\
       
   201 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/rmi/server/resources -name "*zh_TW.properties"),\
       
   202 	%zh_TW,%zh_HK))
       
   203 
       
   204 # sun/tools/jar/resources
       
   205 $(eval $(call add_properties_to_compile,SUN_TOOLS_JAR,\
       
   206 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/tools/jar/resources -name "*.properties"),\
       
   207 		ListResourceBundle))
       
   208 $(eval $(call add_properties_to_compile,SUN_TOOLS_JAR_HK,\
       
   209 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/tools/jar/resources -name "*.properties"),\
       
   210 		ListResourceBundle,%zh_TW,%zh_HK))
       
   211 
       
   212 #sun/tools/javac/resources
       
   213 # It's unclear if the other localized property files here are supposed to be copied or not
       
   214 # but the old build system didn't copy them.
       
   215 $(eval $(call add_properties_to_clean,SUN_TOOLS_SERIALVER,\
       
   216 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/tools/javac/resources -name "javac.properties")))
       
   217 
       
   218 #sun/tools/serialver
       
   219 $(eval $(call add_properties_to_clean,SUN_TOOLS_SERIALVER,\
       
   220 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/tools/serialver -name "*.properties"),,,resources))
       
   221 
       
   222 #sun/util/logging/resources
       
   223 $(eval $(call add_properties_to_compile,SUN_UTIL_LOGGING,\
       
   224 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/util/logging/resources -name "*.properties"),\
       
   225 		ListResourceBundle))
       
   226 $(eval $(call add_properties_to_compile,SUN_UTIL_LOGGING_HK,\
       
   227 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/util/logging/resources -name "*.properties"),\
       
   228 		ListResourceBundle,%zh_TW,%zh_HK))
       
   229 # sun/util/resources
       
   230 $(eval $(call add_properties_to_compile,SUN_UTIL,\
       
   231 	$(shell find $(JDK_TOPDIR)/src/share/classes/sun/util/resources -name "*.properties"),\
       
   232 		LocaleNamesBundle))
       
   233 
       
   234 
       
   235 # Now setup the rule for the generation of the resource bundles.
       
   236 $(JDK_OUTPUTDIR)/gensrc_properties/_the.compiled_properties : $(ALL_COMPILED_PROPSOURCES) $(BUILD_TOOLS)
       
   237 	$(RM) -rf $(JDK_OUTPUTDIR)/gensrc_properties/*
       
   238 #	Generate all output directories in advance since the build tool does not do that...
       
   239 	$(MKDIR) -p $(sort $(dir $(ALL_COMPILED_PROPJAVAS)))
       
   240 	echo Compiling $(words $(ALL_COMPILED_PROPSOURCES)) properties into resource bundles
       
   241 	$(call ListPathsSafely,COMPILE_PROPCMDLINE,\n, >> $(JDK_OUTPUTDIR)/gensrc_properties/_the.cmdline)
       
   242 	$(TOOL_COMPILEPROPERTIES) -quiet @$(JDK_OUTPUTDIR)/gensrc_properties/_the.cmdline
       
   243 	touch $@
       
   244 
       
   245 # Now setup the rule for the generation of the cleaned properties.
       
   246 # FIXME: We currently don't handle removed properties incrementally. 
       
   247 $(JDK_OUTPUTDIR)/newclasses/_the.cleaned_properties : $(ALL_CLEANED_PROPSOURCES) $(BUILD_TOOLS)
       
   248 	$(RM) -f $(JDK_OUTPUTDIR)/newclasses/_the.cleaned_properties.cmdline
       
   249 #	Generate all output directories in advance since the build tool does not do that...
       
   250 	$(MKDIR) -p $(sort $(dir $(ALL_CLEANED_PROPOUTPUT)))
       
   251 	echo Copying and cleaning $(words $(ALL_CLEANED_PROPSOURCES)) properties 
       
   252 	$(call ListPathsSafely,CLEAN_PROPCMDLINE,\n, >> $(JDK_OUTPUTDIR)/newclasses/_the.cleaned_properties.cmdline)
       
   253 	$(TOOL_STRIPPROPERTIES) @$(JDK_OUTPUTDIR)/newclasses/_the.cleaned_properties.cmdline
       
   254 	touch $@
       
   255 
       
   256 $(ALL_COMPILED_PROPJAVAS) : $(JDK_OUTPUTDIR)/gensrc_properties/_the.compiled_properties
       
   257 
       
   258 $(ALL_CLEANED_PROPOUTPUT) : $(JDK_OUTPUTDIR)/newclasses/_the.cleaned_properties
       
   259 
       
   260 
       
   261 # Some zh_HK resources are just copied of zh_TW
       
   262 $(JDK_OUTPUTDIR)/gensrc_properties/%_zh_HK.java: $(JDK_TOPDIR)/src/share/classes/%_zh_TW.java
       
   263 	$(MKDIR) -p $(@D)
       
   264 	$(CAT) $< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $@
       
   265 
       
   266 ZH_HK_JAVA:=	sun/applet/resources/MsgAppletViewer_zh_HK.java \
       
   267 		sun/misc/resources/Messages_zh_HK.java \
       
   268 		sun/security/util/AuthResources_zh_HK.java
       
   269 ZH_HK_JAVA_FILES:=$(addprefix $(JDK_OUTPUTDIR)/gensrc_properties/,$(ZH_HK_JAVA))
       
   270 
       
   271 
       
   272 GENSRC_PROPERTIES:=$(ALL_COMPILED_PROPJAVAS) $(ALL_CLEANED_PROPOUTPUT) $(ZH_HK_JAVA_FILES)