# # Copyright (c) 2011, 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 file defines macros that sets up rules for generating java classes # from resource bundle properties files. ################################################################################ # Helper macro for SetupCopy-zh_HK. define SetupOneCopy-zh_HK $1_$2_TARGET := $$(patsubst $(JDK_TOPDIR)/src/$(MODULE)/share/classes/%, \ $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/%, \ $$(subst _zh_TW,_zh_HK, $2)) $$($1_$2_TARGET): $2 $(MKDIR) -p $$(@D) $(CAT) $$< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $$@ $1 += $$($1_$2_TARGET) endef ################################################################################ # Creates rules for copying zh_TW resources to zh_HK. # Param 1 - Variable to add targets to # Param 2 - Files to copy from define SetupCopy-zh_HK $$(foreach f, $2, $$(eval $$(call SetupOneCopy-zh_HK,$1,$$f))) endef ################################################################################ # Creates a rule that runs CompileProperties on a set of properties files. # Param 1 - Variable to add targets to, must not contain space # Param 2 - Properties files to process # Param 3 - The super class for the generated classes define SetupCompileProperties $1_SRCS := $2 $1_CLASS := $3 # Convert .../src//share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties # to .../langtools/gensrc//com/sun/tools/javac/resources/javac_zh_CN.java # Strip away prefix and suffix, leaving for example only: # "/share/classes/com/sun/tools/javac/resources/javac_zh_CN" $1_JAVAS := $$(patsubst $(JDK_TOPDIR)/src/%, \ $(SUPPORT_OUTPUTDIR)/gensrc/%, \ $$(patsubst %.properties, %.java, \ $$(subst /share/classes,, $$($1_SRCS)))) # Generate the package dirs for the to be generated java files. Sort to remove # duplicates. $1_DIRS := $$(sort $$(dir $$($1_JAVAS))) # 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. $1_CMDLINE := $$(subst _SPACE_, $(SPACE), \ $$(join $$(addprefix -compile_SPACE_, $$($1_SRCS)), \ $$(addsuffix _SPACE_$$($1_CLASS), \ $$(addprefix _SPACE_, $$($1_JAVAS))))) $1_TARGET := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.done $1_CMDLINE_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.cmdline # Now setup the rule for the generation of the resource bundles. $$($1_TARGET): $$($1_SRCS) $$($1_JAVAS) $(BUILD_TOOLS_JDK) $(MKDIR) -p $$(@D) $$($1_DIRS) $(ECHO) Compiling $$(words $$($1_SRCS)) properties into resource bundles for $(MODULE) $(RM) $$($1_CMDLINE_FILE) $$(call ListPathsSafely,$1_CMDLINE,\n, >> $$($1_CMDLINE_FILE)) $(TOOL_COMPILEPROPERTIES) -quiet @$$($1_CMDLINE_FILE) $(TOUCH) $$@ $$($1_JAVAS): $$($1_SRCS) # Create zh_HK versions of all zh_TW files created above $$(eval $$(call SetupCopy-zh_HK,$1_HK,$$(filter %_zh_TW.java, $$($1_JAVAS)))) # The zh_HK copy must wait for the compile properties tool to run $$($1_HK): $$($1_TARGET) $1 += $$($1_JAVAS) $$($1_TARGET) $$($1_HK) endef ################################################################################