Customize the ICU data for iOS
Add ios/icudtl.dat and ios/patch_locale.sh.
Update README.chromium and BUILD.gn accordingly.
Update scripts/copy_data.sh to take (ios|common|android).
At the moment, iOS data is almost identical to that of Android, but in the future
more cuts may be made (e.g. dictionary data for breakiterator).
Bug: 718955
TEST: iOS Chrome works as before.
Review-Url: https://codereview.chromium.org/2743123002 .
diff --git a/BUILD.gn b/BUILD.gn
index 4e9364b..30de807 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -967,6 +967,8 @@
# that have not been ported over.
if (is_android) {
data_dir = "android"
+} else if (is_ios) {
+ data_dir = "ios"
} else {
data_dir = "common"
}
diff --git a/README.chromium b/README.chromium
index cba7171..14dad32 100644
--- a/README.chromium
+++ b/README.chromium
@@ -54,7 +54,7 @@
This makes icudt${version}l.dat.
f. Run
- ${CHROME_ICU_TREE_TOP}/scripts/copy_data.sh
+ ${CHROME_ICU_TREE_TOP}/scripts/copy_data.sh common
This copies the ICU data files for non-Android platforms
(both Little and Big Endian) to the following locations:
@@ -73,20 +73,33 @@
This makes icudt${version}l.dat for Android.
i. Run
- ${CHROME_ICU_TREE_TOP}/scripts/copy_data_android.sh
+ ${CHROME_ICU_TREE_TOP}/scripts/copy_data.sh android
This copies the icu data file for Android to the following location:
android/icudtl.dat
j. Run
+ ${CHROME_ICU_TREE_TOP}/ios/patch_locale.sh
+
+ Further cuts the data size for iOS.
+
+ k. Run
+ ${CHROME_ICU_TREE_TOP}/scripts/make_data.sh
+
+ This makes icudt${version}l.dat for iOS.
+
+ l. Run
+ ${CHROME_ICU_TREE_TOP}/scripts/copy_data.sh ios
+
+ m. Run
${CHROME_ICU_TREE_TOP}/scripts/clean_up_data_source.sh
This reverts the result of trim_data.sh and patch_locale.sh and
make the tree ready for committing updated ICU data files for
non-Android and Android platforms.
- k. Whenever data is updated (e.g timezone update), follow d ~ j as long
+ n. Whenever data is updated (e.g timezone update), follow d ~ m as long
as the ICU build directory used in a ~ c is kept. Besides, icudt.dll for
Windows has to be udpated following the procedure described below.
diff --git a/ios/icudtl.dat b/ios/icudtl.dat
new file mode 100644
index 0000000..eb9da3e
--- /dev/null
+++ b/ios/icudtl.dat
Binary files differ
diff --git a/ios/patch_locale.sh b/ios/patch_locale.sh
new file mode 100755
index 0000000..6b8b214
--- /dev/null
+++ b/ios/patch_locale.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+treeroot="$(dirname "$0")/.."
+cd "${treeroot}"
+
+cd source/data
+
+# Keep only two common calendars. Add locale-specific calendars to Thai.
+COMMON_CALENDARS="gregorian|generic"
+for i in locales/*.txt; do
+ CALENDARS="${COMMON_CALENDARS}"
+ case $(basename $i .txt | sed 's/_.*$//') in
+ th)
+ EXTRA_CAL='buddhist'
+ ;;
+ *)
+ EXTRA_CAL=''
+ ;;
+ esac
+
+ CAL_PATTERN="(${COMMON_CALENDARS}${EXTRA_CAL:+|${EXTRA_CAL}})"
+ echo $CAL_PATTERN
+
+ echo Overwriting $i...
+ sed -r '/^ calendar\{$/,/^ \}$/ {
+ /^ calendar\{$/p
+ /^ default\{".*"\}$/p
+ /^ '${CAL_PATTERN}'\{$/, /^ \}$/p
+ /^ \}$/p
+ d
+ }' -i $i
+done
+
+echo DONE.
diff --git a/scripts/copy_data.sh b/scripts/copy_data.sh
index 98b4c08..607badc 100755
--- a/scripts/copy_data.sh
+++ b/scripts/copy_data.sh
@@ -6,18 +6,48 @@
# This script is tested ONLY on Linux. It may not work correctly on
# Mac OS X.
#
+
+if [ $# -lt 1 ];
+then
+ echo "Usage: "$0" (common|android|ios)" >&2
+ exit 1
+fi
+
TOPSRC="$(dirname "$0")/.."
source "${TOPSRC}/scripts/data_common.sh"
-DATA_PREFIX="data/out/tmp/icudt${VERSION}"
-echo "Generating the big endian data bundle"
-LD_LIBRARY_PATH=lib bin/icupkg -tb "${DATA_PREFIX}l.dat" "${DATA_PREFIX}b.dat"
+function copy_common {
+ DATA_PREFIX="data/out/tmp/icudt${VERSION}"
-echo "Copying icudtl.dat and icudtlb.dat"
-for endian in l b
-do
- cp "${DATA_PREFIX}${endian}.dat" "${TOPSRC}/common/icudt${endian}.dat"
-done
+ echo "Generating the big endian data bundle"
+ LD_LIBRARY_PATH=lib bin/icupkg -tb "${DATA_PREFIX}l.dat" "${DATA_PREFIX}b.dat"
-echo "Done with copying pre-built ICU data files."
+ echo "Copying icudtl.dat and icudtlb.dat"
+ for endian in l b
+ do
+ cp "${DATA_PREFIX}${endian}.dat" "${TOPSRC}/common/icudt${endian}.dat"
+ done
+
+ echo "Done with copying pre-built ICU data files."
+}
+
+function copy_android_ios {
+ echo "Copying icudtl.dat for $1"
+
+ cp "data/out/tmp/icudt${VERSION}l.dat" "${TOPSRC}/$2/icudtl.dat"
+
+ echo "Done with copying pre-built ICU data file for $1."
+}
+
+case "$1" in
+ "common")
+ copy_common
+ ;;
+ "android")
+ copy_android_ios Android android
+ ;;
+ "ios")
+ copy_android_ios iOS ios
+ ;;
+esac