diff --git a/thirdparty/nghttp3/HPKBUILD b/thirdparty/nghttp3/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..7802560d8708e9a31d31204efb78e7be116bd14a --- /dev/null +++ b/thirdparty/nghttp3/HPKBUILD @@ -0,0 +1,59 @@ +# Contributor: tyBrave +# Maintainer: tyBrave +pkgname=nghttp3 +pkgver=v0.10.0 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT") +depends=("CUnit") +makedepends=() +install= +source="https://github.com/ngtcp2/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true + +builddir=$pkgname-${pkgver:1} +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 > `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() { + cd $builddir/$ARCH-build + echo "checkcheckcheckcheckcheckcheckcheckcheck" + make -f lib/CMakeFiles/nghttp3_static.dir/build.make lib/CMakeFiles/nghttp3_static.dir/depend >> `pwd`/build.log 2>&1 && \ + make -f lib/CMakeFiles/nghttp3_static.dir/build.make lib/CMakeFiles/nghttp3_static.dir/build >> `pwd`/build.log 2>&1 && \ + make -f tests/CMakeFiles/main.dir/build.make tests/CMakeFiles/main.dir/depend >> `pwd`/build.log 2>&1 && \ + make -f tests/CMakeFiles/main.dir/build.make tests/CMakeFiles/main.dir/build >> `pwd`/build.log 2>&1 && \ + make -f CMakeFiles/check.dir/build.make CMakeFiles/check.dir/depend >> `pwd`/build.log 2>&1 + res=$? + cd $OLDPWD + echo "The test must be on an OpenHarmony device!" + # real test CMD + # ctest + return $res +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/nghttp3/README.OpenSource b/thirdparty/nghttp3/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..544387ed9000ff46812ff0d58613971ff32672b4 --- /dev/null +++ b/thirdparty/nghttp3/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "nghttp3", + "License": "MIT", + "License File": "https://github.com/ngtcp2/nghttp3/blob/main/COPYING", + "Version Number": "v0.10.0, + "Owner": "tianyong13@huawei.com", + "Upstream URL": "https://github.com/ngtcp2/nghttp3/archive/refs/tags/v0.10.0.tar.gz", + "Description": "nghttp3 is an implementation of RFC 9114 HTTP/3 mapping over QUIC and RFC 9204 QPACK in C." + } +] diff --git a/thirdparty/nghttp3/README_zh.md b/thirdparty/nghttp3/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..c0052ad28ba22a54328daa872de4f39e0d22c345 --- /dev/null +++ b/thirdparty/nghttp3/README_zh.md @@ -0,0 +1,12 @@ +# nghttp3三方库说明 +## 功能简介 +nghttp3是在C中通过QUIC和QPACK进行HTTP/3映射的实现,它不依赖于任何特定的QUIC传输实现 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v0.10.0 +- 当前适配的功能:支持http3 +- [MIT License](https://github.com/ngtcp2/nghttp3/blob/main/COPYING) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/nghttp3/SHA512SUM b/thirdparty/nghttp3/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..436e20c2185ca6c4344c2e15b9f2e752ec7a85a9 --- /dev/null +++ b/thirdparty/nghttp3/SHA512SUM @@ -0,0 +1 @@ +44dd4f4bb807a4d9f2c85399e83e3146ca8e18b4d4e9bca0b1a9a626daf1f9ca2892bfa55552267a3f43af7e6c6090ec662782936a45bada6faca822d1a31638 nghttp3-0.10.0.tar.gz diff --git a/thirdparty/nghttp3/docs/hap_integrate.md b/thirdparty/nghttp3/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..684ef62a276178c81dce9a3682ed677818d77491 --- /dev/null +++ b/thirdparty/nghttp3/docs/hap_integrate.md @@ -0,0 +1,70 @@ +# nghttp3集成到应用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/nghttp3 #三方库nghttp3的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将nghttp3及其依赖库CUnit拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/CUnit tools/main -rf + cp thirdparty/nghttp3 tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh CUnit nghttp3 + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + nghttp3/arm64-v8a nghttp3/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + + ![nghttp3_install_dir](pic/nghttp3_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/nghttp3/${OHOS_ARCH}/lib/libnghttp3.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/nghttp3/${OHOS_ARCH}/include) + ``` + ![nghttp3_usage](pic/nghttp3_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![nghttp3_test](pic/nghttp3_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/nghttp3/docs/pic/nghttp3_install_dir.png b/thirdparty/nghttp3/docs/pic/nghttp3_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..5bfbc97b586177bfaaeea702f0d32cb29292eb06 Binary files /dev/null and b/thirdparty/nghttp3/docs/pic/nghttp3_install_dir.png differ diff --git a/thirdparty/nghttp3/docs/pic/nghttp3_test.png b/thirdparty/nghttp3/docs/pic/nghttp3_test.png new file mode 100644 index 0000000000000000000000000000000000000000..582457b1e2e31b20e7ff55808034ff0c1766f2c8 Binary files /dev/null and b/thirdparty/nghttp3/docs/pic/nghttp3_test.png differ diff --git a/thirdparty/nghttp3/docs/pic/nghttp3_usage.png b/thirdparty/nghttp3/docs/pic/nghttp3_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..f79bd199b074a1846a01c8ee25391d98bfbffb9c Binary files /dev/null and b/thirdparty/nghttp3/docs/pic/nghttp3_usage.png differ