• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2024 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set -e
16
17echo "[ICUData]++++++++++++++++++Pkg icu data start.++++++++++++++++++++++"
18date +%F' '%H:%M:%S
19echo $@
20
21script_path=$(cd $(dirname $0); pwd)
22
23while getopts "o:b:v:f:h" arg;
24do
25    case "${arg}" in
26        "o")
27            out_put_root_path=${OPTARG}
28        ;;
29        "b")
30            tool_bin_dir=${OPTARG}
31        ;;
32        "v")
33            icu_dat_name=${OPTARG}
34        ;;
35        "f")
36            icu_data_filter_dir=${OPTARG}
37        ;;
38        "h")
39            exit 0
40        ;;
41    ?)
42        echo "unkonw argument"
43        exit 1
44        ;;
45    esac
46done
47
48script_path=$(cd $(dirname $0); pwd)
49root_path="$script_path/../../../.."
50
51if ! root_path=$(realpath "$root_path"); then
52    echo "Cannot find real path for root_path '$root_path'."
53    exit 1
54fi
55
56out_put_root_path="$root_path/$out_put_root_path"
57tool_bin_dir="$root_path/$tool_bin_dir/thirdparty/icu"
58icu_source_path="$root_path/third_party/icu/icu4c"
59res_out_root_dir="$out_put_root_path/thirdparty/icu"
60icu_data_filter_file="$script_path/$icu_data_filter_dir/data_filter.json"
61export LD_LIBRARY_PATH=$res_out_root_dir:$LD_LIBRARY_PATH
62export LD_LIBRARY_PATH=$tool_bin_dir:$LD_LIBRARY_PATH
63
64rm -rf "$out_put_root_path/thirdparty/icu/out/*"
65
66python3 $script_path/ohos_data.py \
67    --icu_src_dir "$icu_source_path/source/data" \
68    --ohos_src_dir "$script_path/$icu_data_filter_dir/" \
69    --out_dir "$out_put_root_path/thirdparty/icu" \
70
71gen_icu_data() {
72
73    # compile to res file
74    PYTHONPATH=$icu_source_path/source/python python3 -m icutools.databuilder \
75    --src_dir $icu_source_path/source/data \
76    --include_uni_core_data \
77    --seqmode sequential \
78    --filter_file $out_put_root_path/thirdparty/icu/out/temp/data_filter.json \
79    --mode unix-exec \
80    --tool_dir $tool_bin_dir \
81    --out_dir $res_out_root_dir/out/build/$icu_dat_name \
82    --tmp_dir $res_out_root_dir/out/tmp \
83
84    # package to one dat file
85    export LD_LIBRARY_PATH=$tool_bin_dir:$LD_LIBRARY_PATH
86    $tool_bin_dir/pkgdata \
87    -s $res_out_root_dir/out/build/$icu_dat_name \
88    -T $res_out_root_dir/out/tmp -p $icu_dat_name \
89    -d $res_out_root_dir/out \
90    $res_out_root_dir/out/tmp/icudata.lst
91}
92
93if ! gen_icu_data; then
94    echo "[ICUData] gen icudata res failed."
95    exit 1
96fi
97echo "[ICUData] gen icudata res success."
98
99exit 0
100