• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2016 and later: Unicode, Inc. and others.
2# License & terms of use: http://www.unicode.org/copyright.html
3# Copyright (C) 2010-2014, International Business Machines Corporation and others.
4# All Rights Reserved.
5#
6# Commands for regenerating ICU4C locale data (.txt files) from CLDR,
7# updated to apply to CLDR 37 / ICU 67 and later versions.
8#
9# The process requires local copies of
10#    - CLDR (the source of most of the data, and some Java tools)
11#    - The complete ICU source tree, including:
12#      tools - includes the LdmlConverter build tool and associated config files
13#      icu4c - the target for converted CLDR data, and source for ICU4J data;
14#              includes tests for the converted data
15#      icu4j - the target for updated data jars; includes tests for the converted
16#              data
17#
18# For an official CLDR data integration into ICU, these should be clean, freshly
19# checked-out. For released CLDR sources, an alternative to checking out sources
20# for a given version is downloading the zipped sources for the common (core.zip)
21# and tools (tools.zip) directory subtrees from the Data column in
22# [http://cldr.unicode.org/index/downloads].
23#
24# The versions of each of these must match. Included with the release notes for
25# ICU is the version number and/or a CLDR git tag name for the revision of CLDR
26# that was the source of the data for that release of ICU.
27#
28# Besides a standard JDK, the process also requires ant and maven
29# (http://ant.apache.org/),
30# plus the xml-apis.jar from the Apache xalan package
31# (http://xml.apache.org/xalan-j/downloads.html).
32#
33# You will also need to have performed the CLDR Maven setup (non-Eclipse version)
34# per http://cldr.unicode.org/development/maven
35#
36# Note: Enough things can (and will) fail in this process that it is best to
37#   run the commands separately from an interactive shell. They should all
38#   copy and paste without problems.
39#
40# It is often useful to save logs of the output of many of the steps in this
41# process. The commands below put log files in /tmp; you may want to put them
42# somewhere else.
43#
44#----
45#
46# There are several environment variables that need to be defined.
47#
48# a) Java- and ant-related variables
49#
50# JAVA_HOME:     Path to JDK (a directory, containing e.g. bin/java, bin/javac,
51#                etc.); on many systems this can be set using
52#                `/usr/libexec/java_home`.
53#
54# ANT_OPTS:      You may want to set:
55#
56#                -Xmx4096m, to give Java more memory; otherwise it may run out
57#                 of heap.
58#
59# b) CLDR-related variables
60#
61# CLDR_DIR:      This is the path to the to root of standard CLDR sources, below
62#                which are the common and tools directories.
63#
64# CLDR_CLASSES:  Path to the CLDR Tools classes directory. If not set, defaults
65#                to $CLDR_DIR/tools/java/classes
66#
67# CLDR_TMP_DIR:  Parent of temporary CLDR production data.
68#                Defaults to $CLDR_DIR/../cldr-aux (sibling to CLDR_DIR).
69#
70#                *** NOTE ***: In CLDR 36 and 37, the GenerateProductionData tool
71#                no longer generates data by default into $CLDR_TMP_DIR/production;
72#                instead it generates data into $CLDR_DIR/../cldr-staging/production
73#                (though there is a command-line option to override this). However
74#                the rest of the build still assumes that the generated data is in
75#                $CLDR_TMP_DIR/production. So CLDR_TMP_DIR must be defined to be
76#                $CLDR_DIR/../cldr-staging
77#
78# c) ICU-related variables
79# These variables only need to be set if you're directly reusing the
80# commands below.
81#
82# ICU4C_DIR:     Path to root of ICU4C sources, below which is the source dir.
83#
84# ICU4J_ROOT:    Path to root of ICU4J sources, below which is the main dir.
85#
86# TOOLS_ROOT:    Path to root of ICU tools directory, below which is (e.g.) the
87#                cldr and unicodetools dirs.
88#
89#----
90#
91# If you are adding or removing locales, or specific kinds of locale data,
92# there are some xml files in the ICU sources that need to be updated (these xml
93# files are used in addition to the CLDR files as inputs to the CLDR data build
94# process for ICU):
95#
96# The primary file to edit for ICU 67 and later is
97#
98#    $TOOLS_ROOT/cldr/cldr-to-icu/build-icu-data.xml
99#
100#----
101#
102# For an official CLDR data integration into ICU, there are some additional
103# considerations:
104#
105# a) Don't commit anything in ICU sources (and possibly any changes in CLDR
106#    sources, depending on their nature) until you have finished testing and
107#    resolving build issues and test failures for both ICU4C and ICU4J.
108#
109# b) There are version numbers that may need manual updating in CLDR (other
110#    version numbers get updated automatically, based on these):
111#
112#    common/dtd/ldml.dtd                            - update cldrVersion
113#    common/dtd/ldmlBCP47.dtd                       - update cldrVersion
114#    common/dtd/ldmlSupplemental.dtd                - update cldrVersion
115#    common/dtd/ldmlSupplemental.dtd                - updateunicodeVersion
116#    keyboards/dtd/ldmlKeyboard.dtd                 - update cldrVersion
117#    tools/java/org/unicode/cldr/util/CLDRFile.java - update GEN_VERSION
118#
119# c) After everything is committed, you will need to tag the CLDR and ICU
120#    sources that ended up being used for the integration; see step 16
121#    below.
122#
123################################################################################
124
125# 1a. Java and ant variables, adjust for your system
126
127export JAVA_HOME=`/usr/libexec/java_home`
128export ANT_OPTS="-Xmx4096m"
129
130# 1b. CLDR variables, adjust for your setup; with cygwin it might be e.g.
131# CLDR_DIR=`cygpath -wp /build/cldr`
132
133export CLDR_DIR=$HOME/cldr-myfork
134
135# 1c. ICU variables
136
137export ICU4C_DIR=$HOME/icu-myfork/icu4c
138export ICU4J_ROOT=$HOME/icu-myfork/icu4j
139export TOOLS_ROOT=$HOME/icu-myfork/tools
140
141# 2. Build and install the CLDR jar
142
143cd $TOOLS_ROOT/cldr
144ant install-cldr-libs
145
146See the $TOOLS_ROOT/cldr/lib/README.txt file for more information on the CLDR
147jar and the install-cldr-jars.sh script.
148
149# 3. Configure ICU4C, build and test without new data first, to verify that
150# there are no pre-existing errors. Here <platform> is the runConfigureICU
151# code for the platform you are building, e.g. Linux, MacOSX, Cygwin.
152
153cd $ICU4C_DIR/source
154./runConfigureICU <platform>
155make clean
156make check 2>&1 | tee /tmp/icu4c-oldData-makeCheck.txt
157
158# 4a. Generate the CLDR production data. This process uses ant with ICU's
159# data/build.xml
160#
161# Running "ant cleanprod" is necessary to clean out the production data directory
162# (usually $CLDR_TMP_DIR/production ), required if any CLDR data has changed.
163#
164# Running "ant setup" is not required, but it will print useful errors to
165# debug issues with your path when it fails.
166
167cd $ICU4C_DIR/source/data
168ant cleanprod
169ant setup
170ant proddata 2>&1 | tee /tmp/cldr-newData-proddataLog.txt
171
172# 4b. Build the new ICU4C data files; these include .txt files and .py files.
173# These new files will replace whatever was already present in the ICU4C sources.
174# This process uses the LdmlConverter in $TOOLS_ROOT/cldr/cldr-to-icu/;
175# see $TOOLS_ROOT/cldr/cldr-to-icu/README.txt
176#
177# This process will take several minutes, during most of which there will be no log
178# output (so do not assume nothing is happening). Keep a log so you can investigate
179# anything that looks suspicious.
180#
181# Note that "ant clean" should not be run before this. The build-icu-data.xml process
182# will automatically run its own "clean" step to delete files it cannot determine to
183# be ones that it would generate, except for pasts listed in <retain> elements such as
184# coll/de__PHONEBOOK.txt, coll/de_.txt, etc.
185#
186# Before running Ant to regenerate the data, make any necessary changes to the
187# build-icu-data.xml file, such as adding new locales etc.
188
189cd $TOOLS_ROOT/cldr/cldr-to-icu
190ant -f build-icu-data.xml -DcldrDataDir="$CLDR_TMP_DIR/production" | tee /tmp/cldr-newData-builddataLog.txt
191
192# 4c. Update the CLDR testData files needed by ICU4C and ICU4J tests, ensuring
193# they're representative of the newest CLDR data.
194
195cd $TOOLS_ROOT/cldr
196ant copy-cldr-testdata
197
198# 4d. Copy from CLDR common/testData/localeIdentifiers/localeCanonicalization.txt
199# into icu4c/source/test/testdata/localeCanonicalization.txt
200# and icu4j/main/tests/core/src/com/ibm/icu/dev/data/unicode/localeCanonicalization.txt
201# and add the following line to the beginning of these two files
202# # File copied from cldr common/testData/localeIdentifiers/localeCanonicalization.txt
203
204# 4e. For the time being, manually re-add the lstm entries in data/brkitr/root.txt
205
206open $ICU4C_DIR/source/data/brkitr/root.txt
207
208# paste the following block at the end, after the dictionaries block>
209    lstm{
210        Thai{"Thai_graphclust_model4_heavy.res"}
211        Mymr{"Burmese_graphclust_model5_heavy.res"}
212    }
213
214# 5. Check which data files have modifications, which have been added or removed
215# (if there are no changes, you may not need to proceed further). Make sure the
216# list seems reasonable.
217
218cd $ICU4C_DIR/source/data
219git status
220
221# 5a. You may also want to check which files were modified in CLDR production data:
222
223cd $CLDR_TMP_DIR
224git status
225
226# 6. Fix any errors, investigate any warnings.
227#
228# Fixing may entail modifying CLDR source data or TOOLS_ROOT config files or
229# tooling.
230
231# 7. Now rebuild ICU4C with the new data and run make check tests.
232# Again, keep a log so you can investigate the errors.
233cd $ICU4C_DIR/source
234
235# 7a. If any files were added or removed (likely), re-run configure:
236./runConfigureICU <platform>
237make clean
238
239# 7b. Now do the rebuild.
240make check 2>&1 | tee /tmp/icu4c-newData-makeCheck.txt
241
242# 8. Investigate each test case failure. The first run processing new CLDR data
243# from the Survey Tool can result in thousands of failures (in many cases, one
244# CLDR data fix can resolve hundreds of test failures). If the error is caused
245# by bad CLDR data, then file a CLDR bug, fix the data, and regenerate from
246# step 4. If the data is OK but the testcase needs to be updated because the
247# data has legitimately changed, then update the testcase. You will check in
248# the updated testcases along with the new ICU data at the end of this process.
249# Note that if the new data has any differences in structure, you will have to
250# update test/testdata/structLocale.txt or /tsutil/cldrtest/TestLocaleStructure
251# may fail.
252# Repeat steps 4-7 until there are no errors.
253
254# 9. You can also run the make check tests in exhaustive mode. As an alternative
255# you can run them as part of the pre-merge tests by adding the following as a
256# comment in the pull request: "/azp run CI-Exhaustive". You should do one or the
257# other; the exhaustive tests are *not* run automatically on each pull request,
258# and are only run occasionally on the default branch.
259
260cd $ICU4C_DIR/source
261export INTLTEST_OPTS="-e"
262export CINTLTST_OPTS="-e"
263make check 2>&1 | tee /tmp/icu4c-newData-makeCheckEx.txt
264
265# 10. Again, investigate each failure, fixing CLDR data or ICU test cases as
266# appropriate, and repeating steps 4-7 and 9 until there are no errors.
267
268# 11. Now with ICU4J, build and test without new data first, to verify that
269# there are no pre-existing errors (or at least to have the pre-existing errors
270# as a base for comparison):
271
272cd $ICU4J_ROOT
273ant check 2>&1 | tee /tmp/icu4j-oldData-antCheck.txt
274
275# 12. Transfer the data to ICU4J:
276cd $ICU4C_DIR/source
277
278# 12a. You need to reconfigure ICU4C to include the unicore data.
279ICU_DATA_BUILDTOOL_OPTS=--include_uni_core_data ./runConfigureICU <platform>
280
281# 12b. Now build the jar files.
282cd $ICU4C_DIR/source/data
283# The following 2 lines are required to include the unicore data:
284make clean
285make -j6
286make icu4j-data-install
287cd $ICU4C_DIR/source/test/testdata
288make icu4j-data-install
289
290# 13. Now rebuild ICU4J with the new data and run tests:
291# Keep a log so you can investigate the errors.
292
293cd $ICU4J_ROOT
294ant check 2>&1 | tee /tmp/icu4j-newData-antCheck.txt
295
296# 14. Investigate test case failures; fix test cases and repeat from step 12,
297# or fix CLDR data and repeat from step 4, as appropriate, until there are no
298# more failures in ICU4C or ICU4J (except failures that were present before you
299# began testing the new CLDR data).
300
301# Note that certain data changes and related test failures may require the
302# rebuilding of other kinds of data. For example:
303# a) Changes to locale matching data may cause failures in e.g. the following:
304#      com.ibm.icu.dev.test.util.LocaleDistanceTest (testLoadedDataSameAsBuiltFromScratch)
305#      com.ibm.icu.dev.test.util.LocaleMatcherTest (testLikelySubtagsLoadedDataSameAsBuiltFromScratch)
306#    To address these requires building and running the tool
307#      icu4j/tools/misc/src/com/ibm/icu/dev/tool/locale/LocaleDistanceBuilder.java
308#    to regenerate the file icu4c/source/data/misc/langInfo.txt and then regenerating
309#    the ICU4J data jars.
310# b) Changes to plurals data may cause failures in e.g. the following
311#      com.ibm.icu.dev.test.format.PluralRulesTest (TestLocales)
312#    To address these requires updating the LOCALE_SNAPSHOT data in
313#      icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java
314#    by modifying the TestLocales() test there to run generateLOCALE_SNAPSHOT() and then
315#    copying in the updated data.
316
317# 15. Check the file changes; then git add or git rm as necessary, and
318# commit the changes.
319
320cd $HOME/icu/
321cd ..
322git status
323# git add or remove as necessary
324# commit
325
326# 16. For an official CLDR data integration into ICU, now tag the CLDR and
327# ICU sources with an appropriate CLDR milestone (you can check previous
328# tags for format), e.g.:
329
330cd $CLDR_DIR
331git tag ...
332git push --tags
333
334cd $HOME/icu
335git tag ...
336git push --tags
337
338# 17. You should also commit and tag the update production data in CLDR_TMP_DIR
339# using the same tag as for CLDR_DIR above:
340
341cd $CLDR_TMP_DIR
342# git add or remove as necessary
343# commit
344git tag ...
345git push --tags
346
347
348
349