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# 5. Check which data files have modifications, which have been added or removed 205# (if there are no changes, you may not need to proceed further). Make sure the 206# list seems reasonable. 207 208cd $ICU4C_DIR/source/data 209git status 210 211# 5a. You may also want to check which files were modified in CLDR production data: 212 213cd $CLDR_TMP_DIR 214git status 215 216# 6. Fix any errors, investigate any warnings. 217# 218# Fixing may entail modifying CLDR source data or TOOLS_ROOT config files or 219# tooling. 220 221# 7. Now rebuild ICU4C with the new data and run make check tests. 222# Again, keep a log so you can investigate the errors. 223cd $ICU4C_DIR/source 224 225# 7a. If any files were added or removed (likely), re-run configure: 226./runConfigureICU <platform> 227make clean 228 229# 7b. Now do the rebuild. 230make check 2>&1 | tee /tmp/icu4c-newData-makeCheck.txt 231 232# 8. Investigate each test case failure. The first run processing new CLDR data 233# from the Survey Tool can result in thousands of failures (in many cases, one 234# CLDR data fix can resolve hundreds of test failures). If the error is caused 235# by bad CLDR data, then file a CLDR bug, fix the data, and regenerate from 236# step 4. If the data is OK but the testcase needs to be updated because the 237# data has legitimately changed, then update the testcase. You will check in 238# the updated testcases along with the new ICU data at the end of this process. 239# Note that if the new data has any differences in structure, you will have to 240# update test/testdata/structLocale.txt or /tsutil/cldrtest/TestLocaleStructure 241# may fail. 242# Repeat steps 4-7 until there are no errors. 243 244# 9. You can also run the make check tests in exhaustive mode. As an alternative 245# you can run them as part of the pre-merge tests by adding the following as a 246# comment in the pull request: "/azp run CI-Exhaustive". You should do one or the 247# other; the exhaustive tests are *not* run automatically on each pull request, 248# and are only run occasionally on the default branch. 249 250cd $ICU4C_DIR/source 251export INTLTEST_OPTS="-e" 252export CINTLTST_OPTS="-e" 253make check 2>&1 | tee /tmp/icu4c-newData-makeCheckEx.txt 254 255# 10. Again, investigate each failure, fixing CLDR data or ICU test cases as 256# appropriate, and repeating steps 4-7 and 9 until there are no errors. 257 258# 11. Now with ICU4J, build and test without new data first, to verify that 259# there are no pre-existing errors (or at least to have the pre-existing errors 260# as a base for comparison): 261 262cd $ICU4J_ROOT 263ant check 2>&1 | tee /tmp/icu4j-oldData-antCheck.txt 264 265# 12. Transfer the data to ICU4J: 266cd $ICU4C_DIR/source 267 268# 12a. You need to reconfigure ICU4C to include the unicore data. 269ICU_DATA_BUILDTOOL_OPTS=--include_uni_core_data ./runConfigureICU <platform> 270 271# 12b. Now build the jar files. 272cd $ICU4C_DIR/source/data 273# The following 2 lines are required to include the unicore data: 274make clean 275make -j6 276make icu4j-data-install 277cd $ICU4C_DIR/source/test/testdata 278make icu4j-data-install 279 280# 13. Now rebuild ICU4J with the new data and run tests: 281# Keep a log so you can investigate the errors. 282 283cd $ICU4J_ROOT 284ant check 2>&1 | tee /tmp/icu4j-newData-antCheck.txt 285 286# 14. Investigate test case failures; fix test cases and repeat from step 12, 287# or fix CLDR data and repeat from step 4, as appropriate, until there are no 288# more failures in ICU4C or ICU4J (except failures that were present before you 289# began testing the new CLDR data). 290 291# Note that certain data changes and related test failures may require the 292# rebuilding of other kinds of data. For example: 293# a) Changes to locale matching data may cause failures in e.g. the following: 294# com.ibm.icu.dev.test.util.LocaleDistanceTest (testLoadedDataSameAsBuiltFromScratch) 295# com.ibm.icu.dev.test.util.LocaleMatcherTest (testLikelySubtagsLoadedDataSameAsBuiltFromScratch) 296# To address these requires building and running the tool 297# icu4j/tools/misc/src/com/ibm/icu/dev/tool/locale/LocaleDistanceBuilder.java 298# to regenerate the file icu4c/source/data/misc/langInfo.txt and then regenerating 299# the ICU4J data jars. 300# b) Changes to plurals data may cause failures in e.g. the following 301# com.ibm.icu.dev.test.format.PluralRulesTest (TestLocales) 302# To address these requires updating the LOCALE_SNAPSHOT data in 303# icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java 304# by modifying the TestLocales() test there to run generateLOCALE_SNAPSHOT() and then 305# copying in the updated data. 306 307# 15. Check the file changes; then git add or git rm as necessary, and 308# commit the changes. 309 310cd $HOME/icu/ 311cd .. 312git status 313# git add or remove as necessary 314# commit 315 316# 16. For an official CLDR data integration into ICU, now tag the CLDR and 317# ICU sources with an appropriate CLDR milestone (you can check previous 318# tags for format), e.g.: 319 320cd $CLDR_DIR 321git tag ... 322git push --tags 323 324cd $HOME/icu 325git tag ... 326git push --tags 327 328# 17. You should also commit and tag the update production data in CLDR_TMP_DIR 329# using the same tag as for CLDR_DIR above: 330 331cd $CLDR_TMP_DIR 332# git add or remove as necessary 333# commit 334git tag ... 335git push --tags 336 337 338 339