diff --git a/thirdparty/marisa-trie/HPKBUILD b/thirdparty/marisa-trie/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..ebab0356b7c5b134b8816a52ae7ade8aed099195 --- /dev/null +++ b/thirdparty/marisa-trie/HPKBUILD @@ -0,0 +1,95 @@ +# Contributor: lpzhong <278527840@qq.com> +# Maintainer: lpzhong <278527840@qq.com> + +pkgname=marisa-trie +pkgver=v0.2.6 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("LGPL-2.1" "GPL-2.0") +depends=() +makedepends=() +install= +source="https://github.com/s-yata/${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 == "armeabi-v7a" ]; 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 == "arm64-v8a" ]; 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 -i > ./build.log 2>&1 + cd $OLDPWD +} + +build() { + cd $builddir-$ARCH-build + ./configure "$@" --host=$host >> ./build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-$ARCH-build + make install >> ./build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +check() { + cd $builddir-$ARCH-build/tests + ## 编译出测试应用 + make base-test io-test vector-test trie-test marisa-test >> ../build.log 2>&1 + ret=$? + ## 修改测试条件, 使测试时不在进行编译操作 + sed -i "s/check-TESTS: \$(check_PROGRAMS)/check-TESTS: # \$(check_PROGRAMS)/" Makefile + sed -i "s/base-test.log: base-test\$(EXEEXT)/base-test.log: # base-test\$(EXEEXT)/" Makefile + sed -i "s/io-test.log: io-test\$(EXEEXT)/io-test.log: # io-test\$(EXEEXT)/" Makefile + sed -i "s/vector-test.log: vector-test\$(EXEEXT)/vector-test.log: # vector-test\$(EXEEXT)/" Makefile + sed -i "s/trie-test.log: trie-test\$(EXEEXT)/trie-test.log: # trie-test\$(EXEEXT)/" Makefile + sed -i "s/marisa-test.log: marisa-test\$(EXEEXT)/marisa-test.log: # marisa-test\$(EXEEXT)/" Makefile + + 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!" + + ## real test cmd + ## make check-TESTS -C tests + + return $ret +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename + rm -rf ${PWD}/*-build +} diff --git a/thirdparty/marisa-trie/README.OpenSource b/thirdparty/marisa-trie/README.OpenSource new file mode 100755 index 0000000000000000000000000000000000000000..c6071347afeefeda86a9681a426c711c6a677b57 --- /dev/null +++ b/thirdparty/marisa-trie/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "marisa", + "License": "LGPL-2.1/GPL-2.0", + "License File": "COPYING.md", + "Version Number": "v0.2.6", + "Owner": "zhongluping1@huawei.com", + "Upstream URL": "https://github.com/s-yata/marisa-trie", + "Description": " Matching Algorithm with Recursively Implemented StorAge (MARISA) is a static and space-efficient trie data structure" + } +] diff --git a/thirdparty/marisa-trie/README_zh.md b/thirdparty/marisa-trie/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..26afb870ded0596b481d378c9d24b145d495ff87 --- /dev/null +++ b/thirdparty/marisa-trie/README_zh.md @@ -0,0 +1,17 @@ +# marisa 三方库说明 + +## 功能简介 + +marisa 递归存储匹配算法种静态的、节省空间的trie数据结构. + +## 使用约束 + +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:4.0.0 +- 当前适配的功能:提供字典树数据结构算法,用于生成并加载asr字典树. +- [LGPL-2.1/GPL-2.0](https://github.com/s-yata/marisa-trie/blob/master/COPYING.md) + +## 集成方式 + +- [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/marisa-trie/SHA512SUM b/thirdparty/marisa-trie/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..418d25bb637f9452ac8aa686cbc3f6dccc1180f7 --- /dev/null +++ b/thirdparty/marisa-trie/SHA512SUM @@ -0,0 +1 @@ +c094e4b22e1457efdd20f2b978ee421b53e36ed94e4fdbd8944136c0ba23da4f6ba9fe3a2c64729c1426aee4dbe8098bfa5eebb943ae7fdaa4eec760485c564d marisa-trie-0.2.6.tar.gz diff --git a/thirdparty/marisa-trie/docs/hap_integrate.md b/thirdparty/marisa-trie/docs/hap_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..6d5c58a7ccc3a90dbafe22e3ed13fa117f3e493e --- /dev/null +++ b/thirdparty/marisa-trie/docs/hap_integrate.md @@ -0,0 +1,91 @@ +# marisa 集成到应用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/marisa-trie # 三方库marisa的目录结构如下 + ├── docs # 三方库相关文档的文件夹 + ├── HPKBUILD # 构建脚本 + ├── SHA512SUM # 三方库校验文件 + ├── README.OpenSource # 说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将marisa-trie拷贝至tools/main目录下 + + ```shell + cd tpc_c_cplusplus + cp thirdparty/marisa-trie tools/main -rf ## 拷贝marisa三方库到编译目录 + ``` + +- 在tools目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + + ```shell + cd tools ## 进入到编译目录 + ./build.sh marisa-trie ## 编译三方库 + ``` + +- 三方库头文件及生成的库 + + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + marisa-trie/arm64-v8a marisa-trie/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + +  ![thirdparty_install_dir](../../thirdparty_template/docs/pic/xxx_install_dir.png) + + 其中xxx代表的三方库名字,此处即为`marisa-trie`; + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + # 将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/marisa-trie/${OHOS_ARCH}/lib/libmarisa.a) + # 将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/marisa/${OHOS_ARCH}/include) + ``` + + ![marisa_usage](../../thirdparty_template/docs/pic/xxx_usage.png) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行`make check-TESTS -C tests`运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![marisa_test](pic/marisa_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/marisa-trie/docs/pic/jasper_test.png b/thirdparty/marisa-trie/docs/pic/jasper_test.png new file mode 100755 index 0000000000000000000000000000000000000000..edba1b27becd2395583f41e629861d6edd8c9b28 Binary files /dev/null and b/thirdparty/marisa-trie/docs/pic/jasper_test.png differ diff --git a/thirdparty/marisa-trie/docs/pic/marisa_test.png b/thirdparty/marisa-trie/docs/pic/marisa_test.png new file mode 100755 index 0000000000000000000000000000000000000000..b3913a6bddbcb48b9fd89bbdbe3a685af6b3e07d Binary files /dev/null and b/thirdparty/marisa-trie/docs/pic/marisa_test.png differ