GensrcLocaleDataMetaInfo.gmk 5.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#
# Copyright (c) 2011, 2012, 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.
#

# Scan for all locale resources and extract for which locales there exists
# resources. Then put this meta information about exiting (supported?) locales
# into LocaleDataMetaInfo.java

# First go look for all locale files
LOCALE_FILES:=$(shell $(FIND) $(JDK_TOPDIR)/src/share/classes \
	-name "FormatData_*.java" -o -name "FormatData_*.properties" -o \
	-name "CollationData_*.java" -o -name "CollationData_*.properties" -o \
	-name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \
	-name "LocaleNames_*.java" -o -name "LocaleNames_*.properties" -o \
	-name "CurrencyNames_*.java" -o -name "CurrencyNames_*.properties" -o \
	-name "CalendarData_*.java" -o -name "CalendarData_*.properties")

# Then translate the locale files into for example: FormatData_sv 
LOCALE_RESOURCES:=$(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES)))))

# Include the list of resources found during the previous compile.
O
ohair 已提交
43
-include $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources
44 45 46 47 48 49

MISSING_RESOURCES:=$(filter-out $(LOCALE_RESOURCES),$(PREV_LOCALE_RESOURCES))
NEW_RESOURCES:=$(filter-out $(PREV_LOCALE_RESOURCES),$(LOCALE_RESOURCES))

ifneq (,$(MISSING_RESOURCES)$(NEW_RESOURCES))
    # There is a difference in the number of supported resources. Trigger a regeneration.
O
ohair 已提交
50
    $(shell $(RM) $(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java)
51 52
endif

53 54
# The US locales
US_LOCALES:=en en-US
55

56
# ja-JP-JP and th-TH-TH need to be manually added, as they don't have any resource files.
57
ALL_NON_US_LOCALES:=ja-JP-JP th-TH-TH
58 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
# This macro creates a sed expression that substitues for example:
62
# #FormatData_USLocales# with: en and/or en_US.
63 64
define CaptureLocale
    $1_LOCALES := $$(subst _,-,$$(filter-out $1,$$(subst $1_,,$$(filter $1_%,$(LOCALE_RESOURCES)))))
65 66
    $1_US_LOCALES := $$(filter $(US_LOCALES),$$($1_LOCALES))
    $1_NON_US_LOCALES := $$(filter-out $(US_LOCALES),$$($1_LOCALES))
67

68 69
    ALL_US_LOCALES += $$($1_US_LOCALES)
    ALL_NON_US_LOCALES += $$($1_NON_US_LOCALES)
70

71 72 73
    # Don't sed in a space if there are no locales.
    SED_ARGS+= -e 's/$$(HASH)$1_USLocales$$(HASH)/$$(if $$($1_US_LOCALES),$$(SPACE)$$($1_US_LOCALES),)/g'
    SED_ARGS+= -e 's/$$(HASH)$1_NonUSLocales$$(HASH)/$$(if $$($1_NON_US_LOCALES),$$(SPACE)$$($1_NON_US_LOCALES),)/g'
74
endef
75 76

#sun.text.resources.FormatData
77
$(eval $(call CaptureLocale,FormatData))
78 79

#sun.text.resources.CollationData
80
$(eval $(call CaptureLocale,CollationData))
81 82

#sun.util.resources.TimeZoneNames
83
$(eval $(call CaptureLocale,TimeZoneNames))
84 85

#sun.util.resources.LocaleNames
86
$(eval $(call CaptureLocale,LocaleNames))
87 88

#sun.util.resources.CurrencyNames
89
$(eval $(call CaptureLocale,CurrencyNames))
90 91

#sun.util.resources.CalendarData
92 93
$(eval $(call CaptureLocale,CalendarData))

94 95
SED_ARGS+= -e 's/$(HASH)AvailableLocales_USLocales$(HASH)/$(sort $(ALL_US_LOCALES))/g'
SED_ARGS+= -e 's/$(HASH)AvailableLocales_NonUSLocales$(HASH)/$(sort $(ALL_NON_US_LOCALES))/g'
96

O
ohair 已提交
97
$(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java: \
98
		$(JDK_TOPDIR)/src/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template
99
	$(MKDIR) -p $(@D)
100
	$(ECHO) Creating sun/util/LocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources.
O
ohair 已提交
101
	$(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" > $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources
102
	$(SED) $(SED_ARGS) $< > $@
103

O
ohair 已提交
104
GENSRC_LOCALEDATAMETAINFO:=$(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java
105 106 107

###

O
ohair 已提交
108
GENSRC_CRBC_DST := $(JDK_OUTPUTDIR)/gensrc/sun/util/CoreResourceBundleControl.java
109 110 111 112 113 114 115 116 117 118 119 120
GENSRC_CRBC_CMD := $(JDK_TOPDIR)/makefiles/scripts/localelist.sh

JRE_NONEXIST_LOCALES := en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh

$(GENSRC_CRBC_DST) : $(JDK_TOPDIR)/src/share/classes/sun/util/CoreResourceBundleControl-XLocales.java.template \
                     $(GENSRC_CRBC_CMD)
	$(MKDIR) -p $(@D)
	NAWK="$(NAWK)" SED="$(SED)" $(SH) $(GENSRC_CRBC_CMD) "$(JRE_NONEXIST_LOCALES)" $< $@ 

GENSRC_LOCALEDATAMETAINFO += $(GENSRC_CRBC_DST)

###