• 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# 1d. Directory for logs/notes (create if does not exist)
142
143export NOTES=...(some directory)...
144mkdir -p $NOTES
145
146# 2a. Configure ICU4C, build and test without new data first, to verify that
147# there are no pre-existing errors. Here <platform> is the runConfigureICU
148# code for the platform you are building, e.g. Linux, MacOSX, Cygwin.
149# (optionally build with debug enabled)
150
151cd $ICU4C_DIR/source
152./runConfigureICU [--enable-debug] <platform>
153make clean
154make check 2>&1 | tee $NOTES/icu4c-oldData-makeCheck.txt
155
156# 2b. Now with ICU4J, build and test without new data first, to verify that
157# there are no pre-existing errors (or at least to have the pre-existing errors
158# as a base for comparison):
159
160cd $ICU4J_ROOT
161ant clean
162ant check 2>&1 | tee $NOTES/icu4j-oldData-antCheck.txt
163
164# 3. Make pre-adjustments as necessary
165# 3a. Copy latest relevant CLDR dtds to ICU
166cp -p $CLDR_DIR/common/dtd/ldml.dtd $ICU4C_DIR/source/data/dtd/cldr/common/dtd/
167cp -p $CLDR_DIR/common/dtd/ldmlICU.dtd $ICU4C_DIR/source/data/dtd/cldr/common/dtd/
168
169# 3b. Update the cldr-icu tooling to use the latest tagged version of ICU
170open $TOOLS_ROOT/cldr/cldr-to-icu/pom.xml
171# search for icu4j-for-cldr and update to the latest tagged version per instructions
172
173# 3c. Update the build for any new icu version, added locales, etc.
174open $TOOLS_ROOT/cldr/cldr-to-icu/build-icu-data.xml
175# update icuVersion, icuDataVersion if necessary
176# update lists of locales to include if necessary
177
178# 4. Build and install the CLDR jar
179
180cd $TOOLS_ROOT/cldr
181ant install-cldr-libs
182
183See the $TOOLS_ROOT/cldr/lib/README.txt file for more information on the CLDR
184jar and the install-cldr-jars.sh script.
185
186# 5a. Generate the CLDR production data. This process uses ant with ICU's
187# data/build.xml
188#
189# Running "ant cleanprod" is necessary to clean out the production data directory
190# (usually $CLDR_TMP_DIR/production ), required if any CLDR data has changed.
191#
192# Running "ant setup" is not required, but it will print useful errors to
193# debug issues with your path when it fails.
194
195cd $ICU4C_DIR/source/data
196ant cleanprod
197ant setup
198ant proddata 2>&1 | tee $NOTES/cldr-newData-proddataLog.txt
199
200# 5b. Build the new ICU4C data files; these include .txt files and .py files.
201# These new files will replace whatever was already present in the ICU4C sources.
202# This process uses the LdmlConverter in $TOOLS_ROOT/cldr/cldr-to-icu/;
203# see $TOOLS_ROOT/cldr/cldr-to-icu/README.txt
204#
205# This process will take several minutes, during most of which there will be no log
206# output (so do not assume nothing is happening). Keep a log so you can investigate
207# anything that looks suspicious.
208#
209# Note that "ant clean" should not be run before this. The build-icu-data.xml process
210# will automatically run its own "clean" step to delete files it cannot determine to
211# be ones that it would generate, except for pasts listed in <retain> elements such as
212# coll/de__PHONEBOOK.txt, coll/de_.txt, etc.
213#
214# Before running Ant to regenerate the data, make any necessary changes to the
215# build-icu-data.xml file, such as adding new locales etc.
216
217cd $TOOLS_ROOT/cldr/cldr-to-icu
218ant -f build-icu-data.xml -DcldrDataDir="$CLDR_TMP_DIR/production" | tee $NOTES/cldr-newData-builddataLog.txt
219
220# 5c. Update the CLDR testData files needed by ICU4C and ICU4J tests, ensuring
221# they're representative of the newest CLDR data.
222
223cd $TOOLS_ROOT/cldr
224ant copy-cldr-testdata
225
226# 5d. Copy from CLDR common/testData/localeIdentifiers/localeCanonicalization.txt
227# into icu4c/source/test/testdata/localeCanonicalization.txt
228# and icu4j/main/tests/core/src/com/ibm/icu/dev/data/unicode/localeCanonicalization.txt
229# and add the following line to the beginning of these two files
230# # File copied from cldr common/testData/localeIdentifiers/localeCanonicalization.txt
231
232# 5e. For the time being, manually re-add the lstm entries in data/brkitr/root.txt
233open $ICU4C_DIR/source/data/brkitr/root.txt
234
235# paste the following block after the dictionaries block and before the final closing '}':
236    lstm{
237        Thai{"Thai_graphclust_model4_heavy.res"}
238        Mymr{"Burmese_graphclust_model5_heavy.res"}
239    }
240
241# 6. Check which data files have modifications, which have been added or removed
242# (if there are no changes, you may not need to proceed further). Make sure the
243# list seems reasonable.
244
245cd $ICU4C_DIR/..
246git status
247
248# 6a. You may also want to check which files were modified in CLDR production data:
249
250cd $CLDR_TMP_DIR
251git status
252
253# 7. Fix any errors, investigate any warnings.
254#
255# Fixing may entail modifying CLDR source data or TOOLS_ROOT config files or
256# tooling.
257
258# 8. Now rebuild ICU4C with the new data and run make check tests.
259# Again, keep a log so you can investigate the errors.
260cd $ICU4C_DIR/source
261
262# 8a. If any files were added or removed (likely), re-run configure:
263./runConfigureICU [--enable-debug] <platform>
264make clean
265
266# 8b. Now do the rebuild.
267make check 2>&1 | tee $NOTES/icu4c-newData-makeCheck.txt
268
269# 9. Investigate each test case failure. The first run processing new CLDR data
270# from the Survey Tool can result in thousands of failures (in many cases, one
271# CLDR data fix can resolve hundreds of test failures). If the error is caused
272# by bad CLDR data, then file a CLDR bug, fix the data, and regenerate from
273# step 4. If the data is OK but the testcase needs to be updated because the
274# data has legitimately changed, then update the testcase. You will check in
275# the updated testcases along with the new ICU data at the end of this process.
276# Note that if the new data has any differences in structure, you will have to
277# update test/testdata/structLocale.txt or /tsutil/cldrtest/TestLocaleStructure
278# may fail.
279# Repeat steps 4-8 until there are no errors.
280
281# 10. You can also run the make check tests in exhaustive mode. As an alternative
282# you can run them as part of the pre-merge tests by adding the following as a
283# comment in the pull request: "/azp run CI-Exhaustive". You should do one or the
284# other; the exhaustive tests are *not* run automatically on each pull request,
285# and are only run occasionally on the default branch.
286
287cd $ICU4C_DIR/source
288export INTLTEST_OPTS="-e"
289export CINTLTST_OPTS="-e"
290make check 2>&1 | tee $NOTES/icu4c-newData-makeCheckEx.txt
291
292# 11. Again, investigate each failure, fixing CLDR data or ICU test cases as
293# appropriate, and repeating steps 4-8 and 10 until there are no errors.
294
295# 12. Transfer the data to ICU4J:
296cd $ICU4C_DIR/source
297
298# 12a. You need to reconfigure ICU4C to include the unicore data.
299ICU_DATA_BUILDTOOL_OPTS=--include_uni_core_data ./runConfigureICU <platform>
300
301# 12b. Now build the jar files.
302cd $ICU4C_DIR/source/data
303# The following 2 lines are required to include the unicore data:
304make clean
305make -j6
306make icu4j-data-install
307cd $ICU4C_DIR/source/test/testdata
308make icu4j-data-install
309
310# 13. Now rebuild ICU4J with the new data and run tests:
311# Keep a log so you can investigate the errors.
312
313cd $ICU4J_ROOT
314ant check 2>&1 | tee $NOTES/icu4j-newData-antCheck.txt
315
316# 14. Investigate test case failures; fix test cases and repeat from step 12,
317# or fix CLDR data and repeat from step 4, as appropriate, until there are no
318# more failures in ICU4C or ICU4J (except failures that were present before you
319# began testing the new CLDR data).
320
321# Note that certain data changes and related test failures may require the
322# rebuilding of other kinds of data. For example:
323# a) Changes to locale matching data may cause failures in e.g. the following:
324#      com.ibm.icu.dev.test.util.LocaleDistanceTest (testLoadedDataSameAsBuiltFromScratch)
325#      com.ibm.icu.dev.test.util.LocaleMatcherTest (testLikelySubtagsLoadedDataSameAsBuiltFromScratch)
326#    To address these requires building and running the tool
327#      icu4j/tools/misc/src/com/ibm/icu/dev/tool/locale/LocaleDistanceBuilder.java
328#    to regenerate the file icu4c/source/data/misc/langInfo.txt and then regenerating
329#    the ICU4J data jars.
330# b) Changes to plurals data may cause failures in e.g. the following
331#      com.ibm.icu.dev.test.format.PluralRulesTest (TestLocales)
332#    To address these requires updating the LOCALE_SNAPSHOT data in
333#      icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java
334#    by modifying the TestLocales() test there to run generateLOCALE_SNAPSHOT() and then
335#    copying in the updated data.
336
337# 15. Check the file changes; then git add or git rm as necessary, and
338# commit the changes.
339
340cd $HOME/icu/
341cd ..
342git status
343# git add or remove as necessary
344# commit
345
346# 16. For an official CLDR data integration into ICU, now tag the CLDR and
347# ICU sources with an appropriate CLDR milestone (you can check previous
348# tags for format), e.g.:
349
350cd $CLDR_DIR
351git tag ...
352git push --tags
353
354cd $HOME/icu
355git tag ...
356git push --tags
357
358# 17. You should also commit and tag the update production data in CLDR_TMP_DIR
359# using the same tag as for CLDR_DIR above:
360
361cd $CLDR_TMP_DIR
362# git add or remove as necessary
363# commit
364git tag ...
365git push --tags
366
367
368
369