diff --git a/thirdparty/OpenCC/HPKBUILD b/thirdparty/OpenCC/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..015549c314087596dcf7cf2c4c8e4b21a009ec94 --- /dev/null +++ b/thirdparty/OpenCC/HPKBUILD @@ -0,0 +1,122 @@ +# Copyright (c) 2025 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. + +# Contributor: dingchenjie1 +# Maintainer: dingchenjie1 + +pkgname=OpenCC +pkgver=ver.1.1.9 +pkgrel=0 +pkgdesc="OpenCC is an opensource project for conversions between Traditional Chinese, Simplified Chinese and Japanese Kanji (Shinjitai)." +url="https://github.com/BYVoid/OpenCC" +archs=("armeabi-v7a" "arm64-v8a") +license=("Apache-2.0") +depends=() +makedepends=("doxygen") + +source="https://github.com/BYVoid/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="make" +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +source envset.sh +buildsrchostflag=true +# OpenCC 采用makefile编译构建,为了保留构建环境(方便测试)。因此同一份源码在解压后分为两份,各自编译互不干扰 +prepare() { + # 预编译源平台二进制以生成字体文件 + if $buildsrchostflag + then + cp -arf $builddir $builddir-src_host-build + cd $builddir-src_host-build + $MAKE PREFIX=$builddir-src_host-build/usr VERBOSE=1 >> $publicbuildlog 2>&1 + ret=$? + # buildsrchostflag只需要编一次,关闭build + buildsrchostflag=false + cd $OLDPWD + fi + + cp -arf $builddir $builddir-$ARCH-build + # 将编译依赖的字体文件拷贝到指定目录 + mkdir -p $builddir-$ARCH-build/build/rel + mkdir -p $builddir-$ARCH-build/build/dbg + cp -arf $builddir-src_host-build/build/rel/data $builddir-$ARCH-build/build/rel + cp -arf $builddir-src_host-build/build/rel/data $builddir-$ARCH-build/build/dbg + ## 修改编译条件,使编译时不生成额外的依赖文件 + cd $builddir-$ARCH-build + patch -p1 < `pwd`/../opencc_oh_pkg.patch >> $publicbuildlog 2>&1 + cd $OLDPWD + + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + elif [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + else + echo "${ARCH} not support" + return -1 + fi + return $ret +} + +build() { + cd $builddir-$ARCH-build + $MAKE PREFIX=$LYCIUM_ROOT/usr/$pkgname/$ARCH VERBOSE=1 > $buildlog 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-$ARCH-build + $MAKE VERBOSE=1 install PREFIX=$LYCIUM_ROOT/usr/$pkgname/$ARCH >> $buildlog 2>&1 + ret=$? + cd $OLDPWD + ## 将OpenCC依赖的配置文件拷贝到指定目录 + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/share/opencc + cp -arf $builddir-src_host-build/build/rel/data/* $LYCIUM_ROOT/usr/$pkgname/$ARCH/share/opencc + return $ret +} + +check() { + cd $builddir-$ARCH-build + ## 修改编译条件,使编译时不进行测试操作 + sed -i '/^\s*(cd build\/dbg; ctest --verbose)/s/^/#/' Makefile + sed -i '/^\s*make -C build\/dbg install VERBOSE=${VERBOSE}/s/^/#/' Makefile + ## 编译出测试应用 + $MAKE test >> $builddir-$ARCH-test-build.log 2>&1 + ret=$? + cd $OLDPWD + + if [ $ARCH == "armeabi-v7a" ]; then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ]; then + unsetarm64ENV + fi + unset host + + echo "The test must be on an OpenHarmony device!" + ## ctest + return $ret +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build $builddir-arm64-v8a-build #${PWD}/$packagename +} \ No newline at end of file diff --git a/thirdparty/OpenCC/HPKCHECK b/thirdparty/OpenCC/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..62ac2fc4e7e45c3640680bdacf72419a66cbfa6f --- /dev/null +++ b/thirdparty/OpenCC/HPKCHECK @@ -0,0 +1,31 @@ +# Copyright (c) 2025 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. + +# Contributor: dingchenjie1 +# Maintainer: dingchenjie1 + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log +openharmonycheck() { + res=0 + cd $builddir-$ARCH-build/build/dbg + ctest > ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + mkdir -p ${LYCIUM_FAULT_PATH}/${pkgname} + cp Testing/Temporary/LastTest.log ${LYCIUM_FAULT_PATH}/${pkgname}/ + fi + cd $OLDPWD + return $res +} \ No newline at end of file diff --git a/thirdparty/OpenCC/README.OpenSource b/thirdparty/OpenCC/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..780be58ef05f007a3458aa09e6a88c8f0d7ce03a --- /dev/null +++ b/thirdparty/OpenCC/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "OpenCC", + "License": "Apache-2.0", + "License File": "https://github.com/BYVoid/OpenCC/blob/master/LICENSE", + "Version Number": "ver.1.1.9", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/BYVoid/OpenCC/archive/refs/tags/ver.1.1.9.tar.gz", + "Description": "Open Chinese Convert (OpenCC, 開放中文轉換) is an opensource project for conversions between Traditional Chinese, Simplified Chinese and Japanese Kanji (Shinjitai)." + } +] diff --git a/thirdparty/OpenCC/README_zh.md b/thirdparty/OpenCC/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..6d142a2fd489659329d16a60882052f337722250 --- /dev/null +++ b/thirdparty/OpenCC/README_zh.md @@ -0,0 +1,12 @@ +# OpenCC 三方库说明 +## 功能简介 +OpenCC (开放式汉字转换) 是一个开源的工程,用于繁体中文、简体中文和日文汉字之间的转换。 + +## 三方库版本 +- OpenCC-ver.1.1.9 + +## 使用约束 +- [IDE和SDK版本](../../docs/constraint.md) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/OpenCC/SHA512SUM b/thirdparty/OpenCC/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..c7cb47610a39255e45c853bae779e1a72e1acb60 --- /dev/null +++ b/thirdparty/OpenCC/SHA512SUM @@ -0,0 +1 @@ +713cf00931d7616994eb455eef3bc893096b5cd6d42b346aa1130591752d9612891ea3ed035bd7bd4ec7df1c90425e86375f5b3337fac11663c656c79a8f33e9 OpenCC-ver.1.1.9.tar.gz \ No newline at end of file diff --git a/thirdparty/OpenCC/docs/hap_integrate.md b/thirdparty/OpenCC/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..e44ddfc297079a8832a05d336e84f18faa830615 --- /dev/null +++ b/thirdparty/OpenCC/docs/hap_integrate.md @@ -0,0 +1,81 @@ +# OpenCC 集成到应用 hap + +本库是在 RK3568 开发板上基于 OpenHarmony3.2 Release 版本的镜像验证的,如果是从未使用过 RK3568,可以先查看[润和 RK3568 开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- [开发环境准备](../../../docs/hap_integrate_environment.md) + +## 编译三方库 + +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + + ``` + tpc_c_cplusplus/thirdparty/OpenCC #三方库OpenCC的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── HPKCHECK #自动化测试脚本 + ├── README_zh.md #三方库说明文档 + ``` + +- 在 lycium 目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ``` + + cd lycium + ./build.sh OpenCC + ``` + +- 三方库头文件及生成的库 + 在 lycium 目录下会生成 usr 目录,该目录下存在已编译完成的 32 位和 64 位三方库 + + ``` + OpenCC/arm64-v8a OpenCC/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的头文件和库文件拷贝到该目录下,将编译生成的动态库(只需要拷贝soname的so到该目录,否则会增加hap的大小)拷贝到工程的libs目录下。如下图所示: +   + +  ![OpenCC_install](pic/OpenCC_install.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + +```shell + +#将三方库加入工程中 +target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/OpenCC/${OHOS_ARCH}/lib/libopencc.so.1.1) +#将三方库的头文件加入工程中 +target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/OpenCC/${OHOS_ARCH}/include) + +``` + +![OpenCC_usage](pic/OpenCC_usage.png) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +进入到构建目录执行(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) +```shell + cd build/dbg + ctest #执行测试用例 +``` + ![OpenCC_test](pic/OpenCC_test.png) + +## 参考资料 + +- [润和 RK3568 开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony 三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony 知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过 DevEco Studio 开发一个 NAPI 工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/OpenCC/docs/pic/OpenCC_install.png b/thirdparty/OpenCC/docs/pic/OpenCC_install.png new file mode 100644 index 0000000000000000000000000000000000000000..a8e430f1b9994039fade4544e2d4e36d43c98324 Binary files /dev/null and b/thirdparty/OpenCC/docs/pic/OpenCC_install.png differ diff --git a/thirdparty/OpenCC/docs/pic/OpenCC_test.png b/thirdparty/OpenCC/docs/pic/OpenCC_test.png new file mode 100644 index 0000000000000000000000000000000000000000..b5439881d1dbc36f1ee3efa11af375766c2fbb81 Binary files /dev/null and b/thirdparty/OpenCC/docs/pic/OpenCC_test.png differ diff --git a/thirdparty/OpenCC/docs/pic/OpenCC_usage.png b/thirdparty/OpenCC/docs/pic/OpenCC_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..6a400301cd4bff0d33fe4e3a0a0985b05c79389f Binary files /dev/null and b/thirdparty/OpenCC/docs/pic/OpenCC_usage.png differ diff --git a/thirdparty/OpenCC/opencc_oh_pkg.patch b/thirdparty/OpenCC/opencc_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..481d356f1c9ca0400351841c4f2dba392b770d8f --- /dev/null +++ b/thirdparty/OpenCC/opencc_oh_pkg.patch @@ -0,0 +1,14 @@ +diff -upN OpenCC-ver.1.1.9/CMakeLists.txt OpenCC-ver.1.1.9-arm64-v8a-build/CMakeLists.txt +--- OpenCC-ver.1.1.9/CMakeLists.txt 2024-08-03 11:45:16.000000000 +0800 ++++ OpenCC-ver.1.1.9-arm64-v8a-build/CMakeLists.txt 2025-02-19 09:50:40.904744320 +0800 +@@ -221,8 +221,8 @@ endif() + ######## Subdirectories + + add_subdirectory(src) +-add_subdirectory(doc) +-add_subdirectory(data) ++# add_subdirectory(doc) ++# add_subdirectory(data) + add_subdirectory(test) + + ######## Testing