diff --git a/thirdparty/libssh2/HPKBUILD b/thirdparty/libssh2/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..74cb743689cf56b59c427edcdfdf09a71b3e44be --- /dev/null +++ b/thirdparty/libssh2/HPKBUILD @@ -0,0 +1,51 @@ +# Contributor: huangminzhong2 +# Maintainer: huangminzhong2 + +pkgname=libssh2 +pkgver=libssh2-1.11.0 +pkgrel=0 +pkgdesc="libssh is a lightweight SSH client library." +url="https://github.com/libssh2/libssh2" +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD Licensed") +depends=("openssl") +makedepends=() +install= +source="https://github.com/$pkgname/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +downloadpackage=true +autounpack=true +patchflag=true +buildtools="cmake" +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +prepare() { + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > $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!" +} + +# 清理环境 +cleanbuild() { + rm -rf ${PWD}/$builddir ${PWD}/$packagename +} diff --git a/thirdparty/libssh2/HPKCHECK b/thirdparty/libssh2/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..ac88ebdf631b84b7d8345b1b0b500df8b4b112fe --- /dev/null +++ b/thirdparty/libssh2/HPKCHECK @@ -0,0 +1,19 @@ +# Contributor: huangminzhong2 +# Maintainer: huangminzhong2 + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +openharmonycheck() { + cd $builddir/$ARCH-build + ctest > ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + mkdir -p $LYCIUM_FAULT_PATH/$pkgname + cp Testing/Temporary/LastTest.log $LYCIUM_FAULT_PATH/$pkgname + fi + cd $OLDPWD + + return $res +} diff --git a/thirdparty/libssh2/OAT.xml b/thirdparty/libssh2/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c910b32a0f5cab1461a8807c1f474d998359e04 --- /dev/null +++ b/thirdparty/libssh2/OAT.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/thirdparty/libssh2/README.OpenSource b/thirdparty/libssh2/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..8c526dcca40e1a191f91e8ed8a07f5d3bfd8efec --- /dev/null +++ b/thirdparty/libssh2/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libssh2", + "License": "BSD", + "License File": "LICENSE", + "Version Number": "libssh2-1.11.0", + "Owner": "huangminzhong2@huawei.com", + "Upstream URL": "https://github.com/libssh2/libssh2/archive/refs/tags/libssh2-1.11.0.tar.gz", + "Description": "libssh2 is a library implementing the SSH2 protocol, available under the revised BSD license." + } +] diff --git a/thirdparty/libssh2/README_zh.md b/thirdparty/libssh2/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..4039503bab3de1c5bb72022a2d7a4a244158d758 --- /dev/null +++ b/thirdparty/libssh2/README_zh.md @@ -0,0 +1,11 @@ +# libssh2三方库说明 +## 功能简介 +libssh2是一个实现SSH2协议的库,可以在修订后的BSD许可下使用。 +## 使用约束 +- IDE版本:DevEco Studio 4.1.3 Release +- SDK版本:ohos_sdk_public 5.0.3.100 (API Version 10 Release) +- 三方库版本:libssh2-1.11.0 +- 当前适配的功能:支持向量机 + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/libssh2/SHA512SUM b/thirdparty/libssh2/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..afd7378f665354b55f274d7a2ca6050fdd4e1de1 --- /dev/null +++ b/thirdparty/libssh2/SHA512SUM @@ -0,0 +1 @@ +8ae38d76e7fae82843c7c6990760ad5827cb55e2aba096f684b832016614d76983d1871ae0857ba28efcb9fd65018ae0b34420f6841da6bb6c6ccebd9689ec0f libssh2-libssh2-1.11.0.tar.gz \ No newline at end of file diff --git a/thirdparty/libssh2/docs/hap_integrate.md b/thirdparty/libssh2/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..b43fca6695b69e665c67a4e0297fd022ae06a0c7 --- /dev/null +++ b/thirdparty/libssh2/docs/hap_integrate.md @@ -0,0 +1,89 @@ +# libssh2集成到应用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/libssh2 #三方库libssh2的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本、license等信息 + ├── README_zh.md + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh libssh2 + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + libssh2/arm64-v8a libssh2/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 需要将libssh2生成的so动态库文件下图所示拷贝到entry/libs目录下 + +- ![thirdparty_install_dir](pic/libssh2_so_ide.png) + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库的头文件及将其依赖库头文件和依赖库静态库拷贝到该目录下,如下图所示 + +- ![thirdparty_install_dir](pic/libssh2_include_ide.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```cmake +#将三方库的头文件和库文件加入工程中 +target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libssh2/${OHOS_ARCH}/include) +target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libssh2.so.1) + +#将三方库依赖的库的头文件和库文件加入工程中 +target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH}/lib/libssl.a) +target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH}/lib/libcrypto.a) +target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH}/include) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + + + +进入库文件到解压文件夹内编译生产目录下,使用ctest进行测试 +编译生成目录:libssh2/libssh2-libssh2-1.11.0/armeabi-v7a-build/tests +执行:ctest + ![thirdparty_install_dir](pic/test.png) + +失败原因是网络请求超时及请求次数超过指定最大次数 + + ![thirdparty_install_dir](pic/test_result.png) + +## 参考资料 + +- [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/libssh2/docs/pic/libssh2_include_ide.png b/thirdparty/libssh2/docs/pic/libssh2_include_ide.png new file mode 100644 index 0000000000000000000000000000000000000000..08b16df49d7bb6fb7c68badc9795cd20442d68b1 Binary files /dev/null and b/thirdparty/libssh2/docs/pic/libssh2_include_ide.png differ diff --git a/thirdparty/libssh2/docs/pic/libssh2_lib_ide.png b/thirdparty/libssh2/docs/pic/libssh2_lib_ide.png new file mode 100644 index 0000000000000000000000000000000000000000..15d832c2e817501920c79c88c084d9e13cf6a597 Binary files /dev/null and b/thirdparty/libssh2/docs/pic/libssh2_lib_ide.png differ diff --git a/thirdparty/libssh2/docs/pic/test.png b/thirdparty/libssh2/docs/pic/test.png new file mode 100644 index 0000000000000000000000000000000000000000..225804e123174c32df281171eaaeea3e9fef5e9e Binary files /dev/null and b/thirdparty/libssh2/docs/pic/test.png differ diff --git a/thirdparty/libssh2/docs/pic/test_result.png b/thirdparty/libssh2/docs/pic/test_result.png new file mode 100644 index 0000000000000000000000000000000000000000..c7b9d5080a01fe55c8d3c8ad4c0d013bffb41ef2 Binary files /dev/null and b/thirdparty/libssh2/docs/pic/test_result.png differ