make/common/internal/Resources.gmk

changeset 1
55540e827aef
child 158
91006f157c46
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/make/common/internal/Resources.gmk	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,224 @@
     1.4 +#
     1.5 +# Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Sun designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Sun in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 +# CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 +# have any questions.
    1.27 +#
    1.28 +
    1.29 +# 
    1.30 +# Generic mechanism for installing properties files, resource bundles,
    1.31 +#   and other resource files.
    1.32 +#
    1.33 +# FILES_properties should be defined.
    1.34 +# FILES_compiled_properties should be defined.
    1.35 +# 
    1.36 +# If COMPILED_PROPERTIES_SUPERCLASS is defined, ALL the FILES_properties
    1.37 +# files will be compiled into java with this super class.
    1.38 +#
    1.39 +# You can add locales to LOCALE_SUFFIXES explicitly, or use the
    1.40 +# LOCALE_SET_DEFINITION variable to add some pre-defined locale lists.
    1.41 +# The LOCALE_SET_DEFINITION can have the value: jre, plugin, or jdk.
    1.42 +#
    1.43 +# Resource bundles to be installed are identified using the following variables.
    1.44 +# Note that only the file name of the base bundle is given; localized versions
    1.45 +# are added automatically. For Java files, use a format suitable for inclusion
    1.46 +# in the FILES_java list; dito for properties, all relative paths.
    1.47 +#
    1.48 +#   NEW_RESOURCE_BUNDLES_JAVA        - new resource bundles implemented in
    1.49 +#                                      Java, not localized
    1.50 +#   NEW_RESOURCE_BUNDLES_PROPERTIES  - new resource bundles implemented as
    1.51 +#                                      properties files, not localized
    1.52 +#   RESOURCE_BUNDLES_JAVA            - resource bundles implemented in
    1.53 +#                                      Java, localized
    1.54 +#   RESOURCE_BUNDLES_PROPERTIES      - new resource bundles implemented as
    1.55 +#                                      properties files, localized
    1.56 +#
    1.57 +# The following variable is now used for most .properties files in the JDK. 
    1.58 +# These properties files are converted into java and compiled with javac.
    1.59 +# The resulting .class files are usually smaller and are always faster to load. 
    1.60 +# The relative path to the properties file becomes a relative path to a
    1.61 +# java source file.
    1.62 +#
    1.63 +#   RESOURCE_BUNDLES_COMPILED_PROPERTIES - resource bundles implemented as
    1.64 +#                                          properties files, localized
    1.65 +#   NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES - same as above, not localized
    1.66 +#
    1.67 +# Other properties files to be installed are identified using the variable:
    1.68 +#
    1.69 +#   OTHER_PROPERTIES
    1.70 +#
    1.71 +
    1.72 +# Compile properties files into java source?
    1.73 +ifdef COMPILED_PROPERTIES_SUPERCLASS
    1.74 +  # Add all properties files to the compiled properties list (all or nothing)
    1.75 +  COMPILED_PROPERTIES += $(FILES_compiled_properties) $(FILES_properties)
    1.76 +else
    1.77 +  COMPILED_PROPERTIES_SUPERCLASS = ListResourceBundle
    1.78 +  COMPILED_PROPERTIES += $(FILES_compiled_properties)
    1.79 +endif
    1.80 +
    1.81 +# Determine the locale suffixes needed beyond the base bundle
    1.82 +
    1.83 +ifeq ($(LOCALE_SET_DEFINITION), plugin)
    1.84 +  LOCALE_SUFFIXES += $(PLUGIN_LOCALES)
    1.85 +endif
    1.86 +ifeq ($(LOCALE_SET_DEFINITION), jdk)
    1.87 +  LOCALE_SUFFIXES += $(JDK_LOCALES)
    1.88 +endif
    1.89 +ifeq ($(LOCALE_SET_DEFINITION), jre)
    1.90 +  LOCALE_SUFFIXES += $(JRE_LOCALES)
    1.91 +endif
    1.92 +
    1.93 +# Java files get tacked onto the standard list of files to compile
    1.94 +RESOURCE_BUNDLE_FILES_java += $(NEW_RESOURCE_BUNDLES_JAVA)
    1.95 +RESOURCE_BUNDLE_FILES_java += $(RESOURCE_BUNDLES_JAVA) \
    1.96 +    $(foreach file,$(RESOURCE_BUNDLES_JAVA), \
    1.97 +       $(foreach locale,$(LOCALE_SUFFIXES), \
    1.98 +	  $(basename $(file))_$(locale).java))
    1.99 +
   1.100 +# Add to java sources list
   1.101 +FILES_java += $(RESOURCE_BUNDLE_FILES_java)
   1.102 +
   1.103 +# Compiled properties files are translated to .java.
   1.104 +#   The .java files are generated into GENSRCDIR.
   1.105 +COMPILED_PROPERTIES += $(NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES)
   1.106 +COMPILED_PROPERTIES += $(RESOURCE_BUNDLES_COMPILED_PROPERTIES) \
   1.107 +    $(foreach file,$(RESOURCE_BUNDLES_COMPILED_PROPERTIES),\
   1.108 +      $(foreach locale,$(LOCALE_SUFFIXES),\
   1.109 +	 $(basename $(file))_$(locale)$(suffix $(file))))
   1.110 +
   1.111 +# Add to java sources list
   1.112 +FILES_java += $(COMPILED_PROPERTIES:%.properties=%.java)
   1.113 +
   1.114 +# Non-compiled files
   1.115 +PROPERTIES_FILES += $(NEW_RESOURCE_BUNDLES_PROPERTIES)
   1.116 +PROPERTIES_FILES += $(RESOURCE_BUNDLES_PROPERTIES) \
   1.117 +    $(foreach file,$(RESOURCE_BUNDLES_PROPERTIES), \
   1.118 +       $(foreach locale,$(LOCALE_SUFFIXES), \
   1.119 +	  $(basename $(file))_$(locale)$(suffix $(file))))
   1.120 +PROPERTIES_FILES += $(OTHER_PROPERTIES)
   1.121 +
   1.122 +#
   1.123 +# Compile Properties tool
   1.124 +#
   1.125 +COMPILEPROPERTIES_JARFILE = $(BUILDTOOLJARDIR)/compileproperties.jar
   1.126 +
   1.127 +#
   1.128 +# Strip Properties tool
   1.129 +#
   1.130 +STRIPPROPERTIES_JARFILE = $(BUILDTOOLJARDIR)/stripproperties.jar
   1.131 +
   1.132 +#
   1.133 +# Process and strip all non-compiled properties files (in a batch mode)
   1.134 +#
   1.135 +STRIP_PROP_FILES = $(PROPERTIES_FILES:%=$(CLASSDESTDIR)/%)
   1.136 +# To efficiently strip properties we use one run of StripProperties. 
   1.137 +# This macro gathers an option for use later.
   1.138 +STRIP_PROP_options=$(TEMPDIR)/strip_prop_options
   1.139 +define install-properties-file
   1.140 +$(install-file)
   1.141 +$(CHMOD) a+rw $@
   1.142 +@$(ECHO) "# Adding to strip properties list: $@"
   1.143 +$(ECHO) "$@" >> $(STRIP_PROP_options)
   1.144 +endef
   1.145 +
   1.146 +# Constructs command line options file
   1.147 +$(STRIP_PROP_options): $(STRIP_PROP_FILES)
   1.148 +	@$(TOUCH) $@
   1.149 +strip_prop_options_clean:
   1.150 +	@$(RM) $(STRIP_PROP_options)
   1.151 +
   1.152 +# Strip the properties files
   1.153 +strip_all_props: $(STRIPPROPERTIES_JARFILE) $(STRIP_PROP_options)
   1.154 +	@if [ -s $(STRIP_PROP_options) ] ; then \
   1.155 +          $(ECHO) "$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) -optionsfile $(STRIP_PROP_options)" ; \
   1.156 +          $(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) -optionsfile $(STRIP_PROP_options) ; \
   1.157 +        fi
   1.158 +	@$(java-vm-cleanup)
   1.159 +
   1.160 +#
   1.161 +# Creates files in CLASSDESTDIR
   1.162 +#
   1.163 +
   1.164 +# In some cases, we move files from package to resources subdir
   1.165 +$(CLASSDESTDIR)/$(PKGDIR)/resources/%.properties: \
   1.166 +	     $(SHARE_SRC)/classes/$(PKGDIR)/%.properties
   1.167 +	$(install-properties-file)
   1.168 +$(CLASSDESTDIR)/%.properties: $(SHARE_SRC)/classes/%.properties
   1.169 +	$(install-properties-file)
   1.170 +$(CLASSDESTDIR)/%.res: $(SHARE_SRC)/classes/%.res
   1.171 +	$(install-file)
   1.172 +$(CLASSDESTDIR)/%.dtd: $(SHARE_SRC)/classes/%.dtd
   1.173 +	$(install-file)
   1.174 +$(CLASSDESTDIR)/%.xml: $(SHARE_SRC)/classes/%.xml
   1.175 +	$(install-file)
   1.176 +$(CLASSDESTDIR)/%.prp: $(SHARE_SRC)/classes/%.prp
   1.177 +	$(install-file)
   1.178 +
   1.179 +$(GENSRCDIR)/%.java: $(PLATFORM_SRC)/classes/%.properties
   1.180 +	$(add-property-java-file)
   1.181 +$(GENSRCDIR)/%.java: $(SHARE_SRC)/classes/%.properties
   1.182 +	$(add-property-java-file)
   1.183 +$(GENSRCDIR)/%.java: $(GENSRCDIR)/%.properties
   1.184 +	$(add-property-java-file)
   1.185 +
   1.186 +# Create HK java file from zh_TW (explicit resource bundles only)
   1.187 +define create-hk-java-file
   1.188 +@$(prep-target)
   1.189 +$(CAT) $< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $@
   1.190 +endef
   1.191 +
   1.192 +# Explicit resource bundles
   1.193 +$(GENSRCDIR)/%_zh_HK.java: $(PLATFORM_SRC)/classes/%_zh_TW.java
   1.194 +	$(create-hk-java-file)
   1.195 +$(GENSRCDIR)/%_zh_HK.java: $(SHARE_SRC)/classes/%_zh_TW.java
   1.196 +	$(create-hk-java-file)
   1.197 +
   1.198 +# Compile of zh_HK properties just uses the zh_TW properties files
   1.199 +$(GENSRCDIR)/%_zh_HK.java: $(PLATFORM_SRC)/classes/%_zh_TW.properties
   1.200 +	$(add-property-java-file)
   1.201 +$(GENSRCDIR)/%_zh_HK.java: $(SHARE_SRC)/classes/%_zh_TW.properties
   1.202 +	$(add-property-java-file)
   1.203 +
   1.204 +# Simple delivery of zh_HK properties files just copies zh_TW properties files
   1.205 +$(CLASSDESTDIR)/%_zh_HK.properties: \
   1.206 +             $(PLATFORM_SRC)/classes/%_zh_TW.properties
   1.207 +	$(install-properties-file)
   1.208 +$(CLASSDESTDIR)/%_zh_HK.properties: \
   1.209 +             $(SHARE_SRC)/classes/%_zh_TW.properties
   1.210 +	$(install-properties-file)
   1.211 +
   1.212 +# List of java files converted from properties files needed
   1.213 +COMPILE_PROP_JAVA_FILES = $(COMPILED_PROPERTIES:%.properties=$(GENSRCDIR)/%.java)
   1.214 +
   1.215 +# Make sure the build rule creates all the properties
   1.216 +resources:
   1.217 +
   1.218 +ifneq ($(PROPERTIES_FILES),)
   1.219 +  resources: strip_prop_options_clean   strip_all_props
   1.220 +  clobber clean:: 
   1.221 +	$(RM) $(STRIP_PROP_FILES)
   1.222 +	$(RM) $(STRIP_PROP_options)
   1.223 +endif
   1.224 +
   1.225 +.PHONY: resources \
   1.226 +	strip_prop_options_clean   strip_all_props
   1.227 +

mercurial