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# Note: Some versions of the OpenJDK will not build the CLDR java utilities. 24# If you see compilation errors complaining about type incompatibilities with 25# functions on generic classes, try switching to the Sun JDK. 26# 27# Besides a standard JDK, the process also requires ant 28# (http://ant.apache.org/), 29# plus the xml-apis.jar from the Apache xalan package 30# (http://xml.apache.org/xalan-j/downloads.html). 31# 32# Note: Enough things can (and will) fail in this process that it is best to 33# run the commands separately from an interactive shell. They should all 34# copy and paste without problems. 35# 36# It is often useful to save logs of the output of many of the steps in this 37# process. The commands below put log files in /tmp; you may want to put them 38# somewhere else. 39# 40#---- 41# 42# IP address whitelisting 43# 44# Parts of the build process (notably building the new ICU data files in step 4) 45# require http: access to files in the CLDR repository; for example, processing 46# the files in icu4c/source/data/xml/ may require access to 47# http://www.unicode.org/repos/cldr/trunk/common/dtd/ldml.dtd 48# 49# Unless you cache the dtds locally by e.g. setting -DCLDR_DTD_CACHE=/tmp, the 50# builds will repeatedly make such requests, which will likely result in the 51# Unicode server blocking access and consequent timeout failures. You can 52# prevent such blockage by having the external IP address of your build system 53# whitelisted with Unicode; contact Rick McGowan or Steven Loomis. 54# 55#---- 56# 57# There are several environment variables that need to be defined. 58# 59# a) Java- and ant-related variables 60# 61# JAVA_HOME: Path to JDK (a directory, containing e.g. bin/java, bin/javac, 62# etc.); on many systems this can be set using 63# `/usr/libexec/java_home`. 64# 65# ANT_OPTS: You may want to set: 66# 67# -Xmx3072m, to give Java more memory; otherwise it may run out 68# of heap. 69# -DCLDR_DTD_CACHE=/tmp, to reduce frequent http: access to dtds 70# and consequent blockage by Unicode server. 71# 72# b) CLDR-related variables 73# 74# CLDR_DIR: Path to root of CLDR sources, below which are the common and 75# tools directories. 76# CLDR_CLASSES: Defined relative to CLDR_DIR. It only needs to be set if you 77# are not running ant jar for CLDR and have a non-default output 78# folder for cldr-tools classes. 79# 80# c) ICU-related variables 81# These variables only need to be set if you're directly reusing the 82# commands below. 83# 84# ICU4C_DIR: Path to root of ICU4C sources, below which is the source dir. 85# 86# ICU4J_ROOT: Path to root of ICU4J sources, below which is the main dir. 87# 88#---- 89# 90# If you are adding or removing locales, or specific kinds of locale data, 91# there are some xml files in the ICU sources that need to be updated (these xml 92# files are used in addition to the CLDR files as inputs to the CLDR data build 93# process for ICU): 94# 95# icu4c/source/data/icu-config.xml - Update <locales> to add or remove 96# CLDR locales for inclusion in ICU. Update <paths> to prefer 97# alt forms for certain paths, or to exclude certain paths; note 98# that <paths> items can only have draft or alt attributes. 99# 100# Note that if a language-only locale (e.g. "de") is included in 101# <locales>, then all region sublocales for that language that 102# are present in CLDR data (e.g. "de_AT", "de_BE", "de_CH", etc.) 103# should also be included in <locales>, per PMC policy decision 104# 2012-05-02 (see http://bugs.icu-project.org/trac/ticket/9298). 105# 106# icu4c/source/data/build.xml - If you are adding or removing break 107# iterators, you need to update <fileset id="brkitr" ...> under 108# <target name="clean" ...> to clean the correct set of files. 109# 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. 114# 115#---- 116# 117# For an official CLDR data integration into ICU, there are some additional 118# considerations: 119# 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. 123# 124# b) There are version numbers that may need manual updating in CLDR (other 125# version numbers get updated automatically, based on these): 126# 127# common/dtd/ldml.dtd - update cldrVersion 128# common/dtd/ldmlBCP47.dtd - update cldrVersion 129# common/dtd/ldmlSupplemental.dtd - update cldrVersion 130# tools/java/org/unicode/cldr/util/CLDRFile.java - update GEN_VERSION 131# 132# c) After everything is committed, you will need to tag the CLDR, ICU4J, and 133# ICU4C sources that ended up being used for the integration; see step 17 134# below. 135# 136################################################################################ 137 138# 1a. Java and ant variables, adjust for your system 139 140export JAVA_HOME=`/usr/libexec/java_home` 141export ANT_OPTS="-Xmx3072m -DCLDR_DTD_CACHE=/tmp" 142 143# 1b. CLDR variables, adjust for your setup; with cygwin it might be e.g. 144# CLDR_DIR=`cygpath -wp /build/cldr` 145 146export CLDR_DIR=$HOME/cldr/trunk 147#export CLDR_CLASSES=$CLDR_DIR/tools/java/classes 148 149# 1c. ICU variables 150 151export ICU4C_DIR=$HOME/icu/trunk/icu4c 152export ICU4J_ROOT=$HOME/icu/trunk/icu4j 153 154# 2. Build the CLDR Java tools 155 156cd $CLDR_DIR/tools/java 157ant jar 158 159# 3. Configure ICU4C, build and test without new data first, to verify that 160# there are no pre-existing errors (configure shown here for MacOSX, adjust 161# for your platform). 162 163cd $ICU4C_DIR/source 164./runConfigureICU MacOSX 165make all 2>&1 | tee /tmp/icu4c-oldData-makeAll.txt 166make check 2>&1 | tee /tmp/icu4c-oldData-makeCheck.txt 167 168# 4. Build the new ICU4C data files; these include .txt files and .mk files. 169# These new files will replace whatever was already present in the ICU4C sources. 170# This process uses ant with ICU's data/build.xml and data/icu-config.xml to 171# operate (via CLDR's ant/CLDRConverterTool.java and ant/CLDRBuild.java) the 172# necessary CLDR tools including LDML2ICUConverter, ConvertTransforms, etc. 173# This process will take several minutes. 174# Keep a log so you can investigate anything that looks suspicious. 175# 176# If you see timeout errors when building the rbnf data, for example, then the 177# system you are building on likely does not have its IP address whitelisted with 178# Unicode for access to the CLDR repository, see note on "IP address whitelisting" 179# near the top of this file. 180 181cd $ICU4C_DIR/source/data 182ant clean 183ant all 2>&1 | tee /tmp/cldr-newData-buildLog.txt 184 185# 5. Check which data files have modifications, which have been added or removed 186# (if there are no changes, you may not need to proceed further). Make sure the 187# list seems reasonable. 188 189git status 190 191# 6. Fix any errors, investigate any warnings. Some warnings are expected, 192# including warnings for missing versions in locale names which specify some 193# collationvariants, e.g. 194# [cldr-build] WARNING (ja_JP_TRADITIONAL): No version #?? 195# [cldr-build] WARNING (zh_TW_STROKE): No version #?? 196# and warnings for some empty collation bundles, e.g. 197# [cldr-build] WARNING (en): warning: No collations found. Bundle will ... 198# [cldr-build] WARNING (to): warning: No collations found. Bundle will ... 199# 200# Fixing may entail modifying CLDR source data or tools - for example, 201# updating the validSubLocales for collation data (file a bug if appropriate). 202# Repeat steps 4-5 until there are no build errors and no unexpected 203# warnings. 204 205# 7. Now rebuild ICU4C with the new data and run make check tests. 206# Again, keep a log so you can investigate the errors. 207 208cd $ICU4C_DIR/source 209make check 2>&1 | tee /tmp/icu4c-newData-makeCheck.txt 210 211# 8. Investigate each test case failure. The first run processing new CLDR data 212# from the Survey Tool can result in thousands of failures (in many cases, one 213# CLDR data fix can resolve hundreds of test failures). If the error is caused 214# by bad CLDR data, then file a CLDR bug, fix the data, and regenerate from 215# step 4. If the data is OK but the testcase needs to be updated because the 216# data has legitimately changed, then update the testcase. You will check in 217# the updated testcases along with the new ICU data at the end of this process. 218# Note that if the new data has any differences in structure, you will have to 219# update test/testdata/structLocale.txt or /tsutil/cldrtest/TestLocaleStructure 220# may fail. 221# Repeat steps 4-7 until there are no errors. 222 223# 9. Now run the make check tests in exhaustive mode: 224 225cd $ICU4C_DIR/source 226export INTLTEST_OPTS="-e" 227export CINTLTST_OPTS="-e" 228make check 2>&1 | tee /tmp/icu4c-newData-makeCheckEx.txt 229 230# 10. Again, investigate each failure, fixing CLDR data or ICU test cases as 231# appropriate, and repeating steps 4-7 and 9 until there are no errors. 232 233# 11. Now with ICU4J, build and test without new data first, to verify that 234# there are no pre-existing errors (or at least to have the pre-existing errors 235# as a base for comparison): 236 237cd $ICU4J_ROOT 238ant all 2>&1 | tee /tmp/icu4j-oldData-antAll.txt 239ant check 2>&1 | tee /tmp/icu4j-oldData-antCheck.txt 240 241# 12. Now build the new data and test data for ICU4J 242 243cd $ICU4C_DIR/source/data 244make icu4j-data-install 245cd $ICU4C_DIR/source/test/testdata 246make icu4j-data-install 247 248# 13. Now rebuild ICU4J with the new data and run tests: 249# Keep a log so you can investigate the errors. 250 251cd $ICU4J_ROOT 252ant check 2>&1 | tee /tmp/icu4j-newData-antCheck.txt 253 254# 14. Investigate test case failures; fix test cases and repeat from step 12, 255# or fix CLDR data and repeat from step 4, as appropriate, until; there are no 256# more failures in ICU4C or ICU4J (except failures that were present before you 257# began testing the new CLDR data). 258 259# 15. Check the file changes; then svn add or svn remove as necessary, and 260# commit the changes. 261 262cd $ICU4C_DIR/source 263git status 264# add or remove as necessary 265 266cd $ICU4J_ROOT 267git status 268# add or remove as necessary 269 270cd $HOME/icu/trunk/ 271# commit 272 273# 16. For an official CLDR data integration into ICU, now tag the CLDR and 274# ICU sources with an appropriate CLDR milestone (you can check previous 275# tags for format), e.g.: 276 277svn copy svn+ssh://unicode.org/repos/cldr/trunk \ 278svn+ssh://unicode.org/repos/cldr/tags/release-NNN \ 279--parents -m "cldrbug nnnn: tag cldr sources for NNN" 280 281svn copy svn+ssh://source.icu-project.org/repos/icu/trunk \ 282svn+ssh://source.icu-project.org/repos/icu/tags/cldr-NNN \ 283--parents -m 'ticket:mmmm: tag the version used for integrating CLDR NNN' 284 285