Home | History | Annotate | Download | only in data
      1 # Copyright (C) 2010,2012, International Business Machines Corporation and others.
      2 # All Rights Reserved.                  
      3 #
      4 # Commands for regenerating ICU4C locale data (.txt files) from CLDR.
      5 #
      6 # The process requires local copies of
      7 #    - CLDR (the source of most of the data, and some Java tools)
      8 #    - ICU4J  (used by the conversion tools)
      9 #    - ICU4C  (the destination for the new data, and the source for some of it)
     10 #             (Either check out ICU4C from Subversion, or download the additional 
     11 #              icu4c-*-data.zip file so that the icu/source/data/ directory is fully
     12 #              populated.)
     13 #
     14 # For an official CLDR data integration into ICU, these should be clean, freshly
     15 # checked-out. For released CLDR sources, an alternative to checking out sources
     16 # for a given version is downloading the zipped sources for the common (core.zip)
     17 # and tools (tools.zip) directory subtrees from the Data column in
     18 # [http://cldr.unicode.org/index/downloads].
     19 #
     20 # The versions of each of these must match. Included with the release notes for
     21 # ICU is the version number and/or a CLDR svn tag name for the revision of CLDR
     22 # that was the source of the data for that release of ICU.
     23 #
     24 # Note: Some versions of the OpenJDK will not build the CLDR java utilities.
     25 #   If you see compilation errors complaining about type incompatibilities with
     26 #   functions on generic classes, try switching to the Sun JDK.
     27 #
     28 # Besides a standard JDK, the process also requires ant
     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 # XML_APIS_JAR:  Complete path to xml-apis.jar (at the end of the path)
     52 #
     53 # ANT_OPTS:      Two important options you may want to set:
     54 #
     55 #                -Xmx1024m, to give Java more memory; otherwise it may run out
     56 #                 of heap.
     57 #
     58 #                -DCLDR_DTD_CACHE=/tmp/cldrdtd, to set up a temp directory for
     59 #                 caching the CLDR xml dtd, to speed up data generation.
     60 #
     61 # b) CLDR-related variables
     62 #
     63 # CLDR_DIR:      Path to root of CLDR sources, below which are the common and
     64 #                tools directories. Two other variables will be defined based
     65 #                on this:
     66 # CLDR_MAIN, CLDR_JAR are defined relative to CLDR_DIR.
     67 #
     68 # c) ICU-related variables:
     69 #
     70 # ICU4C_DIR:     Path to root of ICU4C sources, below which is the source dir.
     71 #
     72 # ICU4J_ROOT:    Path to root of ICU4J sources, below which is the main dir.
     73 #                Two other variables will be defined based on this:
     74 # ICU4J_JAR, UTILITIES_JAR are defined relative to ICU4J_ROOT.
     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 #    icu/trunk/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 #    icu/trunk/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 #    icu/trunk/source/data/xml/      - If you are adding a new locale, break
     99 #                iterator, collattion tailoring, or rule-based number formatter,
    100 #                you need to add a corresponding xml file in (respectively) the
    101 #                main/, brkitr/, collation/, or rbnf/ subdirectory here.
    102 #
    103 #----
    104 #
    105 # For an official CLDR data integration into ICU, there are some additional
    106 # considerations:
    107 #
    108 # a) Don't commit anything in ICU sources (and possibly any changes in CLDR
    109 #    sources, depending on their nature) until you have finished testing and
    110 #    resolving build issues and test failures for both ICU4C and ICU4J.
    111 #
    112 # b) There are version numbers that may need manual updating in CLDR (other
    113 #    version numbers get updated automatically, based on these):
    114 #
    115 #    common/dtd/ldml.dtd                            - update cldrVersion
    116 #    common/dtd/ldmlBCP47.dtd                       - update cldrVersion
    117 #    common/dtd/ldmlSupplemental.dtd                - update cldrVersion
    118 #    tools/java/org/unicode/cldr/util/CLDRFile.java - update GEN_VERSION
    119 #
    120 # c) After everything is committed, you will need to tag the CLDR, ICU4J, and
    121 #    ICU4C sources that ended up being used for the integration; see step 17
    122 #    below.
    123 #
    124 ################################################################################
    125 
    126 # 1a. Java and ant variables, adjust for your system
    127 # (here XML_APIS_JAR is set as on Mac OSX).
    128 
    129 export JAVA_HOME=`/usr/libexec/java_home`
    130 export XML_APIS_JAR=/Library/Java/Extensions/xml-apis.jar
    131 mkdir /tmp/cldrdtd
    132 export ANT_OPTS="-Xmx1024m -DCLDR_DTD_CACHE=/tmp/cldrdtd"
    133 
    134 # 1b. CLDR variables, adjust for your setup; with cygwin it might be e.g.
    135 # CLDR_DIR=`cygpath -wp /build/cldr`
    136 
    137 export CLDR_DIR=$HOME/cldr/trunk
    138 export CLDR_MAIN=$CLDR_DIR/common/main
    139 export CLDR_JAR=$CLDR_DIR/tools/java/cldr.jar
    140 #export CLDR_CLASSES=$CLDR_DIR/tools/java/classes
    141 
    142 # 1c. ICU variables
    143 
    144 export ICU4C_DIR=$HOME/icu/icu/trunk
    145 export ICU4J_ROOT=$HOME/icu/icu4j/trunk
    146 export ICU4J_JAR=$ICU4J_ROOT/icu4j.jar
    147 export UTILITIES_JAR=$ICU4J_ROOT/out/cldr_util/lib/utilities.jar
    148 #export ICU4J_CLASSES=$ICU4J_ROOT/out/cldr_util/bin
    149 
    150 # 2. Build ICU4J, including the cldr utilities.
    151 
    152 cd $ICU4J_ROOT
    153 ant clean all jar cldrUtil
    154 
    155 # 3. Build the CLDR Java tools
    156 
    157 cd $CLDR_DIR/tools/java
    158 ant jar
    159 
    160 # 4. Configure ICU4C, build and test without new data first, to verify that
    161 # there are no pre-existing errors (configure shown here for MacOSX, adjust
    162 # for your platform).
    163 
    164 cd $ICU4C_DIR/source
    165 ./runConfigureICU MacOSX
    166 make all 2>&1 | tee /tmp/icu4c-oldData-makeAll.txt
    167 make check 2>&1 | tee /tmp/icu4c-oldData-makeCheck.txt
    168 
    169 # 5. Build the new ICU4C data files; these include .txt files and .mk files.
    170 # These new files will replace whatever was already present in the ICU4C sources.
    171 # This process uses ant with ICU's data/build.xml and data/icu-config.xml to
    172 # operate (via CLDR's ant/CLDRConverterTool.java and ant/CLDRBuild.java) the
    173 # necessary CLDR tools including LDML2ICUConverter, ConvertTransforms, etc.
    174 # This process will take several minutes (CLDR_DTD_CACHE helps reduce this).
    175 # Keep a log so you can investigate anything that looks suspicious.
    176 
    177 cd $ICU4C_DIR/source/data
    178 ant clean
    179 ant all 2>&1 | tee /tmp/cldrNN-buildLog.txt
    180 
    181 # 6. Check which data files have modifications, which have been added or removed
    182 # (if there are no changes, you may not need to proceed further). Make sure the
    183 # list seems reasonable.
    184 
    185 svn status
    186 
    187 # 7. Fix any errors, investigate any warnings. Some warnings are expected,
    188 # including  warnings for missing versions in locale names which specify some
    189 # collationvariants, e.g.
    190 #   [cldr-build] WARNING (ja_JP_TRADITIONAL): No version #??
    191 #   [cldr-build] WARNING (zh_TW_STROKE): No version #??
    192 # and warnings for some empty collation bundles, e.g.
    193 #   [cldr-build] WARNING (en):  warning: No collations found. Bundle will ...
    194 #   [cldr-build] WARNING (to):  warning: No collations found. Bundle will ...
    195 #
    196 # Fixing may entail modifying CLDR source data or tools - for example,
    197 # updating the validSubLocales for collation data (file a bug f appropriate).
    198 # Repeat steps 5-7 until there are no build errors and no unexpected
    199 # warnings.
    200 
    201 # 8. Now rebuild ICU4C with the new data and run make check tests.
    202 # Again, keep a log so you can investigate the errors.
    203 
    204 cd $ICU4C_DIR/source
    205 make check 2>&1 | tee /tmp/icu4c-newData-makeCheck.txt
    206 
    207 # 9. Investigate each test case failure. The first run processing new CLDR data
    208 # from the Survey Tool can result in thousands of failures (in many cases, one
    209 # CLDR data fix can resolve hundreds of test failures). If the error is caused
    210 # by bad CLDR data, then file a CLDR bug, fix the data, and regenerate from
    211 # step 5a. If the data is OK but the testcase needs to be updated because the
    212 # data has legitimately changed, then update the testcase. You will check in
    213 # the updated testcases along with the new ICU data at the end of this process.
    214 # Note that if the new data has any differences in structure, you will have to
    215 # update test/testdata/structLocale.txt or /tsutil/cldrtest/TestLocaleStructure
    216 # may fail.
    217 # Repeat steps 5-8 until there are no errors.
    218 
    219 # 10. Now run the make check tests in exhaustive mode:
    220 
    221 cd $ICU4C_DIR/source
    222 export INTLTEST_OPTS="-e"
    223 export CINTLTST_OPTS="-e"
    224 make check 2>&1 | tee /tmp/icu4c-newData-makeCheckEx.txt
    225 
    226 # 11. Again, investigate each failure, fixing CLDR data or ICU test cases as
    227 # appropriate, and repeating steps 5-7 and 10 until there are no errors.
    228 
    229 # 12. Now with ICU4J, build and test without new data first, to verify that
    230 # there are no pre-existing errors (or at least to have the pre-existing errors
    231 # as a base for comparison):
    232 
    233 cd $ICU4J_ROOT
    234 ant all 2>&1 | tee /tmp/icu4j-oldData-antAll.txt
    235 ant check 2>&1 | tee /tmp/icu4j-oldData-antCheck.txt
    236 
    237 # 13. Now build the new data for ICU4J
    238 
    239 cd $ICU4C_DIR/source/data
    240 make icu4j-data-install
    241 
    242 # 14. Now rebuild ICU4J with the new data and run tests:
    243 # Keep a log so you can investigate the errors.
    244 
    245 cd $ICU4J_ROOT
    246 ant check 2>&1 | tee /tmp/icu4j-newData-antCheck.txt
    247 
    248 # 15. Investigate test case failures; fix test cases and repeat from step 14,
    249 # or fix CLDR data and repeat from step 5, as appropriate, unitl; there are no
    250 # more failures in ICU4C or ICU4J (except failures that were present before you
    251 # began testing the new CLDR data).
    252 
    253 # 16. Check the file changes; then svn add or svn remove as necessary, and
    254 # commit the changes.
    255 
    256 cd $ICU4C_DIR/source/
    257 svn status
    258 # add or remove as necessary, then commit
    259 
    260 cd $ICU4J_ROOT
    261 svn status
    262 # add or remove as necessary, then commit
    263 
    264 # 17. For an official CLDR data integration into ICU, now tag the CLDR, ICU4J,
    265 # and ICU4C sources with an appropriate CLDR milestone (you can check previous
    266 # tags for format), e.g.:
    267 
    268 svn copy svn+ssh://unicode.org/repos/cldr/trunk \
    269 svn+ssh://unicode.org/repos/cldr/tags/release-NNN \
    270 --parents -m "cldrbug nnnn: tag cldr sources for NNN"
    271 
    272 svn copy svn+ssh://source.icu-project.org/repos/icu/icu4j/trunk \
    273 svn+ssh://source.icu-project.org/repos/icu/icu4j/tags/cldr-NNN \
    274 --parents -m 'ticket:mmmm: tag the version used for integrating CLDR NNN'
    275 
    276 svn copy svn+ssh://source.icu-project.org/repos/icu/icu/trunk \
    277 svn+ssh://source.icu-project.org/repos/icu/icu/tags/cldr-NNN \
    278 --parents -m 'ticket:mmmm: tag the version used for integrating CLDR NNN'
    279 
    280