diff --git a/thirdparty/rime/HPKBUILD b/thirdparty/rime/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..f54771b2959e27f339cd163884a0c765eab60beb --- /dev/null +++ b/thirdparty/rime/HPKBUILD @@ -0,0 +1,61 @@ +# 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=rime +pkgver=1.13.0 +pkgrel=0 +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD-3-Clause license") +depends=("leveldb" "glog" "yaml-cpp" "marisa-trie" "boost" "googletest" "OpenCC" "gflags") +makedepends=() +source="https://github.com/rime/lib${pkgname}/archive/refs/tags/${pkgver}.tar.gz" +autounpack=true +downloadpackage=true +buildtools="cmake" +builddir=lib$pkgname-${pkgver} +packagename=${pkgver}.tar.gz + +prepare() { + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -B${ARCH}-build \ + -DBUILD_MERGED_PLUGINS=OFF \ + -DENABLE_EXTERNAL_PLUGINS=ON > $buildlog 2>&1 + + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake --build ${ARCH}-build >> $buildlog 2>&1 + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake --build ${ARCH}-build --target install >> $buildlog 2>&1 + cd $OLDPWD + return $ret +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename + return $ret +} diff --git a/thirdparty/rime/HPKCHECK b/thirdparty/rime/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..b8fc0847690a8ffa02e48feca71eb3084478127f --- /dev/null +++ b/thirdparty/rime/HPKCHECK @@ -0,0 +1,32 @@ +# 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 + ctest > ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ];then + mkdir ${LYCIUM_FAULT_PATH}/${pkgname} + cp Testing/Temporary/LastTest.log ${LYCIUM_FAULT_PATH}/${pkgname}/ + fi + cd $OLDPWD + + return $res +} diff --git a/thirdparty/rime/README.OpenSource b/thirdparty/rime/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..c32d3108a2faa0b9001c3da70f8493dbac7e0707 --- /dev/null +++ b/thirdparty/rime/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "rime", + "License": "BSD-3-Clause license", + "License File": "https://github.com/rime/librime/blob/master/LICENSE", + "Version Number": "1.13.0", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/rime/librime/archive/refs/tags/1.13.0.tar.gz", + "Description": "Rime Input Method Engine, the core library" + } +] diff --git a/thirdparty/rime/README_zh.md b/thirdparty/rime/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..93daf4b01de72a26c70e23dadbec394a39f906aa --- /dev/null +++ b/thirdparty/rime/README_zh.md @@ -0,0 +1,15 @@ +# rime三方库说明 +## 功能简介 + rime是一款开源的输入法引擎框架。 + +## 三方库版本 +- 1.13.0 + +## 已适配功能 +- 支持rime库的功能。 + +## 使用约束 +- [IDE和SDK版本](../../docs/constraint.md) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/rime/SHA512SUM b/thirdparty/rime/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..892f12012e78fed3c18f8adb552d462efa59b4f3 --- /dev/null +++ b/thirdparty/rime/SHA512SUM @@ -0,0 +1 @@ +0b9d4c1ee11af4628616003e38b5c6ed66e16b0c353f16b3fc6cf419d99787fb78bf82b027ffdfb16990c84828df166efd61f4a7e2b1c8627bc3a3d5b7c5b557 1.13.0.tar.gz \ No newline at end of file diff --git a/thirdparty/rime/docs/hap_integrate.md b/thirdparty/rime/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..28d34baa22f9ee0f0e9f5cf8be3ea5da58f22cbf --- /dev/null +++ b/thirdparty/rime/docs/hap_integrate.md @@ -0,0 +1,113 @@ +# rime集成到应用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) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/rime #三方库rime的目录结构如下 + ├── docs # 三方库相关文档的文件夹 + ├── HPKBUILD # 构建脚本 + ├── HPKCHECK # 测试脚本 + ├── SHA512SUM # 三方库校验文件 + ├── README.OpenSource # 说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md # 三方库说明文档 + ├── OAT.xml # OAT开源审查文本 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh rime + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + rime/arm64-v8a rime/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 +   + + ![thirdparty_install_dir](pic/rime_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/boost/${OHOS_ARCH}") + set(GLOG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/${OHOS_ARCH}") + set(YAML_CPP_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/yaml-cpp/${OHOS_ARCH}") + set(LEVELDB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/leveldb/${OHOS_ARCH}") + set(MARISA_TRIE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/marisa-trie/${OHOS_ARCH}") + set(OPENCC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/OpenCC/${OHOS_ARCH}") + set(RIME_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/rime/${OHOS_ARCH}") + + include_directories( + ${BOOST_ROOT}/include + ${GLOG_ROOT}/include + ${YAML_CPP_ROOT}/include + ${LEVELDB_ROOT}/include + ${MARISA_TRIE_ROOT}/include + ${OPENCC_ROOT}/include + ${RIME_ROOT}/include + ) + + # 链接库路径 + link_directories( + ${BOOST_ROOT}/lib + ${GLOG_ROOT}/lib + ${YAML_CPP_ROOT}/lib + ${LEVELDB_ROOT}/lib + ${MARISA_TRIE_ROOT}/lib + ${OPENCC_ROOT}/lib + ${RIME_ROOT}/lib + ) + + target_link_libraries(entry PUBLIC + ${BOOST_ROOT}/lib/libboost_regex.a + ${GLOG_ROOT}/lib/libglog.so.1 + ${YAML_CPP_ROOT}/lib/libyaml-cpp.a + ${LEVELDB_ROOT}/lib/libleveldb.a + ${MARISA_TRIE_ROOT}/lib/libmarisa.so.0 + ${OPENCC_ROOT}/lib/libopencc.so.1.1 + ${RIME_ROOT}/lib/librime.so.1 + ) + ``` + +## 测试三方库 + +进入到构建目录执行(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) +```shell +export LD_LIBRARY_PATH=/data/tpc_c_cplusplus/lycium/usr/OpenCC/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/boost/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/gflags/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/glog/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/googletest/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/leveldb/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/marisa-trie/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/rime/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/snappy/arm64-v8a/lib:/data/tpc_c_cplusplus/lycium/usr/yaml-cpp/arm64-v8a/lib:$LD_LIBRARY_PATH #设置运行时链接动态库的地址 +ctest #执行测试用例 +``` + + ![rime_test](pic/rime_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/rime/docs/pic/rime_install_dir.png b/thirdparty/rime/docs/pic/rime_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..7f109b8dae2b67e63c4a1d349e71946342259880 Binary files /dev/null and b/thirdparty/rime/docs/pic/rime_install_dir.png differ diff --git a/thirdparty/rime/docs/pic/rime_test.png b/thirdparty/rime/docs/pic/rime_test.png new file mode 100644 index 0000000000000000000000000000000000000000..00fdd803ab8dd369fb4258d082c836f79239951d Binary files /dev/null and b/thirdparty/rime/docs/pic/rime_test.png differ diff --git a/thirdparty/rime/docs/pic/rime_usage.png b/thirdparty/rime/docs/pic/rime_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..1b20222e93d5f93a7da0eeb39702bd9f3e1052fc Binary files /dev/null and b/thirdparty/rime/docs/pic/rime_usage.png differ