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.
6 # Commands for regenerating ICU4C locale data (.txt files) from CLDR.
8 # The process requires local copies of
9 # - CLDR (the source of most of the data, and some Java tools)
10 # - ICU4J (used only for checking the converted data)
11 # - ICU4C (the destination for the new data, and the source for some of it)
13 # For an official CLDR data integration into ICU, these should be clean, freshly
14 # checked-out. For released CLDR sources, an alternative to checking out sources
15 # for a given version is downloading the zipped sources for the common (core.zip)
16 # and tools (tools.zip) directory subtrees from the Data column in
17 # [http://cldr.unicode.org/index/downloads].
19 # The versions of each of these must match. Included with the release notes for
20 # ICU is the version number and/or a CLDR svn tag name for the revision of CLDR
21 # that was the source of the data for that release of ICU.
23 # Besides a standard JDK, the process also requires ant
24 # (http://ant.apache.org/),
25 # plus the xml-apis.jar from the Apache xalan package
26 # (http://xml.apache.org/xalan-j/downloads.html).
28 # Note: Enough things can (and will) fail in this process that it is best to
29 # run the commands separately from an interactive shell. They should all
30 # copy and paste without problems.
32 # It is often useful to save logs of the output of many of the steps in this
33 # process. The commands below put log files in /tmp; you may want to put them
40 # Parts of the build process (notably building the new ICU data files in step 4)
41 # require http: access to files in the CLDR repository; for example, processing
42 # the files in icu4c/source/data/xml/ may require access to
43 # http://www.unicode.org/repos/cldr/trunk/common/dtd/ldml.dtd
45 # Unless you cache the dtds locally by
46 # 1. creating a temp directory e.g. ~/.cldrdtd
47 # 2. setting CLDR_DTD_CACHE to it e.g. -DCLDR_DTD_CACHE=~/.cldrdtd
48 # your system will make excessive network requests, which will result in the
49 # Unicode server blocking access.
53 # There are several environment variables that need to be defined.
55 # a) Java- and ant-related variables
57 # JAVA_HOME: Path to JDK (a directory, containing e.g. bin/java, bin/javac,
58 # etc.); on many systems this can be set using
59 # `/usr/libexec/java_home`.
61 # ANT_OPTS: You may want to set:
63 # -Xmx4096m, to give Java more memory; otherwise it may run out
65 # -DCLDR_DTD_CACHE=~/.cldrdtd (or some other temp directory
66 # that already exists), to reduce frequent http: access to dtds
67 # and consequent blockage by Unicode server.
69 # b) CLDR-related variables
71 # CLDR_DIR: Path to root of CLDR sources, below which are the common and
73 # CLDR_CLASSES: Path to the CLDR Tools classes directory. If not set, defaults
74 # to $CLDR_DIR/tools/java/classes
76 # c) ICU-related variables
77 # These variables only need to be set if you're directly reusing the
80 # ICU4C_DIR: Path to root of ICU4C sources, below which is the source dir.
82 # ICU4J_ROOT: Path to root of ICU4J sources, below which is the main dir.
86 # If you are adding or removing locales, or specific kinds of locale data,
87 # there are some xml files in the ICU sources that need to be updated (these xml
88 # files are used in addition to the CLDR files as inputs to the CLDR data build
91 # icu4c/source/data/icu-config.xml - Update <locales> to add or remove
92 # CLDR locales for inclusion in ICU. Update <paths> to prefer
93 # alt forms for certain paths, or to exclude certain paths; note
94 # that <paths> items can only have draft or alt attributes.
96 # Note that if a language-only locale (e.g. "de") is included in
97 # <locales>, then all region sublocales for that language that
98 # are present in CLDR data (e.g. "de_AT", "de_BE", "de_CH", etc.)
99 # should also be included in <locales>, per PMC policy decision
100 # 2012-05-02 (see http://bugs.icu-project.org/trac/ticket/9298).
102 # icu4c/source/data/build.xml - If you are adding or removing break
103 # iterators, you need to update <fileset id="brkitr" ...> under
104 # <target name="clean" ...> to clean the correct set of files.
106 # If there are new CLDR resource bundle types, you may need to
107 # updated the <remapper> sections to put these in the correct
108 # data subfolder for ICU.
110 # icu4c/source/data/xml/ - If you are adding a new locale, break
111 # iterator, collation tailoring, or rule-based number formatter,
112 # you may need to add a corresponding xml file in (respectively)
113 # the main/, brkitr/, collation/, or rbnf/ subdirectory here.
117 # For an official CLDR data integration into ICU, there are some additional
120 # a) Don't commit anything in ICU sources (and possibly any changes in CLDR
121 # sources, depending on their nature) until you have finished testing and
122 # resolving build issues and test failures for both ICU4C and ICU4J.
124 # b) There are version numbers that may need manual updating in CLDR (other
125 # version numbers get updated automatically, based on these):
127 # common/dtd/ldml.dtd - update cldrVersion
128 # common/dtd/ldmlBCP47.dtd - update cldrVersion
129 # common/dtd/ldmlSupplemental.dtd - update cldrVersion
130 # common/dtd/ldmlSupplemental.dtd - updateunicodeVersion
131 # keyboards/dtd/ldmlKeyboard.dtd - update cldrVersion
132 # tools/java/org/unicode/cldr/util/CLDRFile.java - update GEN_VERSION
134 # c) After everything is committed, you will need to tag the CLDR, ICU4J, and
135 # ICU4C sources that ended up being used for the integration; see step 17
138 ################################################################################
140 # 1a. Java and ant variables, adjust for your system
142 export JAVA_HOME=`/usr/libexec/java_home`
143 export ANT_OPTS="-Xmx4096m -DCLDR_DTD_CACHE=~/.cldrdtd"
145 # 1b. CLDR variables, adjust for your setup; with cygwin it might be e.g.
146 # CLDR_DIR=`cygpath -wp /build/cldr`
148 export CLDR_DIR=$HOME/cldr/trunk
152 export ICU4C_DIR=$HOME/icu/icu4c
153 export ICU4J_ROOT=$HOME/icu/icu4j
155 # 1d. Pre-populate your CLDR DTD cache. You need to do this only once.
159 curl http://www.unicode.org/repos/cldr/trunk/common/dtd/ldml.dtd \
160 -o http___www.unicode.org_repos_cldr_trunk_common_dtd_ldml.dtd
161 # WAIT before hitting the server again; it WILL NOT give you a second chance!
163 curl http://www.unicode.org/repos/cldr/trunk/common/dtd/ldmlICU.dtd \
164 -o http___www.unicode.org_repos_cldr_trunk_common_dtd_ldmlICU.dtd
166 curl http://www.unicode.org/repos/cldr/trunk/common/dtd/ldmlSupplemental.dtd \
167 -o http___www.unicode.org_repos_cldr_trunk_common_dtd_ldmlSupplemental.dtd
169 # 2. Build the CLDR Java tools
170 # Optionally build the jar, but ant will look inside the classes directory anyway
172 cd $CLDR_DIR/tools/java
176 # 3. Configure ICU4C, build and test without new data first, to verify that
177 # there are no pre-existing errors. Here <platform> is the runConfigureICU
178 # code for the platform you are building, e.g. Linux, MacOSX, Cygwin.
181 ./runConfigureICU <platform>
182 make all 2>&1 | tee /tmp/icu4c-oldData-makeAll.txt
183 make check 2>&1 | tee /tmp/icu4c-oldData-makeCheck.txt
185 # 4. Build the new ICU4C data files; these include .txt files and .mk files.
186 # These new files will replace whatever was already present in the ICU4C sources.
187 # This process uses ant with ICU's data/build.xml and data/icu-config.xml to
188 # operate (via CLDR's ant/CLDRConverterTool.java and ant/CLDRBuild.java) the
189 # necessary CLDR tools including LDML2ICUConverter, ConvertTransforms, etc.
190 # This process will take several minutes.
191 # Keep a log so you can investigate anything that looks suspicious.
193 # Running "ant setup" is not required, but it will print useful errors to
194 # debug issues with your path when it fails.
196 # If you see timeout errors when building the rbnf data, for example, then you are
197 # likely not using a CLDR dtd cache; see "CLDR dtd caching" above. If you are using
198 # a dtd cache and are still having timeout problems, the IP address of your system
199 # may have been blocked due to previous excessive access. In this case you may need
200 # to contact a Unicode sysadmin to restore access.
202 # Unfortunately, even if you have your DTD cache variable enabled, you may still
203 # get blocked and unable to populate your cache because of multiple successive
204 # requests to download the required DTD files. It is recommended that you
205 # pre-populate your cache as shown above in step 1d.
207 cd $ICU4C_DIR/source/data
210 ant all 2>&1 | tee /tmp/cldr-newData-buildLog.txt
212 # 5. Check which data files have modifications, which have been added or removed
213 # (if there are no changes, you may not need to proceed further). Make sure the
214 # list seems reasonable.
218 # 6. Fix any errors, investigate any warnings. Currently for example there are
219 # a few warnings of the following form in rbnf files:
220 # [cldr-build] Warning: no version match with: $Revisionā¹$
222 # Fixing may entail modifying CLDR source data or tools - for example,
223 # updating the validSubLocales for collation data (file a bug if appropriate).
224 # Repeat steps 4-5 until there are no build errors and no unexpected
227 # 7. Now rebuild ICU4C with the new data and run make check tests.
228 # Again, keep a log so you can investigate the errors.
231 # 7a. If any files were added or removed (likely), re-run configure:
232 ./runConfigureICU <platform>
235 # 7b. Now do the rebuild.
236 make check 2>&1 | tee /tmp/icu4c-newData-makeCheck.txt
238 # 8. Investigate each test case failure. The first run processing new CLDR data
239 # from the Survey Tool can result in thousands of failures (in many cases, one
240 # CLDR data fix can resolve hundreds of test failures). If the error is caused
241 # by bad CLDR data, then file a CLDR bug, fix the data, and regenerate from
242 # step 4. If the data is OK but the testcase needs to be updated because the
243 # data has legitimately changed, then update the testcase. You will check in
244 # the updated testcases along with the new ICU data at the end of this process.
245 # Note that if the new data has any differences in structure, you will have to
246 # update test/testdata/structLocale.txt or /tsutil/cldrtest/TestLocaleStructure
248 # Repeat steps 4-7 until there are no errors.
250 # 9. Now run the make check tests in exhaustive mode:
253 export INTLTEST_OPTS="-e"
254 export CINTLTST_OPTS="-e"
255 make check 2>&1 | tee /tmp/icu4c-newData-makeCheckEx.txt
257 # 10. Again, investigate each failure, fixing CLDR data or ICU test cases as
258 # appropriate, and repeating steps 4-7 and 9 until there are no errors.
260 # 11. Now with ICU4J, build and test without new data first, to verify that
261 # there are no pre-existing errors (or at least to have the pre-existing errors
262 # as a base for comparison):
265 ant all 2>&1 | tee /tmp/icu4j-oldData-antAll.txt
266 ant check 2>&1 | tee /tmp/icu4j-oldData-antCheck.txt
268 # 12. Transfer the data to ICU4J:
271 # 12a. You need to reconfigure ICU4C to include the unicore data.
272 ICU_DATA_BUILDTOOL_OPTS=--include_uni_core_data ./runConfigureICU <platform>
274 # 12b. Now build the jar files.
275 cd $ICU4C_DIR/source/data
276 # The following 2 lines are required to include the unicore data:
279 make icu4j-data-install
280 cd $ICU4C_DIR/source/test/testdata
281 make icu4j-data-install
283 # 13. Now rebuild ICU4J with the new data and run tests:
284 # Keep a log so you can investigate the errors.
287 ant check 2>&1 | tee /tmp/icu4j-newData-antCheck.txt
289 # 14. Investigate test case failures; fix test cases and repeat from step 12,
290 # or fix CLDR data and repeat from step 4, as appropriate, until there are no
291 # more failures in ICU4C or ICU4J (except failures that were present before you
292 # began testing the new CLDR data).
294 # 15. Check the file changes; then git add or git rm as necessary, and
295 # commit the changes.
300 # add or remove as necessary
303 # 16. For an official CLDR data integration into ICU, now tag the CLDR and
304 # ICU sources with an appropriate CLDR milestone (you can check previous
305 # tags for format), e.g.:
307 svn copy svn+ssh://unicode.org/repos/cldr/trunk \
308 svn+ssh://unicode.org/repos/cldr/tags/release-NNN \
309 --parents -m "cldrbug nnnn: tag cldr sources for NNN"