diff --git a/thirdparty/leveldb/HPKBUILD b/thirdparty/leveldb/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..cbcf0a58212bcb2b8c0f1129d4a1643967101183 --- /dev/null +++ b/thirdparty/leveldb/HPKBUILD @@ -0,0 +1,74 @@ +# 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=leveldb +pkgver=1.23 +pkgrel=0 +pkgdesc="LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values." +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD-3-Clause") +makedepends=() +source="https://github.com/google/leveldb.git" + +# 1.23.0版本对应的commitid +commitid=99b3c03b3284f5886f9ef9a4ef703d57373e61be + +downloadpackage=false +autounpack=false +builddir=$pkgname-${pkgver} +cloneflag=true +buildtools="cmake" + +prepare() { + if $cloneflag + then + git clone --recurse-submodules -b $pkgver $source $builddir > $publicbuildlog 2>&1 + if [ $? -ne 0 ] + then + return -1 + fi + cloneflag=false + fi + + 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 + ret=$? + cd $OLDPWD + return $ret +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +cleanbuild() { + rm -rf ${PWD}/$builddir + return $ret +} diff --git a/thirdparty/leveldb/HPKCHECK b/thirdparty/leveldb/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..156470c0250cf852cbefb71ad4aae8aa0fbd7eba --- /dev/null +++ b/thirdparty/leveldb/HPKCHECK @@ -0,0 +1,33 @@ +# 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 + export TEST_TMPDIR=/data/local/tmp/ + 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/leveldb/README.OpenSource b/thirdparty/leveldb/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..e55a5e0d6374ccc7e28c2d31de3d4c8a82ba7125 --- /dev/null +++ b/thirdparty/leveldb/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "leveldb", + "License": "BSD-3-Clause license", + "License File": "https://github.com/google/leveldb/blob/main/LICENSE", + "Version Number": "v1.23.0", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/google/leveldb", + "Description": "LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values." + } +] diff --git a/thirdparty/leveldb/README_zh.md b/thirdparty/leveldb/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..1f3443af43ecaa75ea33c8d8af6ba59d6ec3be4d --- /dev/null +++ b/thirdparty/leveldb/README_zh.md @@ -0,0 +1,15 @@ +# leveldb三方库说明 +## 功能简介 + leveldb是一款快速键值存储库,它提供了从字符串键到字符串值的有序映射。 + +## 三方库版本 +- v1.23.0 + +## 已适配功能 +- 支持leveldb的增删改查等数据库功能。 + +## 使用约束 +- [IDE和SDK版本](../../docs/constraint.md) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/leveldb/docs/hap_integrate.md b/thirdparty/leveldb/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..04e00be6f3e66a2eadc1d04cf4bc60c94d0ce1bf --- /dev/null +++ b/thirdparty/leveldb/docs/hap_integrate.md @@ -0,0 +1,76 @@ +# leveldb集成到应用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/leveldb #三方库leveldb的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh leveldb + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + leveldb/arm64-v8a leveldb/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 +   + + ![thirdparty_install_dir](pic/leveldb_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libleveldb.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/leveldb/${OHOS_ARCH}/include) + ``` + +## 测试三方库 + +进入到构建目录执行(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) +```shell +export TEST_TMPDIR=/data/local/tmp/ #设置有读写权限的目录作为测试目录 +ctest #执行测试用例 +``` + + ![leveldb_test](pic/leveldb_test_1.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/leveldb/docs/pic/leveldb_install_dir.png b/thirdparty/leveldb/docs/pic/leveldb_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..3c9198c14a3a50c44e2f4709afa8dd05039c9392 Binary files /dev/null and b/thirdparty/leveldb/docs/pic/leveldb_install_dir.png differ diff --git a/thirdparty/leveldb/docs/pic/leveldb_test_1.png b/thirdparty/leveldb/docs/pic/leveldb_test_1.png new file mode 100644 index 0000000000000000000000000000000000000000..eb66ec9dbb9573de10137dd9008310346c07d52c Binary files /dev/null and b/thirdparty/leveldb/docs/pic/leveldb_test_1.png differ diff --git a/thirdparty/leveldb/docs/pic/leveldb_usage.png b/thirdparty/leveldb/docs/pic/leveldb_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..ac98c85f5b81ccfe81c29b027b3c10d31c1b1cda Binary files /dev/null and b/thirdparty/leveldb/docs/pic/leveldb_usage.png differ