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# 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) 12# 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]. 18# 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. 22# 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). 27# 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. 31# 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 34# somewhere else. 35# 36#---- 37# 38# There are several environment variables that need to be defined. 39# 40# a) Java- and ant-related variables 41# 42# JAVA_HOME: Path to JDK (a directory, containing e.g. bin/java, bin/javac, 43# etc.); on many systems this can be set using 44# `/usr/libexec/java_home`. 45# 46# ANT_OPTS: You may want to set: 47# 48# -Xmx4096m, to give Java more memory; otherwise it may run out 49# of heap. 50# 51# b) CLDR-related variables 52# 53# CLDR_DIR: Path to root of CLDR sources, below which are the common and 54# tools directories. 55# CLDR_CLASSES: Path to the CLDR Tools classes directory. If not set, defaults 56# to $CLDR_DIR/tools/java/classes 57# 58# CLDR_TMP_DIR: Parent of temporary CLDR production data. 59# Defaults to $CLDR_DIR/../cldr-aux (sibling to CLDR_DIR). 60# 61# *** NOTE ***: In CLDR release-36-beta, the GenerateProductionData 62# tool no longer generates data into $CLDR_TMP_DIR/production; instead 63# it generates data into $CLDR_DIR/../cldr-staging/production. However 64# the rest of the build still assumes that the generated data is in 65# $CLDR_TMP_DIR/production. So CLDR_TMP_DIR must be defined to be 66# $CLDR_DIR/../cldr-staging 67# 68# c) ICU-related variables 69# These variables only need to be set if you're directly reusing the 70# commands below. 71# 72# ICU4C_DIR: Path to root of ICU4C sources, below which is the source dir. 73# 74# ICU4J_ROOT: Path to root of ICU4J sources, below which is the main dir. 75# 76#---- 77# 78# If you are adding or removing locales, or specific kinds of locale data, 79# there are some xml files in the ICU sources that need to be updated (these xml 80# files are used in addition to the CLDR files as inputs to the CLDR data build 81# process for ICU): 82# 83# icu4c/source/data/icu-config.xml - Update <locales> to add or remove 84# CLDR locales for inclusion in ICU. Update <paths> to prefer 85# alt forms for certain paths, or to exclude certain paths; note 86# that <paths> items can only have draft or alt attributes. 87# 88# Note that if a language-only locale (e.g. "de") is included in 89# <locales>, then all region sublocales for that language that 90# are present in CLDR data (e.g. "de_AT", "de_BE", "de_CH", etc.) 91# should also be included in <locales>, per PMC policy decision 92# 2012-05-02 (see http://bugs.icu-project.org/trac/ticket/9298). 93# 94# icu4c/source/data/build.xml - If you are adding or removing break 95# iterators, you need to update <fileset id="brkitr" ...> under 96# <target name="clean" ...> to clean the correct set of files. 97# 98# If there are new CLDR resource bundle types, you may need to 99# updated the <remapper> sections to put these in the correct 100# data subfolder for ICU. 101# 102# icu4c/source/data/xml/ - If you are adding a new locale, break 103# iterator, collation tailoring, or rule-based number formatter, 104# you may need to add a corresponding xml file in (respectively) 105# the main/, brkitr/, collation/, or rbnf/ subdirectory here. 106# 107#---- 108# 109# For an official CLDR data integration into ICU, there are some additional 110# considerations: 111# 112# a) Don't commit anything in ICU sources (and possibly any changes in CLDR 113# sources, depending on their nature) until you have finished testing and 114# resolving build issues and test failures for both ICU4C and ICU4J. 115# 116# b) There are version numbers that may need manual updating in CLDR (other 117# version numbers get updated automatically, based on these): 118# 119# common/dtd/ldml.dtd - update cldrVersion 120# common/dtd/ldmlBCP47.dtd - update cldrVersion 121# common/dtd/ldmlSupplemental.dtd - update cldrVersion 122# common/dtd/ldmlSupplemental.dtd - updateunicodeVersion 123# keyboards/dtd/ldmlKeyboard.dtd - update cldrVersion 124# tools/java/org/unicode/cldr/util/CLDRFile.java - update GEN_VERSION 125# 126# c) After everything is committed, you will need to tag the CLDR, ICU4J, and 127# ICU4C sources that ended up being used for the integration; see step 17 128# below. 129# 130################################################################################ 131 132# 1a. Java and ant variables, adjust for your system 133 134export JAVA_HOME=`/usr/libexec/java_home` 135export ANT_OPTS="-Xmx4096m 136 137# 1b. CLDR variables, adjust for your setup; with cygwin it might be e.g. 138# CLDR_DIR=`cygpath -wp /build/cldr` 139 140export CLDR_DIR=$HOME/cldr-myfork 141 142# 1c. ICU variables 143 144export ICU4C_DIR=$HOME/icu-myfork/icu4c 145export ICU4J_ROOT=$HOME/icu-myfork/icu4j 146 147# 2. Build the CLDR Java tools and jar 148 149cd $CLDR_DIR/tools/java 150ant all 151ant jar 152 153# 3. Configure ICU4C, build and test without new data first, to verify that 154# there are no pre-existing errors. Here <platform> is the runConfigureICU 155# code for the platform you are building, e.g. Linux, MacOSX, Cygwin. 156 157cd $ICU4C_DIR/source 158./runConfigureICU <platform> 159make all 2>&1 | tee /tmp/icu4c-oldData-makeAll.txt 160make check 2>&1 | tee /tmp/icu4c-oldData-makeCheck.txt 161 162# 4. Build the new ICU4C data files; these include .txt files and .py files. 163# These new files will replace whatever was already present in the ICU4C sources. 164# This process uses ant with ICU's data/build.xml and data/icu-config.xml to 165# operate (via CLDR's ant/CLDRConverterTool.java and ant/CLDRBuild.java) the 166# necessary CLDR tools including LDML2ICUConverter, ConvertTransforms, etc. 167# This process will take several minutes. 168# Keep a log so you can investigate anything that looks suspicious. 169# 170# Running "ant setup" is not required, but it will print useful errors to 171# debug issues with your path when it fails. 172# 173 174cd $ICU4C_DIR/source/data 175ant setup 176ant clean 177ant all 2>&1 | tee /tmp/cldr-newData-buildLog.txt 178 179# NOTE: if you change the CLDR data, please run "ant cleanprod" to clean out the 180# temporary production data directory (usually $CLDR_DIR/../cldr-aux/production ) 181 182# 5. Check which data files have modifications, which have been added or removed 183# (if there are no changes, you may not need to proceed further). Make sure the 184# list seems reasonable. 185 186git status 187 188# 6. Fix any errors, investigate any warnings. Currently for example there are 189# a few warnings of the following form in rbnf files: 190# [cldr-build] Warning: no version match with: $Revision☹$ 191# 192# Fixing may entail modifying CLDR source data or tools - for example, 193# updating the validSubLocales for collation data (file a bug if appropriate). 194# Repeat steps 4-5 until there are no build errors and no unexpected 195# warnings. 196 197# 7. Now rebuild ICU4C with the new data and run make check tests. 198# Again, keep a log so you can investigate the errors. 199cd $ICU4C_DIR/source 200 201# 7a. If any files were added or removed (likely), re-run configure: 202./runConfigureICU <platform> 203make clean 204 205# 7b. Now do the rebuild. 206make check 2>&1 | tee /tmp/icu4c-newData-makeCheck.txt 207 208# 8. Investigate each test case failure. The first run processing new CLDR data 209# from the Survey Tool can result in thousands of failures (in many cases, one 210# CLDR data fix can resolve hundreds of test failures). If the error is caused 211# by bad CLDR data, then file a CLDR bug, fix the data, and regenerate from 212# step 4. If the data is OK but the testcase needs to be updated because the 213# data has legitimately changed, then update the testcase. You will check in 214# the updated testcases along with the new ICU data at the end of this process. 215# Note that if the new data has any differences in structure, you will have to 216# update test/testdata/structLocale.txt or /tsutil/cldrtest/TestLocaleStructure 217# may fail. 218# Repeat steps 4-7 until there are no errors. 219 220# 9. Now run the make check tests in exhaustive mode: 221 222cd $ICU4C_DIR/source 223export INTLTEST_OPTS="-e" 224export CINTLTST_OPTS="-e" 225make check 2>&1 | tee /tmp/icu4c-newData-makeCheckEx.txt 226 227# 10. Again, investigate each failure, fixing CLDR data or ICU test cases as 228# appropriate, and repeating steps 4-7 and 9 until there are no errors. 229 230# 11. Now with ICU4J, build and test without new data first, to verify that 231# there are no pre-existing errors (or at least to have the pre-existing errors 232# as a base for comparison): 233 234cd $ICU4J_ROOT 235ant all 2>&1 | tee /tmp/icu4j-oldData-antAll.txt 236ant check 2>&1 | tee /tmp/icu4j-oldData-antCheck.txt 237 238# 12. Transfer the data to ICU4J: 239cd $ICU4C_DIR/source 240 241# 12a. You need to reconfigure ICU4C to include the unicore data. 242ICU_DATA_BUILDTOOL_OPTS=--include_uni_core_data ./runConfigureICU <platform> 243 244# 12b. Now build the jar files. 245cd $ICU4C_DIR/source/data 246# The following 2 lines are required to include the unicore data: 247 make clean 248 make -j6 249make icu4j-data-install 250cd $ICU4C_DIR/source/test/testdata 251make icu4j-data-install 252 253# 13. Now rebuild ICU4J with the new data and run tests: 254# Keep a log so you can investigate the errors. 255 256cd $ICU4J_ROOT 257ant check 2>&1 | tee /tmp/icu4j-newData-antCheck.txt 258 259# 14. Investigate test case failures; fix test cases and repeat from step 12, 260# or fix CLDR data and repeat from step 4, as appropriate, until there are no 261# more failures in ICU4C or ICU4J (except failures that were present before you 262# began testing the new CLDR data). 263 264# Note that certain data changes and related test failures may require the 265# rebuilding of other kinds of data. For example: 266# a) Changes to locale matching data may cause failures in e.g. the following: 267# com.ibm.icu.dev.test.util.LocaleDistanceTest (testLoadedDataSameAsBuiltFromScratch) 268# com.ibm.icu.dev.test.util.LocaleMatcherTest (testLikelySubtagsLoadedDataSameAsBuiltFromScratch) 269# To address these requires building and running the tool 270# icu4j/tools/misc/src/com/ibm/icu/dev/tool/locale/LocaleDistanceBuilder.java 271# to regenerate the file icu4c/source/data/misc/langInfo.txt and then regenerating 272# the ICU4J data jars. 273# b) Changes to plurals data may cause failures in e.g. the following 274# com.ibm.icu.dev.test.format.PluralRulesTest (TestLocales) 275# To address these requires updating the LOCALE_SNAPSHOT data in 276# icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java 277# by modifying the TestLocales() test there to run generateLOCALE_SNAPSHOT() and then 278# copying in the updated data. 279 280# 15. Check the file changes; then git add or git rm as necessary, and 281# commit the changes. 282 283cd $HOME/icu/ 284cd .. 285git status 286# add or remove as necessary 287# commit 288 289# 16. For an official CLDR data integration into ICU, now tag the CLDR and 290# ICU sources with an appropriate CLDR milestone (you can check previous 291# tags for format), e.g.: 292 293svn copy svn+ssh://unicode.org/repos/cldr/trunk \ 294svn+ssh://unicode.org/repos/cldr/tags/release-NNN \ 295--parents -m "cldrbug nnnn: tag cldr sources for NNN" 296 297cd $HOME/icu/ 298git tag ... 299 300 301