diff --git a/thirdparty/thrift/HPKBUILD b/thirdparty/thrift/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..a282a0a8cd5805cf9a91b6fc09fdca5789e7c434 --- /dev/null +++ b/thirdparty/thrift/HPKBUILD @@ -0,0 +1,60 @@ +# Contributor: lpzhong <278527840@qq.com> +# Maintainer: lpzhong <278527840@qq.com> +pkgname=thrift +pkgver=v0.18.1 +pkgrel=0 +pkgdesc="Thrift is a lightweight, language-independent software stack for point-to-point RPC implementation" +url="https://github.com/apache/thrift" +archs=("armeabi-v7a" "arm64-v8a") +license="Apache License" +depends=("boost" "openssl" "zlib") +makedepends=() +source="https://github.com/apache/${pkgname}/archive/refs/tags/${pkgver}.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="cmake" +buildhostthrift=true + +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +prepare() { + if [ $buildhostthrift ]; then + mkdir -p ${builddir}/host-build + cd ${builddir}/host-build + cmake -DWITH_JAVA=OFF -DWITH_JAVASCRIPT=OFF -DWITH_NODEJS=OFF -DWITH_C_GLIB=OFF -DWITH_PYTHON=OFF .. -L > build.log 2>&1 + make -j4 >> build.log 2>&1 + buildhostthrift=false + cd $OLDPWD + fi + + mkdir -p ${builddir}/${ARCH}-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -B$ARCH-build -DWITH_LIBEVENT=OFF -DWITH_HASKELL=OFF -DWITH_JAVA=OFF -DWITH_JAVASCRIPT=OFF -DWITH_NODEJS=OFF -DTHRIFT_COMPILER=`pwd`/host-build/compiler/cpp/bin/thrift -DWITH_C_GLIB=OFF -DWITH_PYTHON=OFF -B${ARCH}-build -S./ -L > `pwd`/${ARCH}-build/build.log 2>&1 + make VERBOSE=1 -j4 -C ${ARCH}-build >> `pwd`/${ARCH}-build/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd ${builddir} + make -C ${ARCH}-build install >> `pwd`/${ARCH}-build/build.log 2>&1 + cd $OLDPWD +} + +check() { + echo "The test must be on an OpenHarmony device!" + # real test CMD + # 进入到编译目录执行[说明:测试时设备需要连接网络] + # ctest +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/${builddir} # ${PWD}/$packagename +} diff --git a/thirdparty/thrift/OAT.xml b/thirdparty/thrift/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..0685541437fc605eb6681e70c1aa4069e1114fc0 --- /dev/null +++ b/thirdparty/thrift/OAT.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/thrift/README.OpenSource b/thirdparty/thrift/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..aadfc01cec4b5da63634f909d7d595fcea3d32e7 --- /dev/null +++ b/thirdparty/thrift/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "thrift", + "License": "Apache License 2.0", + "License File": "https://github.com/apache/thrift/blob/master/LICENSE", + "Version Number": "v0.18.1", + "Owner": "swkec@isoftstone.com", + "Upstream URL": "https://github.com/apache/thrift/archive/refs/tags/v0.18.1.tar.gz", + "Description": "Thrift is an interface description language and binary communication protocol used to define and create cross-language services. It is designed as a remote procedure call (RPC) framework and was developed by Facebook for "large-scale cross-language service development"." + } +] diff --git a/thirdparty/thrift/README_zh.md b/thirdparty/thrift/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..363ac57415ec12000a03047c1ec5075ee4d9c53e --- /dev/null +++ b/thirdparty/thrift/README_zh.md @@ -0,0 +1,12 @@ +# thrift三方库说明 +## 功能简介 +Thrift是一种接口描述语言和二进制通讯协议,它被用来定义和创建跨语言的服务。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v0.18.1 +- 当前适配的功能:支持跨语言服务创建、数据传输和远程过程调用的高性能二进制协议 +- [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/thrift/SHA512SUM b/thirdparty/thrift/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..4dbfcfc6f547f2a6e1a57433fb6ebad5e192a6de --- /dev/null +++ b/thirdparty/thrift/SHA512SUM @@ -0,0 +1 @@ +16d1863e1eceb7b35e74d52aa14aab81641e779a3ed5cb668ef25e72d4a7adc2d7574d1597c07d779ea42e9f3240ac44446eef819bbfed0f7a2f6380f755f534 thrift-0.18.1.tar.gz diff --git a/thirdparty/thrift/docs/hap_integrate.md b/thirdparty/thrift/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..ac05a6ca5f8f11817ccda65b1016dad5716b0583 --- /dev/null +++ b/thirdparty/thrift/docs/hap_integrate.md @@ -0,0 +1,86 @@ +# thrift集成到应用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环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/thrift #三方库thrift的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将thrift拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/thrift tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh boost openssl zlib thrift + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + thrift/arm64-v8a thrift/armeabi-v7a + boost/arm64-v8a boost/armeabi-v7a + openssl/arm64-v8a openssl/armeabi-v7a + zlib/arm64-v8a zlib/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/thrift_install_dir.jpg) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libboost_atomic.so.1.81.0) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libboost_chrono.so.1.81.0) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libboost_container.so.1.81.0) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libboost_context.so.1.81.0) + ... + + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/thrift/${OHOS_ARCH}/include) + ``` + ![thrift_usage](pic/thrift_usage.jpg) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +- 将编译生成的可执行文件及生成的动态库准备好 + +- 将准备好的文件推送到开发板,在windows命令行进行如下操作 + + ``` + hdc_std shell mount -o remount,rw / #修改系统权限为可读写 + hdc_std file send libc++_shared.so /system/lib + ... + hdc_std shell #进入开发板 + chmod 777 * #添加权限 + ctest #执行测试用例 + ``` + + ![thrift_test](pic/thrift_test.jpg) +StalenessCheckTest测试选项需要依赖python环境,导致测试错误 +## 参考资料 +- [润和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/thrift/docs/pic/thrift_install_dir.jpg b/thirdparty/thrift/docs/pic/thrift_install_dir.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c6522b0c83bd03ba8cf105cd2fa7fd3424f309a0 Binary files /dev/null and b/thirdparty/thrift/docs/pic/thrift_install_dir.jpg differ diff --git a/thirdparty/thrift/docs/pic/thrift_test.jpg b/thirdparty/thrift/docs/pic/thrift_test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..66bd5daffa02d324611de139fc3598354d4175e3 Binary files /dev/null and b/thirdparty/thrift/docs/pic/thrift_test.jpg differ diff --git a/thirdparty/thrift/docs/pic/thrift_usage.jpg b/thirdparty/thrift/docs/pic/thrift_usage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..73d9ef8340d897db3f5a8d447609cecba2c5f915 Binary files /dev/null and b/thirdparty/thrift/docs/pic/thrift_usage.jpg differ