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