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