diff --git a/thirdparty/websocketpp/HPKBUILD b/thirdparty/websocketpp/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..dba998cc9e866efb28bd0200ce887eb09ff51083 --- /dev/null +++ b/thirdparty/websocketpp/HPKBUILD @@ -0,0 +1,58 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=websocketpp +pkgver=0.8.2 +pkgrel=0 +pkgdesc="C++ websocket client/server library" +url="https://github.com/zaphoyd/websocketpp" +archs=("armeabi-v7a" "arm64-v8a") +license=("Peter Thorson. All rights reserved") +depends=("openssl" "boost") +makedepends=() + +source="https://github.com/zaphoyd/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +patchflag=true + +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +prepare() { + if $patchflag + then + cd $builddir + patch -p1 < `pwd`/../websocketpp_oh_pkg.patch + # patch只需要打一次,关闭打patch + patchflag=false + cd $OLDPWD + fi + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DBoost_NO_BOOST_CMAKE=ON -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > `pwd`/$ARCH-build/build.log 2>&1 + make -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/websocketpp/README.OpenSource b/thirdparty/websocketpp/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..c6fd4ed7a4fd09cd0cd42c29b31ed696fcfb9974 --- /dev/null +++ b/thirdparty/websocketpp/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "websocketpp", + "License": "Peter Thorson. All rights reserved", + "License File": "COPYING", + "Version Number": "0.8.2", + "Owner": "hanjinfei@foxmail.com", + "Upstream URL": "https://github.com/zaphoyd/websocketpp/archive/refs/tags/0.8.2.tar.gz", + "Description": "C++ websocket client/server library" + } +] diff --git a/thirdparty/websocketpp/README_zh.md b/thirdparty/websocketpp/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..4fd832b98c8bc77205701db30e4c380333a42117 --- /dev/null +++ b/thirdparty/websocketpp/README_zh.md @@ -0,0 +1,12 @@ +# websocketpp三方库说明 +## 功能简介 +websocketpp是一个用于像素操作的低级软件库,提供图像合成和梯形光栅化等功能。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:0.8.2 +- 当前适配的功能:像素操作,图像合成,光栅化 +- [ Peter Thorson. All rights reserved ](https://github.com/zaphoyd/websocketpp/blob/master/COPYING) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/websocketpp/SHA512SUM b/thirdparty/websocketpp/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..2904523a72ff0d0d83de27e3393179bcda272066 --- /dev/null +++ b/thirdparty/websocketpp/SHA512SUM @@ -0,0 +1,2 @@ +b2afc63edb69ce81a3a6c06b3d857b3e8820f0e22300ac32bb20ab30ff07bd58bd5ada3e526ed8ab52de934e0e3a26cad2118b0e68ecf3e5e9e8d7101348fd06 websocketpp-0.8.2.tar.gz +03e81f1e1e3a89518b2f3dc29850a290af6d4f0d99d9994b1eff61818d2ff33b9aac766ad2210d0a90c7076b04fae3edf24670c9c2e0c74c09c2590641170cd4 websocketpp_oh_pkg.patch diff --git a/thirdparty/websocketpp/docs/hap_integrate.md b/thirdparty/websocketpp/docs/hap_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..fe479576cd1ccdaabe42e130c57bd735a00b1cb7 --- /dev/null +++ b/thirdparty/websocketpp/docs/hap_integrate.md @@ -0,0 +1,70 @@ +# websocketpp集成到应用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/websocketpp #三方库websocketpp的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将websocketpp拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/websocketpp tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh websocketpp + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + websocketpp/arm64-v8a websocketpp/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录 +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/websocketpp_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + + + # websocketpp 是一个纯头文件库,将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include/websocketpp/${OHOS_ARCH}) + + ``` + ![websocketpp_usage](pic/websocketpp_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![websocketpp_test](pic/websocketpp_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/websocketpp/docs/pic/websocketpp_install_dir.png b/thirdparty/websocketpp/docs/pic/websocketpp_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..f131e81c93727d94b9ac7f72f8f142cd18cc9e27 Binary files /dev/null and b/thirdparty/websocketpp/docs/pic/websocketpp_install_dir.png differ diff --git a/thirdparty/websocketpp/docs/pic/websocketpp_test.png b/thirdparty/websocketpp/docs/pic/websocketpp_test.png new file mode 100644 index 0000000000000000000000000000000000000000..8963933e544d5c07340be38825c04beccea0e785 Binary files /dev/null and b/thirdparty/websocketpp/docs/pic/websocketpp_test.png differ diff --git a/thirdparty/websocketpp/docs/pic/websocketpp_usage.png b/thirdparty/websocketpp/docs/pic/websocketpp_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..e8df00f945a3e6df8e64291baa57800182384018 Binary files /dev/null and b/thirdparty/websocketpp/docs/pic/websocketpp_usage.png differ diff --git a/thirdparty/websocketpp/websocketpp_oh_pkg.patch b/thirdparty/websocketpp/websocketpp_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..898d15562ab69dc88c81d54cfa82ec44cdf15225 --- /dev/null +++ b/thirdparty/websocketpp/websocketpp_oh_pkg.patch @@ -0,0 +1,12 @@ +diff -rupN websocketpp-0.8.2/CMakeLists.txt websocketpp/CMakeLists.txt +--- websocketpp-0.8.2/CMakeLists.txt 2020-04-19 18:25:17.000000000 +0000 ++++ websocketpp/CMakeLists.txt 2023-03-31 08:53:54.953140034 +0000 +@@ -152,7 +152,7 @@ if (BUILD_TESTS OR BUILD_EXAMPLES) + endif() + set (WEBSOCKETPP_PLATFORM_TLS_LIBS ssl crypto) + set (WEBSOCKETPP_BOOST_LIBS system thread) +- set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x -stdlib=libc++") # todo: is libc++ really needed here? ++ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++") # todo: is libc++ really needed here? + if (NOT APPLE) + add_definitions (-DNDEBUG -Wall -Wno-padded) # todo: should we use CMAKE_C_FLAGS for these? + endif ()