!256 ICU数据实时编译

Merge pull request !256 from zhangdd_ewan/master
This commit is contained in:
openharmony_ci 2024-08-20 10:39:23 +00:00 committed by Gitee
commit 6c7a1b0b56
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 665 additions and 45 deletions

View File

@ -17,4 +17,6 @@ declare_args() {
icu_support_libbegetutil = true
distro_tzdata_dir = "\"/system/etc/tzdata_distro\""
system_tzdata_dir = "\"/system/etc/icu_tzdata\""
icu_dat_name = "icudt72l"
icu_data_filter_dir = "full"
}

View File

@ -54,22 +54,6 @@ ohos_static_library("static_icustubdata") {
subsystem_name = "thirdparty"
}
ohos_prebuilt_etc("ohos_icudat") {
if ("${product_name}" == "ohcore") {
source = "//third_party/icu/ohos_icu4j/data/icudt68l.dat"
} else if ("${build_feature}" == "lite") {
source = "//third_party/icu/ohos_icu4j/data/lite/icudt72l.dat"
} else if (icu_support_locales) {
source = "//third_party/icu/ohos_icu4j/data/icudt72l.dat"
} else {
source = "//third_party/icu/ohos_icu4j/data/lite/icudt72l.dat"
}
module_install_dir = "usr/ohos_icu/"
part_name = "icu"
subsystem_name = "thirdparty"
}
icu_common_source = [
"//third_party/icu/icu4c/source/common/ubiditransform.cpp",
"//third_party/icu/icu4c/source/common/locutil.cpp",
@ -542,10 +526,7 @@ ohos_shared_library("shared_icuuc") {
"SYSTEM_TZDATA_DIR=${system_tzdata_dir}",
]
sources = icu_common_source
deps = [
":ohos_icudat",
":static_icustubdata",
]
deps = [ ":static_icustubdata" ]
cflags_cc = [
"-O3",
"-W",

View File

@ -262,7 +262,8 @@ ohos_shared_library("shared_icuuc_host") {
"-shared",
"-lm",
]
subsystem_name = "$icu_lib_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "hmicuuchost"
}
@ -347,7 +348,8 @@ ohos_shared_library("shared_icutu") {
"-shared",
"-lm",
]
subsystem_name = "$icu_lib_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "hmicutuhost"
}
@ -398,7 +400,8 @@ ohos_shared_library("shared_icuio") {
"-shared",
"-lm",
]
subsystem_name = "$icu_lib_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "hmicuio"
}
@ -412,7 +415,10 @@ group("lib_host") {
}
ohos_executable("genbrk") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [ "//third_party/icu/icu4c/source/tools/genbrk/genbrk.cpp" ]
cflags_cc = [
@ -428,12 +434,16 @@ ohos_executable("genbrk") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "genbrk"
}
ohos_executable("genccode") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [ "//third_party/icu/icu4c/source/tools/genccode/genccode.c" ]
cflags_cc = [
@ -449,12 +459,16 @@ ohos_executable("genccode") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "genccode"
}
ohos_executable("gencfu") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [ "//third_party/icu/icu4c/source/tools/gencfu/gencfu.cpp" ]
cflags_cc = [
@ -470,12 +484,16 @@ ohos_executable("gencfu") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "gencfu"
}
ohos_executable("gencnval") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [ "//third_party/icu/icu4c/source/tools/gencnval/gencnval.c" ]
cflags_cc = [
@ -491,12 +509,16 @@ ohos_executable("gencnval") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "gencnval"
}
ohos_executable("gendict") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [ "//third_party/icu/icu4c/source/tools/gendict/gendict.cpp" ]
cflags_cc = [
@ -512,12 +534,16 @@ ohos_executable("gendict") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "gendict"
}
ohos_static_library("genrb_c") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [
"//third_party/icu/icu4c/source/tools/genrb/errmsg.c",
@ -540,11 +566,15 @@ ohos_static_library("genrb_c") {
"-DUNISTR_FROM_STRING_EXPLICIT=explicit",
"-DU_ATTRIBUTE_DEPRECATED=",
"-Wno-sign-compare",
"-Wno-error=strict-prototypes",
"-Wno-error=unused-but-set-variable",
]
ldflags = [
"-ldl",
"-lm",
]
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
}
ohos_executable("genrb") {
configs = [
@ -579,17 +609,22 @@ ohos_executable("genrb") {
"-DUNISTR_FROM_CHAR_EXPLICIT=explicit",
"-DUNISTR_FROM_STRING_EXPLICIT=explicit",
"-DU_ATTRIBUTE_DEPRECATED=",
"-Wno-unused-but-set-variable",
]
ldflags = [
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "genrb"
}
ohos_executable("derb") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [ "//third_party/icu/icu4c/source/tools/genrb/derb.cpp" ]
cflags_cc = [
@ -605,12 +640,16 @@ ohos_executable("derb") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "derb"
}
ohos_executable("makeconv") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [
"//third_party/icu/icu4c/source/tools/makeconv/gencnvex.c",
@ -631,12 +670,16 @@ ohos_executable("makeconv") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "makeconv"
}
ohos_executable("gensprep") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [
"//third_party/icu/icu4c/source/tools/gensprep/gensprep.c",
@ -655,12 +698,16 @@ ohos_executable("gensprep") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "gensprep"
}
ohos_executable("icupkg") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [ ":lib_host" ]
sources = [ "//third_party/icu/icu4c/source/tools/icupkg/icupkg.cpp" ]
cflags_cc = [
@ -676,12 +723,16 @@ ohos_executable("icupkg") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "icupkg"
}
ohos_executable("pkgdata") {
configs = [ ":icu_config" ]
configs = [
":icu_config",
"//build/config/compiler:rtti",
]
deps = [
":lib_host",
":shared_icutu(${host_toolchain})",
@ -703,7 +754,8 @@ ohos_executable("pkgdata") {
"-ldl",
"-lm",
]
subsystem_name = "$icu_bin_host_subsystem_name"
part_name = "$icu_part_name"
subsystem_name = "$icu_subsystem_name"
output_name = "pkgdata"
}
group("bin_host") {

View File

@ -29,6 +29,7 @@ ohos_shared_library("icundk") {
sources = [ "src/icu_addon.cpp" ]
deps = [
":ohos_icudat",
"//third_party/icu/icu4c:shared_icui18n",
"//third_party/icu/icu4c:shared_icuuc",
]
@ -46,3 +47,37 @@ ohos_shared_library("icundk") {
subsystem_name = "thirdparty"
part_name = "icu"
}
action("pkg_icudata") {
script = "build_data/pkgdata.sh"
sources = [ "//third_party/icu/ohos_icu4c/build_data/pkgdata.sh" ]
deps = [ "//third_party/icu/icu4c/source:bin_host" ]
icu_bin_root_out_dir =
get_label_info(
"//third_party/icu/icu4c/source:bin_host(${host_toolchain})",
"root_out_dir")
if ("${build_feature}" == "lite") {
icu_data_filter_dir = "lite"
}
args = [
"-o",
"$root_out_dir",
"-b",
"$icu_bin_root_out_dir",
"-f",
"$icu_data_filter_dir",
"-v",
"$icu_dat_name",
]
outputs = [ "$root_out_dir/thirdparty/icu/out/$icu_dat_name.dat" ]
}
ohos_prebuilt_etc("ohos_icudat") {
source = "$root_out_dir/thirdparty/icu/out/$icu_dat_name.dat"
deps = [ ":pkg_icudata" ]
module_install_dir = "usr/ohos_icu/"
part_name = "icu"
subsystem_name = "thirdparty"
}

View File

@ -0,0 +1,3 @@
{
"strategy": "subtractive"
}

View File

@ -0,0 +1,455 @@
{
"strategy": "subtractive",
"localeFilter" : {
"filterType" : "locale",
"includeChildren": false,
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"en_IN",
"pt",
"pt_PT",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
},
"featureFilters": {
"conversion_mappings" : {
"includelist":[
"gb18030",
"ibm-1386_P100-2001",
"windows-936-2000",
"ibm-1383_P110-1999",
"ibm-5478_P100-1995"
]
},
"brkitr_dictionaries": {
"whitelist": [
"dictionaries/cjdict"
]
},
"brkitr_lstm": "exclude",
"brkitr_tree": {
"includelist":[
"root",
"ja",
"fr",
"de",
"pt",
"id",
"es",
"it",
"en",
"en_US",
"zh",
"zh_Hant",
"sv"
]
},
"lang_tree": {
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"en_IN",
"pt",
"pt_PT",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
},
"unit_tree": {
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en_IN",
"pt",
"pt_PT",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
},
"rbnf_tree": {
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en_IN",
"pt",
"pt_PT",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
},
"zone_tree": {
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en_IN",
"pt",
"pt_PT",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
},
"curr_tree": {
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en_IN",
"pt",
"pt_PT",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
},
"coll_tree": {
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en_IN",
"pt",
"pt_PT",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
},
"region_tree": {
"includelist":[
"root",
"ar",
"ar_001",
"agq",
"agq_CM",
"ja",
"ja_JP",
"fr",
"fr_FR",
"de",
"de_DE",
"id",
"id_ID",
"es",
"it",
"it_IT",
"tr",
"tr_TR",
"lt",
"lt_LT",
"ko",
"ko_KR",
"th",
"th_TH",
"en_IN",
"pt",
"pt_PT",
"en",
"en_001",
"en_US",
"en_GB",
"zh",
"zh_CN",
"zh_Hans",
"zh_Hant",
"zh_Hant_MO",
"zh_Hant_HK",
"zh_Hant_TW",
"zh_Hans_CN",
"ug",
"ug_CN",
"bo",
"bo_CN",
"bo_IN",
"sv",
"sv_AX",
"sv_FI",
"sv_SE"
]
}
}
}

View File

@ -0,0 +1,92 @@
#!/bin/bash
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
echo "[ICUData]++++++++++++++++++Pkg icu data start.++++++++++++++++++++++"
date +%F' '%H:%M:%S
echo $@
script_path=$(cd $(dirname $0); pwd)
while getopts "o:b:v:f:h" arg;
do
case "${arg}" in
"o")
out_put_root_path=${OPTARG}
;;
"b")
tool_bin_dir=${OPTARG}
;;
"v")
icu_dat_name=${OPTARG}
;;
"f")
icu_data_filter_dir=${OPTARG}
;;
"h")
exit 0
;;
?)
echo "unkonw argument"
exit 1
;;
esac
done
script_path=$(cd $(dirname $0); pwd)
root_path="$script_path/../../../.."
if ! root_path=$(realpath "$root_path"); then
echo "Cannot find real path for root_path '$root_path'."
exit 1
fi
out_put_root_path="$root_path/$out_put_root_path"
tool_bin_dir="$root_path/$tool_bin_dir/thirdparty/icu"
icu_source_path="$root_path/third_party/icu/icu4c"
res_out_root_dir="$out_put_root_path/thirdparty/icu"
icu_data_filter_file="$script_path/$icu_data_filter_dir/data_filter.json"
rm -rf "$out_put_root_path/thirdparty/icu/out/*"
gen_icu_data() {
# compile to res file
PYTHONPATH=$icu_source_path/source/python python3 -m icutools.databuilder \
--src_dir $icu_source_path/source/data \
--include_uni_core_data \
--seqmode sequential \
--filter_file $icu_data_filter_file \
--mode unix-exec \
--tool_dir $tool_bin_dir \
--out_dir $res_out_root_dir/out/build/$icu_dat_name \
--tmp_dir $res_out_root_dir/out/tmp \
# package to one dat file
export LD_LIBRARY_PATH=$tool_bin_dir:$LD_LIBRARY_PATH
$tool_bin_dir/pkgdata \
-s $res_out_root_dir/out/build/$icu_dat_name \
-T $res_out_root_dir/out/tmp -p $icu_dat_name \
-d $res_out_root_dir/out \
$res_out_root_dir/out/tmp/icudata.lst
}
if ! gen_icu_data; then
echo "[ICUData] gen icudata res failed."
exit 1
fi
echo "[ICUData] gen icudata res success."
exit 0