diff --git a/thirdparty/hunspell/HPKBUILD b/thirdparty/hunspell/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..8ef04ba33f4fa78266efbee27c5c3cc1af823d1f --- /dev/null +++ b/thirdparty/hunspell/HPKBUILD @@ -0,0 +1,79 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=hunspell +pkgver=v1.7.2 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license="LGPL-2.1 GPL-2.0" +depends=() +makedepends=() +install= +source="https://github.com/hunspell/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +source envset.sh +host= +prepare() { + cp -arf $builddir $builddir-$ARCH-build + if [ $ARCH == ${archs[0]} ] + then + setarm32ENV + host=arm-linux + export LDFLAGS="${OHOS_SDK}/native/llvm/lib/clang/12.0.1/lib/arm-linux-ohos/a7_hard_neon-vfpv4/libclang_rt.builtins.a ${LDFLAGS}" + fi + if [ $ARCH == ${archs[1]} ] + then + setarm64ENV + host=aarch64-linux + export LDFLAGS="${OHOS_SDK}/native/llvm/lib/clang/12.0.1/lib/aarch64-linux-ohos/libclang_rt.builtins.a ${LDFLAGS}" + fi + cd $builddir-$ARCH-build + autoreconf -ifv > `pwd`/build.log 2>&1 + cd $OLDPWD +} + +build() { + cd $builddir-$ARCH-build + ./configure "$@" --host=$host >> `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-$ARCH-build + make install >> `pwd`/build.log 2>&1 + cd $OLDPWD + if [ $ARCH == ${archs[0]} ] + then + unsetarm32ENV + fi + if [ $ARCH == ${archs[1]} ] + then + unsetarm64ENV + fi + + unset host +} + +check() { + echo "The test must be on an OpenHarmony device!" + + ## real test CMD + ## 进入到编译目录执行 + ## make check-TESTS -C tests +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir ${PWD}/$builddir-${archs[0]}-build ${PWD}/$builddir-${archs[1]}-build #${PWD}/$packagename +} diff --git a/thirdparty/hunspell/README.OpenSource b/thirdparty/hunspell/README.OpenSource new file mode 100755 index 0000000000000000000000000000000000000000..eeb45f4ff1a39f03991a007723a3f34a2ca10f03 --- /dev/null +++ b/thirdparty/hunspell/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "hunspell", + "License": "LGPL-2.1/GPL-2.0 License", + "License File": "COPYING.LESSER", + "Version Number": "v1.7.2", + "Owner": "zhongluping1@huawei.com", + "Upstream URL": "https://github.com/hunspell/hunspell/tree/v1.7.2", + "Description": "Hunspell is a free spell checker and morphological analyzer library and command-line tool" + } +] diff --git a/thirdparty/hunspell/README_zh.md b/thirdparty/hunspell/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..4123db3c6d4b6097d18ff86eede1c17cb5a547a7 --- /dev/null +++ b/thirdparty/hunspell/README_zh.md @@ -0,0 +1,17 @@ +# hunspell 三方库说明 + +## 功能简介 + +hunspell 是一个免费的拼写检查器和形态分析器库和命令行工具. + +## 使用约束 + +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v1.7.2 +- 当前适配的功能:支持拼写检查以及形态分析。 +- [LGPL-2.1/GPL-2.0 License](https://github.com/hunspell/hunspell/blob/master/COPYING.LESSER) + +## 集成方式 + +- [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/hunspell/SHA512SUM b/thirdparty/hunspell/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..83160010cc83cbb9da5d61d13366085a2a7acc82 --- /dev/null +++ b/thirdparty/hunspell/SHA512SUM @@ -0,0 +1 @@ +d007edc8cb7ff95048361418b088bb062962973247c940aa826c9859a5ef90a9734100bffe7c7ac9a774f2e233605e814efb9e7fd3fc8c4ef4b978e9ec990cba hunspell-1.7.2.tar.gz \ No newline at end of file diff --git a/thirdparty/hunspell/docs/hap_integrate.md b/thirdparty/hunspell/docs/hap_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..737f132d052a5cb0c3cc6e844234425ccbdfce61 --- /dev/null +++ b/thirdparty/hunspell/docs/hap_integrate.md @@ -0,0 +1,88 @@ +# hunspell 集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/hunspell #三方库hunspell的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将hunspell拷贝至tools/main目录下 + + ```shell + cd tpc_c_cplusplus + cp thirdparty/hunspell tools/main -rf + ``` + +- 在tools目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + + ```shell + cd tools + ./build.sh hunspell + ``` + +- 三方库头文件及生成的库 + + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + hunspell/arm64-v8a hunspell/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 +  ![thirdparty_install_dir](pic/hunspell_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/hunspell/${OHOS_ARCH}/lib/libhunspell-1.7.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/hunspell/${OHOS_ARCH}/include) + ``` + + ![hunspell_usage](pic/hunspell_usage.png) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行make check-TEST -C ./tests 运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![hunspell_test](pic/hunspell_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/hunspell/docs/pic/hunspell_install_dir.png b/thirdparty/hunspell/docs/pic/hunspell_install_dir.png new file mode 100755 index 0000000000000000000000000000000000000000..25cbbc722e5307cadd1b59edef21820a12fbfd96 Binary files /dev/null and b/thirdparty/hunspell/docs/pic/hunspell_install_dir.png differ diff --git a/thirdparty/hunspell/docs/pic/hunspell_test.png b/thirdparty/hunspell/docs/pic/hunspell_test.png new file mode 100755 index 0000000000000000000000000000000000000000..fe4c14f0904774447d4ea856d5992e56eb3f8753 Binary files /dev/null and b/thirdparty/hunspell/docs/pic/hunspell_test.png differ diff --git a/thirdparty/hunspell/docs/pic/hunspell_usage.png b/thirdparty/hunspell/docs/pic/hunspell_usage.png new file mode 100755 index 0000000000000000000000000000000000000000..7cf91ecf78b0a8869011a6245f52ec61c28263d0 Binary files /dev/null and b/thirdparty/hunspell/docs/pic/hunspell_usage.png differ