jdk/make/gensrc/GensrcProperties.gmk
changeset 27088 ea6446a9121b
parent 26192 33b90e93e3bf
child 27753 a6c284fa0745
child 27565 729f9700483a
equal deleted inserted replaced
27087:de850fa3be4d 27088:ea6446a9121b
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    23 # questions.
    24 #
    24 #
    25 
    25 
    26 # All .properties files to be compiled are appended to this variable.
    26 # This file defines macros that sets up rules for generating java classes
    27 ALL_COMPILED_PROPSOURCES :=
    27 # from resource bundle properties files.
    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 
    28 
    33 define add_properties_to_compile
    29 ################################################################################
    34   # $1 is the name of the properties group
    30 # Helper macro for SetupCopy-zh_HK.
    35   # $2 is the files belonging to this group
    31 define SetupOneCopy-zh_HK
    36   # $3 is the super class for the generated java file.
    32   $1_$2_TARGET := $$(patsubst $(JDK_TOPDIR)/src/$(MODULE)/share/classes/%, \
       
    33       $(JDK_OUTPUTDIR)/gensrc/$(MODULE)/%, \
       
    34       $$(subst _zh_TW,_zh_HK, $2))
    37 
    35 
    38   # Convert <root>/jdk/src/<module>/share/classes/sun/util/resources/CurrencyNames_sv.properties
    36   $$($1_$2_TARGET): $2
    39   # to <build>/jdk/gensrc/<module/sun/util/resources/CurrencyNames_sv.java
    37 	$(MKDIR) -p $$(@D)
    40   $1_PROPJAVAS := $$(patsubst $(JDK_TOPDIR)/src/%.properties, \
    38 	$(CAT) $$< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $$@
    41       $(JDK_OUTPUTDIR)/gensrc/%.java, \
       
    42       $$(subst /share/classes,, \
       
    43       $$(subst /$(OPENJDK_TARGET_OS_API_DIR)/classes,, \
       
    44       $$(subst /$(OPENJDK_TARGET_OS)/classes,, $2))))
       
    45 
    39 
    46   # Accumulate all found properties files.
    40   $1 += $$($1_$2_TARGET)
    47   ALL_COMPILED_PROPSOURCES += $2
       
    48 
       
    49   # Generate the list of to be created java files.
       
    50   ALL_COMPILED_PROPJAVAS += $$($1_PROPJAVAS)
       
    51 
       
    52   # Now generate a sequence of 
       
    53   # "-compile ...CurrencyNames_sv.properties ...CurrencyNames_sv.java ListResourceBundle"
       
    54   # suitable to be fed into the CompileProperties command.
       
    55   COMPILE_PROPCMDLINE += $$(subst _SPACE_,$(SPACE),$$(join $$(addprefix -compile_SPACE_, $2), \
       
    56       $$(addsuffix _SPACE_$(strip $3), \
       
    57       $$(addprefix _SPACE_, $$($1_PROPJAVAS)))))
       
    58 endef
    41 endef
    59 
    42 
    60 ################################################################################
    43 ################################################################################
    61 # Some packages have properties that need to be converted to java source files.
    44 # Creates rules for copying zh_TW resources to zh_HK.
    62 COMPILE_PROP_SRC_FILES := \
    45 # Param 1 - Variable to add targets to
    63     $(filter %.properties, $(call CacheFind, \
    46 # Param 2 - Files to copy from
    64         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/accessibility/internal/resources \
    47 define SetupCopy-zh_HK
    65         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/resources \
    48   $$(foreach f, $2, $$(eval $$(call SetupOneCopy-zh_HK,$1,$$f)))
    66         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources \
    49 endef
    67         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/basic/resources \
       
    68         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/metal/resources \
       
    69         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/synth/resources \
       
    70         $(JDK_TOPDIR)/src/jdk.jdi/share/classes/com/sun/tools/jdi/resources \
       
    71         $(JDK_TOPDIR)/src/java.desktop/share/classes/sun/awt/resources \
       
    72         $(JDK_TOPDIR)/src/java.base/share/classes/sun/launcher/resources \
       
    73         $(JDK_TOPDIR)/src/java.management/share/classes/sun/management/resources \
       
    74         $(JDK_TOPDIR)/src/java.desktop/share/classes/sun/print/resources \
       
    75         $(JDK_TOPDIR)/src/jdk.dev/share/classes/sun/tools/jar/resources \
       
    76         $(JDK_TOPDIR)/src/java.logging/share/classes/sun/util/logging/resources)) \
       
    77     #
       
    78 
       
    79 ifeq ($(OPENJDK_TARGET_OS), macosx)
       
    80   COMPILE_PROP_SRC_FILES += \
       
    81       $(filter %.properties, $(call CacheFind, \
       
    82           $(JDK_TOPDIR)/src/java.desktop/macosx/classes/com/apple/laf/resources \
       
    83           $(JDK_TOPDIR)/src/java.desktop/macosx/classes/sun/awt/resources)) \
       
    84       #
       
    85 endif
       
    86 
       
    87 ifeq ($(OPENJDK_TARGET_OS), windows)
       
    88   COMPILE_PROP_SRC_FILES += \
       
    89       $(filter %.properties, $(call CacheFind, \
       
    90           $(JDK_TOPDIR)/src/java.desktop/windows/classes/sun/awt/windows)) \
       
    91       #
       
    92 else # ! windows
       
    93   COMPILE_PROP_SRC_FILES += \
       
    94       $(filter %.properties, $(call CacheFind, \
       
    95           $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources)) \
       
    96       #
       
    97 endif
       
    98 
       
    99 $(eval $(call add_properties_to_compile,LIST_RESOURCE_BUNDLE, \
       
   100     $(COMPILE_PROP_SRC_FILES), ListResourceBundle))
       
   101 
       
   102 # sun/util/resources
       
   103 $(eval $(call add_properties_to_compile,SUN_UTIL, \
       
   104     $(filter %.properties, \
       
   105         $(call CacheFind, $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/resources) \
       
   106         $(call CacheFind, $(JDK_TOPDIR)/src/jdk.localedata/share/classes/sun/util/resources)), \
       
   107     sun.util.resources.LocaleNamesBundle))
       
   108 
    50 
   109 ################################################################################
    51 ################################################################################
   110 # Now setup the rule for the generation of the resource bundles.
    52 # Creates a rule that runs CompileProperties on a set of properties files.
   111 $(JDK_OUTPUTDIR)/gensrc/_the.compiled_properties: $(ALL_COMPILED_PROPSOURCES) $(BUILD_TOOLS_JDK)
    53 # Param 1 - Variable to add targets to, must not contain space
   112         # Generate all output directories in advance since the build tool does not do that...
    54 # Param 2 - Properties files to process
   113 	$(MKDIR) -p $(sort $(dir $(ALL_COMPILED_PROPJAVAS)))
    55 # Param 3 - The super class for the generated classes
   114 	$(ECHO) Compiling $(words $(ALL_COMPILED_PROPSOURCES)) properties into resource bundles
    56 define SetupCompileProperties
   115 	$(call ListPathsSafely,COMPILE_PROPCMDLINE,\n, >> $(JDK_OUTPUTDIR)/gensrc/_the.cmdline)
    57   $1_SRCS := $2
   116 	$(TOOL_COMPILEPROPERTIES) -quiet @$(JDK_OUTPUTDIR)/gensrc/_the.cmdline
    58   $1_CLASS := $3
   117 	$(TOUCH) $@
       
   118 
    59 
   119 $(ALL_COMPILED_PROPJAVAS): $(JDK_OUTPUTDIR)/gensrc/_the.compiled_properties
    60   # Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
       
    61   # to .../langtools/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
       
    62   # Strip away prefix and suffix, leaving for example only: 
       
    63   # "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
       
    64   $1_JAVAS := $$(patsubst $(JDK_TOPDIR)/src/%, \
       
    65       $(JDK_OUTPUTDIR)/gensrc/%, \
       
    66       $$(patsubst %.properties, %.java, \
       
    67       $$(subst /share/classes,, $$($1_SRCS))))
       
    68 
       
    69   # Generate the package dirs for the to be generated java files. Sort to remove
       
    70   # duplicates.
       
    71   $1_DIRS := $$(sort $$(dir $$($1_JAVAS)))
       
    72 
       
    73   # Now generate a sequence of:
       
    74   # "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
       
    75   # suitable to be fed into the CompileProperties command.
       
    76   $1_CMDLINE := $$(subst _SPACE_, $(SPACE), \
       
    77       $$(join $$(addprefix -compile_SPACE_, $$($1_SRCS)), \
       
    78       $$(addsuffix _SPACE_$$($1_CLASS), \
       
    79       $$(addprefix _SPACE_, $$($1_JAVAS)))))
       
    80 
       
    81   $1_TARGET := $(JDK_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.done
       
    82   $1_CMDLINE_FILE := $(JDK_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.cmdline
       
    83 
       
    84   # Now setup the rule for the generation of the resource bundles.
       
    85   $$($1_TARGET): $$($1_SRCS) $$($1_JAVAS) $(BUILD_TOOLS_JDK)
       
    86 	$(MKDIR) -p $$(@D) $$($1_DIRS)
       
    87 	$(ECHO) Compiling $$(words $$($1_SRCS)) properties into resource bundles for $(MODULE)
       
    88 	$(RM) $$($1_CMDLINE_FILE)
       
    89 	$$(call ListPathsSafely,$1_CMDLINE,\n, >> $$($1_CMDLINE_FILE))
       
    90 	$(TOOL_COMPILEPROPERTIES) -quiet @$$($1_CMDLINE_FILE)
       
    91 	$(TOUCH) $$@
       
    92 
       
    93   $$($1_JAVAS): $$($1_SRCS)
       
    94 
       
    95   # Create zh_HK versions of all zh_TW files created above
       
    96   $$(eval $$(call SetupCopy-zh_HK,$1_HK,$$(filter %_zh_TW.java, $$($1_JAVAS))))
       
    97   # The zh_HK copy must wait for the compile properties tool to run
       
    98   $$($1_HK): $$($1_TARGET)
       
    99 
       
   100   $1 += $$($1_JAVAS) $$($1_TARGET) $$($1_HK)
       
   101 endef
   120 
   102 
   121 ################################################################################
   103 ################################################################################
   122 # Some zh_HK resources are just copies of zh_TW
       
   123 
       
   124 define convert_tw_to_hk
       
   125   $(MKDIR) -p $(@D)
       
   126   $(CAT) $< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $@
       
   127 endef
       
   128 
       
   129 # Some are copies of existing sources
       
   130 $(JDK_OUTPUTDIR)/gensrc/java.desktop/%_zh_HK.java: \
       
   131     $(JDK_TOPDIR)/src/java.desktop/share/classes/%_zh_TW.java
       
   132 	$(call convert_tw_to_hk)
       
   133 
       
   134 $(JDK_OUTPUTDIR)/gensrc/java.base/%_zh_HK.java: \
       
   135     $(JDK_TOPDIR)/src/java.base/share/classes/%_zh_TW.java
       
   136 	$(call convert_tw_to_hk)
       
   137 
       
   138 # Others are copies of sources generated by this makefile
       
   139 $(JDK_OUTPUTDIR)/gensrc/%_zh_HK.java: $(JDK_OUTPUTDIR)/gensrc/%_zh_TW.java
       
   140 	$(call convert_tw_to_hk)
       
   141 
       
   142 # The existing sources
       
   143 ZH_HK_JAVA := java.desktop/sun/applet/resources/MsgAppletViewer_zh_HK.java \
       
   144     java.base/sun/misc/resources/Messages_zh_HK.java \
       
   145     java.base/sun/security/util/AuthResources_zh_HK.java \
       
   146     java.base/sun/security/util/Resources_zh_HK.java
       
   147 
       
   148 ZH_HK_JAVA_FILES := $(addprefix $(JDK_OUTPUTDIR)/gensrc/, $(ZH_HK_JAVA)) \
       
   149     $(filter-out $(JDK_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/zh/%, \
       
   150     $(subst _zh_TW,_zh_HK,$(filter %_zh_TW.java, $(ALL_COMPILED_PROPJAVAS))))
       
   151 
       
   152 ################################################################################
       
   153 
       
   154 GENSRC_PROPERTIES := $(ALL_COMPILED_PROPJAVAS) $(ZH_HK_JAVA_FILES)