-# Copyright (C) 2010-2013, International Business Machines Corporation and others.
+# Copyright (C) 2016 and later: Unicode, Inc. and others.
+# License & terms of use: http://www.unicode.org/copyright.html
+# Copyright (C) 2010-2014, International Business Machines Corporation and others.
# All Rights Reserved.
#
# Commands for regenerating ICU4C locale data (.txt files) from CLDR.
# - CLDR (the source of most of the data, and some Java tools)
# - ICU4J (used only for checking the converted data)
# - ICU4C (the destination for the new data, and the source for some of it)
-# (Either check out ICU4C from Subversion, or download the additional
-# icu4c-*-data.zip file so that the icu/source/data/ directory is fully
-# populated.)
#
# For an official CLDR data integration into ICU, these should be clean, freshly
# checked-out. For released CLDR sources, an alternative to checking out sources
# ICU is the version number and/or a CLDR svn tag name for the revision of CLDR
# that was the source of the data for that release of ICU.
#
-# Note: Some versions of the OpenJDK will not build the CLDR java utilities.
-# If you see compilation errors complaining about type incompatibilities with
-# functions on generic classes, try switching to the Sun JDK.
-#
# Besides a standard JDK, the process also requires ant
# (http://ant.apache.org/),
# plus the xml-apis.jar from the Apache xalan package
#
#----
#
+# CLDR dtd caching
+#
+# Parts of the build process (notably building the new ICU data files in step 4)
+# require http: access to files in the CLDR repository; for example, processing
+# the files in icu4c/source/data/xml/ may require access to
+# http://www.unicode.org/repos/cldr/trunk/common/dtd/ldml.dtd
+#
+# Unless you cache the dtds locally by
+# 1. creating a temp directory e.g. ~/.cldrdtd
+# 2. setting CLDR_DTD_CACHE to it e.g. -DCLDR_DTD_CACHE=~/.cldrdtd
+# your system will make excessive network requests, which will result in the
+# Unicode server blocking access.
+#
+#----
+#
# There are several environment variables that need to be defined.
#
# a) Java- and ant-related variables
#
# ANT_OPTS: You may want to set:
#
-# -Xmx1024m, to give Java more memory; otherwise it may run out
+# -Xmx4096m, to give Java more memory; otherwise it may run out
# of heap.
+# -DCLDR_DTD_CACHE=~/.cldrdtd (or some other temp directory
+# that already exists), to reduce frequent http: access to dtds
+# and consequent blockage by Unicode server.
#
# b) CLDR-related variables
#
# CLDR_DIR: Path to root of CLDR sources, below which are the common and
# tools directories.
-# CLDR_CLASSES: Defined relative to CLDR_DIR. It only needs to be set if you
-# are not running ant jar for CLDR and have a non-default output
-# folder for cldr-tools classes.
+# CLDR_CLASSES: Path to the CLDR Tools classes directory. If not set, defaults
+# to $CLDR_DIR/tools/java/classes
#
# c) ICU-related variables
# These variables only need to be set if you're directly reusing the
# files are used in addition to the CLDR files as inputs to the CLDR data build
# process for ICU):
#
-# icu/trunk/source/data/icu-config.xml - Update <locales> to add or remove
+# icu4c/source/data/icu-config.xml - Update <locales> to add or remove
# CLDR locales for inclusion in ICU. Update <paths> to prefer
# alt forms for certain paths, or to exclude certain paths; note
# that <paths> items can only have draft or alt attributes.
# should also be included in <locales>, per PMC policy decision
# 2012-05-02 (see http://bugs.icu-project.org/trac/ticket/9298).
#
-# icu/trunk/source/data/build.xml - If you are adding or removing break
+# icu4c/source/data/build.xml - If you are adding or removing break
# iterators, you need to update <fileset id="brkitr" ...> under
# <target name="clean" ...> to clean the correct set of files.
#
-# icu/trunk/source/data/xml/ - If you are adding a new locale, break
+# If there are new CLDR resource bundle types, you may need to
+# updated the <remapper> sections to put these in the correct
+# data subfolder for ICU.
+#
+# icu4c/source/data/xml/ - If you are adding a new locale, break
# iterator, collation tailoring, or rule-based number formatter,
# you may need to add a corresponding xml file in (respectively)
# the main/, brkitr/, collation/, or rbnf/ subdirectory here.
# common/dtd/ldml.dtd - update cldrVersion
# common/dtd/ldmlBCP47.dtd - update cldrVersion
# common/dtd/ldmlSupplemental.dtd - update cldrVersion
+# common/dtd/ldmlSupplemental.dtd - updateunicodeVersion
+# keyboards/dtd/ldmlKeyboard.dtd - update cldrVersion
# tools/java/org/unicode/cldr/util/CLDRFile.java - update GEN_VERSION
#
# c) After everything is committed, you will need to tag the CLDR, ICU4J, and
# 1a. Java and ant variables, adjust for your system
export JAVA_HOME=`/usr/libexec/java_home`
-export ANT_OPTS="-Xmx1024m
+export ANT_OPTS="-Xmx4096m -DCLDR_DTD_CACHE=~/.cldrdtd"
# 1b. CLDR variables, adjust for your setup; with cygwin it might be e.g.
# CLDR_DIR=`cygpath -wp /build/cldr`
export CLDR_DIR=$HOME/cldr/trunk
-#export CLDR_CLASSES=$CLDR_DIR/tools/java/classes
# 1c. ICU variables
-export ICU4C_DIR=$HOME/icu/icu/trunk
-export ICU4J_ROOT=$HOME/icu/icu4j/trunk
+export ICU4C_DIR=$HOME/icu/icu4c
+export ICU4J_ROOT=$HOME/icu/icu4j
+
+# 1d. Pre-populate your CLDR DTD cache. You need to do this only once.
+
+mkdir ~/.cldrdtd
+cd ~/.cldrdtd
+curl http://www.unicode.org/repos/cldr/trunk/common/dtd/ldml.dtd \
+ -o http___www.unicode.org_repos_cldr_trunk_common_dtd_ldml.dtd
+# WAIT before hitting the server again; it WILL NOT give you a second chance!
+sleep 5
+curl http://www.unicode.org/repos/cldr/trunk/common/dtd/ldmlICU.dtd \
+ -o http___www.unicode.org_repos_cldr_trunk_common_dtd_ldmlICU.dtd
+sleep 5
+curl http://www.unicode.org/repos/cldr/trunk/common/dtd/ldmlSupplemental.dtd \
+ -o http___www.unicode.org_repos_cldr_trunk_common_dtd_ldmlSupplemental.dtd
# 2. Build the CLDR Java tools
+# Optionally build the jar, but ant will look inside the classes directory anyway
cd $CLDR_DIR/tools/java
-#cd $CLDR_DIR/cldr-tools
-ant jar
+ant all
+#ant jar
# 3. Configure ICU4C, build and test without new data first, to verify that
-# there are no pre-existing errors (configure shown here for MacOSX, adjust
-# for your platform).
+# there are no pre-existing errors. Here <platform> is the runConfigureICU
+# code for the platform you are building, e.g. Linux, MacOSX, Cygwin.
cd $ICU4C_DIR/source
-./runConfigureICU MacOSX
+./runConfigureICU <platform>
make all 2>&1 | tee /tmp/icu4c-oldData-makeAll.txt
make check 2>&1 | tee /tmp/icu4c-oldData-makeCheck.txt
# necessary CLDR tools including LDML2ICUConverter, ConvertTransforms, etc.
# This process will take several minutes.
# Keep a log so you can investigate anything that looks suspicious.
+#
+# Running "ant setup" is not required, but it will print useful errors to
+# debug issues with your path when it fails.
+#
+# If you see timeout errors when building the rbnf data, for example, then you are
+# likely not using a CLDR dtd cache; see "CLDR dtd caching" above. If you are using
+# a dtd cache and are still having timeout problems, the IP address of your system
+# may have been blocked due to previous excessive access. In this case you may need
+# to contact a Unicode sysadmin to restore access.
+#
+# Unfortunately, even if you have your DTD cache variable enabled, you may still
+# get blocked and unable to populate your cache because of multiple successive
+# requests to download the required DTD files. It is recommended that you
+# pre-populate your cache as shown above in step 1d.
cd $ICU4C_DIR/source/data
+ant setup
ant clean
-ant all 2>&1 | tee /tmp/cldrNN-buildLog.txt
+ant all 2>&1 | tee /tmp/cldr-newData-buildLog.txt
# 5. Check which data files have modifications, which have been added or removed
# (if there are no changes, you may not need to proceed further). Make sure the
# list seems reasonable.
-svn status
+git status
-# 6. Fix any errors, investigate any warnings. Some warnings are expected,
-# including warnings for missing versions in locale names which specify some
-# collationvariants, e.g.
-# [cldr-build] WARNING (ja_JP_TRADITIONAL): No version #??
-# [cldr-build] WARNING (zh_TW_STROKE): No version #??
-# and warnings for some empty collation bundles, e.g.
-# [cldr-build] WARNING (en): warning: No collations found. Bundle will ...
-# [cldr-build] WARNING (to): warning: No collations found. Bundle will ...
+# 6. Fix any errors, investigate any warnings. Currently for example there are
+# a few warnings of the following form in rbnf files:
+# [cldr-build] Warning: no version match with: $Revisionā¹$
#
# Fixing may entail modifying CLDR source data or tools - for example,
# updating the validSubLocales for collation data (file a bug if appropriate).
# 7. Now rebuild ICU4C with the new data and run make check tests.
# Again, keep a log so you can investigate the errors.
-
cd $ICU4C_DIR/source
+
+# 7a. If any files were added or removed (likely), re-run configure:
+./runConfigureICU <platform>
+make clean
+
+# 7b. Now do the rebuild.
make check 2>&1 | tee /tmp/icu4c-newData-makeCheck.txt
# 8. Investigate each test case failure. The first run processing new CLDR data
ant all 2>&1 | tee /tmp/icu4j-oldData-antAll.txt
ant check 2>&1 | tee /tmp/icu4j-oldData-antCheck.txt
-# 12. Now build the new data for ICU4J
+# 12. Transfer the data to ICU4J:
+cd $ICU4C_DIR/source
+
+# 12a. You need to reconfigure ICU4C to include the unicore data.
+ICU_DATA_BUILDTOOL_OPTS=--include_uni_core_data ./runConfigureICU <platform>
+# 12b. Now build the jar files.
cd $ICU4C_DIR/source/data
+# The following 2 lines are required to include the unicore data:
+ make clean
+ make -j6
+make icu4j-data-install
+cd $ICU4C_DIR/source/test/testdata
make icu4j-data-install
# 13. Now rebuild ICU4J with the new data and run tests:
ant check 2>&1 | tee /tmp/icu4j-newData-antCheck.txt
# 14. Investigate test case failures; fix test cases and repeat from step 12,
-# or fix CLDR data and repeat from step 4, as appropriate, until; there are no
+# or fix CLDR data and repeat from step 4, as appropriate, until there are no
# more failures in ICU4C or ICU4J (except failures that were present before you
# began testing the new CLDR data).
-# 15. Check the file changes; then svn add or svn remove as necessary, and
+# 15. Check the file changes; then git add or git rm as necessary, and
# commit the changes.
-cd $ICU4C_DIR/source
-svn status
-# add or remove as necessary, then commit
-
-cd $ICU4J_ROOT
-svn status
-# add or remove as necessary, then commit
+cd $HOME/icu/
+cd ..
+git status
+# add or remove as necessary
+# commit
-# 16. For an official CLDR data integration into ICU, now tag the CLDR, ICU4J,
-# and ICU4C sources with an appropriate CLDR milestone (you can check previous
+# 16. For an official CLDR data integration into ICU, now tag the CLDR and
+# ICU sources with an appropriate CLDR milestone (you can check previous
# tags for format), e.g.:
svn copy svn+ssh://unicode.org/repos/cldr/trunk \
svn+ssh://unicode.org/repos/cldr/tags/release-NNN \
--parents -m "cldrbug nnnn: tag cldr sources for NNN"
-svn copy svn+ssh://source.icu-project.org/repos/icu/icu4j/trunk \
-svn+ssh://source.icu-project.org/repos/icu/icu4j/tags/cldr-NNN \
---parents -m 'ticket:mmmm: tag the version used for integrating CLDR NNN'
+cd $HOME/icu/
+git tag ...
-svn copy svn+ssh://source.icu-project.org/repos/icu/icu/trunk \
-svn+ssh://source.icu-project.org/repos/icu/icu/tags/cldr-NNN \
---parents -m 'ticket:mmmm: tag the version used for integrating CLDR NNN'