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