diff --git a/thirdparty/libdivsufsort/HPKBUILD b/thirdparty/libdivsufsort/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..b242527998f0d3cc66efe82cea99a6eb710c6fcb --- /dev/null +++ b/thirdparty/libdivsufsort/HPKBUILD @@ -0,0 +1,65 @@ +# Copyright (c) 2023 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: wangjialun <2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn> , wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +pkgname=libdivsufsort +pkgver=2.0.0 +pkgrel=0 +pkgdesc="libdivsufsort is a lightweight suffix-sorting library." +url="https://github.com/y-256/libdivsufsort/tree/2.0.0" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT license") +depends=() +makedepends=() +source="https://github.com/y-256/libdivsufsort/archive/refs/tags/2.0.0.zip" + +downloadpackage=true +autounpack=true +buildtools=cmake + +builddir=libdivsufsort-2.0.0 +packagename=libdivsufsort-2.0.0.zip + +prepare() { + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DCMAKE_C_FLAGS="-Wno-unused-command-line-argument" \ + -DCMAKE_CXX_FLAGS="-Wno-unused-command-line-argument" -B$ARCH-build -S./ > $buildlog 2>&1 + $MAKE VERBOSE=1 -C $ARCH-build >> $buildlog 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + $MAKE -C $ARCH-build install >> $buildlog 2>&1 + cd $OLDPWD +} + + +check() { + echo "The test must be on an OpenHarmony device!" + # 在OpenHarmony开发板中执行一个demo用例 + # ./suftest test.txt +} + + +cleanbuild() { + rm -rf ${PWD}/$builddir +} \ No newline at end of file diff --git a/thirdparty/libdivsufsort/HPKCHECK b/thirdparty/libdivsufsort/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..aa09b483a384772608a6cb797b4217122dfb2991 --- /dev/null +++ b/thirdparty/libdivsufsort/HPKCHECK @@ -0,0 +1,51 @@ +# Copyright (c) 2023 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: wangjialun <2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn> , wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +source HPKBUILD > /dev/null 2>&1 # 导入HPKBUILD文件 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +# 在OH环境执行测试的接口 +openharmonycheck() { + res=0 + cd ${builddir}/${ARCH}-build/example # 进入到对应架构目录下的/example目录 + # 该库没有测试用例,因此执行一个demo:该库构建目录下的/sample文件夹里放有对应功能的二进制文件,验证该库功能: + #执行 ./suftest test.txt。(test.txt文件是自行准备的,内容:AGCTATAG) + #./suftest test.txt 功能为:计算test.txt文件包含的字节数、构建后缀数组,并对其构建的后缀数组进行检查。 + #检查后缀数组构建成功的标志为:输出“sufcheck: Done." + ./suftest test.txt >> $logfile 2>&1 + res=$? + # 检查是否有输出 + if [ -s $logfile ]; then + # 检查日志文件中是否包含 "sufcheck: Done." + if grep -q "sufcheck: Done." $logfile; then + echo "Test passed: 'sufcheck: Done.' found in the log." >> $logfile + else + echo "Test failed: 'sufcheck: Done.' not found in the log." >> $logfile + res=1 + fi + else + # 若无输出,则测试失败 + echo "Test failed: No output from the test." >> $logfile + res=1 + fi + #保存测试失败日志 + if [ $res -ne 0 ]; then + mkdir -p ${LYCIUM_FAULT_PATH}/${pkgname} + cp Testing/Temporary/LastTest.log ${LYCIUM_FAULT_PATH}/${pkgname}/test_failed.log + fi + cd $OLDPWD + return $res +} \ No newline at end of file diff --git a/thirdparty/libdivsufsort/README.OpenSource b/thirdparty/libdivsufsort/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..3b208dfb9827d8aa8847cfe103274fe104bec275 --- /dev/null +++ b/thirdparty/libdivsufsort/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libdivsufsort", + "License": "MIT license", + "License File": "https://github.com/y-256/libdivsufsort/blob/master/LICENSE", + "Version Number": "2.0.0", + "Owner": "2942375747@qq.com", + "Upstream URL": "https://github.com/y-256/libdivsufsort", + "Description": "libdivsufsort is a lightweight suffix-sorting library." + } +] \ No newline at end of file diff --git a/thirdparty/libdivsufsort/README_zh.md b/thirdparty/libdivsufsort/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f22fbcd22fbb769a568154be803fbf98f8cd85b3 --- /dev/null +++ b/thirdparty/libdivsufsort/README_zh.md @@ -0,0 +1,9 @@ +# libdivsufsort三方库说明 +## 功能简介 +libdivsufsort是一个轻量级的后缀排序库。 +## 三方库版本: +- 2.0.0 +## 使用约束: +- [IDE和SDK版本](../../docs/constraint.md) +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) \ No newline at end of file diff --git a/thirdparty/libdivsufsort/SHA512SUM b/thirdparty/libdivsufsort/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..2ff72788cc453b7c6449021e17a33e69566c3b7d --- /dev/null +++ b/thirdparty/libdivsufsort/SHA512SUM @@ -0,0 +1 @@ +54007c542ae2859fcdbcad8d04759a92b62ce41d345f436f5e73311e57791ae63a01905d971cacc41db95ba5f5d24489d502cbdcfc743a391ee67fef5ac50ba1 libdivsufsort-2.0.0.zip \ No newline at end of file diff --git a/thirdparty/libdivsufsort/docs/hap_integrate.md b/thirdparty/libdivsufsort/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..9cd8923d7c85690c95629423a5a2177125032f76 --- /dev/null +++ b/thirdparty/libdivsufsort/docs/hap_integrate.md @@ -0,0 +1,80 @@ +# libdivsufsort 集成到应用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/libdivsufsort #三方库libdivsufsort的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库简介 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh libdivsufsort + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + libdivsufsort/arm64-v8a libdivsufsort/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的头文件和库文件拷贝到该目录下,将编译生成的动态库(动态库名字带版本号和不带版本号的都需要)拷贝到工程的libs目录下,如下图所示: +   + +  ![thirdparty_install_dir](pic/libdivsufsort_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libdivsufsort/${OHOS_ARCH}/lib/libdivsufsort.so) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libdivsufsort/${OHOS_ARCH}/include) + ``` + +## 测试三方库 +- 编译出可执行的文件,使用原库自带的测试用例来做测试.但本库没有测试用例,改为执行一个demo [准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +- 进入到构建目录下的example目录,运行demo(注意arm64-v8a为构建64位的目录,armeabi-v7a为构建32位的目录)。该库构建目录下的/sample文件夹里放有对应功能的二进制文件,验证该库功能:执行 ./suftest test.txt。(test.txt文件是自行准备的,内容:AGCTATAG) +- suftest功能:计算test.txt文件包含的字节数,并且构建后缀数组,对其构建的后缀数组进行检查。 + 执行结果如图所示: + +```shell + cd /data/tpc_c_cplusplus/thirdparty/libdivsufsort-2.0.0/libdivsufsort-2.0.0/arm64-v8a-build/example + ./suftest test.txt +``` + ![libdivsufsort_test](pic/libdivsufsort_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) \ No newline at end of file diff --git a/thirdparty/libdivsufsort/docs/pic/libdivsufsort_install_dir.png b/thirdparty/libdivsufsort/docs/pic/libdivsufsort_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..5ad9891d9ffa4f8fd9382481dd23fc140c2d9d71 Binary files /dev/null and b/thirdparty/libdivsufsort/docs/pic/libdivsufsort_install_dir.png differ diff --git a/thirdparty/libdivsufsort/docs/pic/libdivsufsort_test.png b/thirdparty/libdivsufsort/docs/pic/libdivsufsort_test.png new file mode 100644 index 0000000000000000000000000000000000000000..ab1f65848a148130f2792e97f1ce5c1e211e5eec Binary files /dev/null and b/thirdparty/libdivsufsort/docs/pic/libdivsufsort_test.png differ