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" 61 62rm -rf "$out_put_root_path/thirdparty/icu/out/*" 63 64gen_icu_data() { 65 66 # compile to res file 67 PYTHONPATH=$icu_source_path/source/python python3 -m icutools.databuilder \ 68 --src_dir $icu_source_path/source/data \ 69 --include_uni_core_data \ 70 --seqmode sequential \ 71 --filter_file $icu_data_filter_file \ 72 --mode unix-exec \ 73 --tool_dir $tool_bin_dir \ 74 --out_dir $res_out_root_dir/out/build/$icu_dat_name \ 75 --tmp_dir $res_out_root_dir/out/tmp \ 76 77 # package to one dat file 78 export LD_LIBRARY_PATH=$tool_bin_dir:$LD_LIBRARY_PATH 79 $tool_bin_dir/pkgdata \ 80 -s $res_out_root_dir/out/build/$icu_dat_name \ 81 -T $res_out_root_dir/out/tmp -p $icu_dat_name \ 82 -d $res_out_root_dir/out \ 83 $res_out_root_dir/out/tmp/icudata.lst 84} 85 86if ! gen_icu_data; then 87 echo "[ICUData] gen icudata res failed." 88 exit 1 89fi 90echo "[ICUData] gen icudata res success." 91 92exit 0 93