xref: /aosp_15_r20/external/cronet/third_party/icu/cast/patch_locale.sh (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/bin/sh
2# Copyright (c) 2012 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6treeroot="$(dirname "$0")/.."
7cd "${treeroot}"
8
9echo "Applying brkitr.patch"
10patch -p1 < cast/brkitr.patch || { echo "failed to patch" >&2; exit 1; }
11
12# One of the purposes of this patch is to reduce the binary size by excluding
13# `cjdict`, which is one of the biggest resources.
14#
15# On the other hand, the AdaBoost ML line break engine requires `cjdict` to
16# exist, regardless of the content. To enable the AdaBoost ML line break
17# engine, this patch makes `cjdcit` empty instead of excluding.
18#
19# It can't be really empty though, as the build tool fails if it's empty.
20# Instead, this patch makes it just one entry.
21CJDICT="${treeroot}/source/data/brkitr/dictionaries/cjdict.txt"
22CJDICT_TMP="${CJDICT}.tmp"
23grep -E "^[^#[:space:]]+[[:space:]]+[[:digit:]]+" "$CJDICT" |
24  tail -1 > "$CJDICT_TMP"
25mv "$CJDICT_TMP" "$CJDICT"
26