jdk/makefiles/GensrcLocaleDataMetaInfo.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 # Scan for all locale resources and extract for which locales there exists
       
    27 # resources. Then put this meta information about exiting (supported?) locales
       
    28 # into LocaleDataMetaInfo.java
       
    29 
       
    30 # First go look for all locale files
       
    31 LOCALE_FILES:=$(shell $(FIND) $(JDK_TOPDIR)/src/share/classes \
       
    32 	-name "FormatData_*.java" -o -name "FormatData_*.properties" -o \
       
    33 	-name "CollationData_*.java" -o -name "CollationData_*.properties" -o \
       
    34 	-name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \
       
    35 	-name "LocaleNames_*.java" -o -name "LocaleNames_*.properties" -o \
       
    36 	-name "CurrencyNames_*.java" -o -name "CurrencyNames_*.properties" -o \
       
    37 	-name "CalendarData_*.java" -o -name "CalendarData_*.properties")
       
    38 
       
    39 # Then translate the locale files into for example: FormatData_sv 
       
    40 LOCALE_RESOURCES:=$(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES)))))
       
    41 
       
    42 # Include the list of resources found during the previous compile.
       
    43 -include $(JDK_OUTPUTDIR)/gensrc_localedatametainfo/_the.locale_resources
       
    44 
       
    45 MISSING_RESOURCES:=$(filter-out $(LOCALE_RESOURCES),$(PREV_LOCALE_RESOURCES))
       
    46 NEW_RESOURCES:=$(filter-out $(PREV_LOCALE_RESOURCES),$(LOCALE_RESOURCES))
       
    47 
       
    48 ifneq (,$(MISSING_RESOURCES)$(NEW_RESOURCES))
       
    49     # There is a difference in the number of supported resources. Trigger a regeneration.
       
    50     $(shell $(RM) $(JDK_OUTPUTDIR)/gensrc_localedatametainfo/sun/util/LocaleDataMetaInfo.java)
       
    51 endif
       
    52 
       
    53 # The non-euro zone locales have to be separated from the euro-zone locales.
       
    54 NON_EURO_LOCALES:=ar% hi% iw% ja% ko% th% vi% zh%
       
    55 
       
    56 # This macro creates a sed expression that substitues for example:
       
    57 # #FormatData_EuroLocales# with: be be_BY bg bg_BG ca ca_ES... and some more.
       
    58 CAPTURE_LOCALE='s/$$(HASH)$1_$2EuroLocales$$(HASH)/ $$($3 $(NON_EURO_LOCALES),$$(filter-out $1,$$(subst $1_,,$$(filter $1_%,$(LOCALE_RESOURCES)))))/g'
       
    59 
       
    60 SED_ARGS:=-e 's|$(HASH)warn This file is preprocessed before being compiled|// -- This file was mechanically generated: Do not edit! -- //|g'
       
    61 #sun.text.resources.FormatData
       
    62 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,FormatData,,filter-out))
       
    63 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,FormatData,Non,filter))
       
    64 
       
    65 #sun.text.resources.CollationData
       
    66 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,CollationData,,filter-out))
       
    67 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,CollationData,Non,filter))
       
    68 
       
    69 #sun.util.resources.TimeZoneNames
       
    70 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,TimeZoneNames,,filter-out))
       
    71 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,TimeZoneNames,Non,filter))
       
    72 
       
    73 #sun.util.resources.LocaleNames
       
    74 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,LocaleNames,,filter-out))
       
    75 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,LocaleNames,Non,filter))
       
    76 
       
    77 #sun.util.resources.CurrencyNames
       
    78 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,CurrencyNames,,filter-out))
       
    79 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,CurrencyNames,Non,filter))
       
    80 
       
    81 #sun.util.resources.CalendarData
       
    82 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,CalendarData,,filter-out))
       
    83 $(eval SED_ARGS+=-e $(call CAPTURE_LOCALE,CalendarData,Non,filter))
       
    84 
       
    85 $(JDK_OUTPUTDIR)/gensrc_localedatametainfo/sun/util/LocaleDataMetaInfo.java: \
       
    86 		$(JDK_TOPDIR)/src/share/classes/sun/util/LocaleDataMetaInfo-XLocales.java.template
       
    87 	mkdir -p $(@D)
       
    88 	$(ECHO) Creating sun/util/LocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources.
       
    89 	$(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" > $(JDK_OUTPUTDIR)/gensrc_localedatametainfo/_the.locale_resources
       
    90 	$(SED) $(SED_ARGS) $(JDK_TOPDIR)/src/share/classes/sun/util/LocaleDataMetaInfo-XLocales.java.template \
       
    91 		> $(JDK_OUTPUTDIR)/gensrc_localedatametainfo/sun/util/LocaleDataMetaInfo.java
       
    92 
       
    93 GENSRC_LOCALEDATAMETAINFO:=$(JDK_OUTPUTDIR)/gensrc_localedatametainfo/sun/util/LocaleDataMetaInfo.java