diff --git a/thirdparty/curl_8_8_0/HPKBUILD b/thirdparty/curl_8_8_0/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..60a62b46edc23c0dd33d1c06cb97bacca7b33818 --- /dev/null +++ b/thirdparty/curl_8_8_0/HPKBUILD @@ -0,0 +1,77 @@ +# Copyright (c) 2023 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: Jeff Han +# Maintainer: Jeff Han + +pkgname=curl_8_8_0 +pkgver=curl-8_8_0 +pkgrel=0 +pkgdesc="A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. libcurl offers a myriad of powerful features" +url="https://curl.se/" +archs=("armeabi-v7a" "arm64-v8a") +license=("curl") +depends=("openssl_1_1_1w" "zstd_1_5_6" "nghttp2") # QUICHE/WEBSOCKETS +makedepends=() + +# 官方下载地址: https://github.com/curl/${pkgname:0:4}/archive/refs/tags/$pkgver.tar.gz,因网络原因采用gitee mirrors +source="https://gitee.com/mirrors/${pkgname:0:4}/repository/archive/$pkgver.zip" + +autounpack=true +downloadpackage=true +patchflag=true + +builddir=${pkgname:0:4}-${pkgver} +packagename=$builddir.zip + +prepare() { + if $patchflag + then + cd $builddir + # 编译识别 OpenHarmony 系统 + patch -p1 < `pwd`/../curl_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 "$@" -DCURL_CA_BUNDLE="/etc/ssl/certs/cacert.pem" -DCURL_CA_PATH="/etc/ssl/certs/" -DCURL_ZSTD=ON -DENABLE_WEBSOCKETS=ON -DUSE_NGHTTP2=ON -B$ARCH-build -S./ > $buildlog 2>&1 + $MAKE -C $ARCH-build >> $buildlog 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" + make -C $ARCH-build testdeps >> `pwd`/$ARCH-build/build.log 2>&1 + cd $OLDPWD + echo "The test must be on an OpenHarmony device!" + # real test CMD + # TODO test +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/curl_8_8_0/HPKCHECK b/thirdparty/curl_8_8_0/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..9601faee3b7c2cf8f70dbb22044bde87d6ccfd80 --- /dev/null +++ b/thirdparty/curl_8_8_0/HPKCHECK @@ -0,0 +1,40 @@ +# Copyright (c) 2023 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: Jeff Han +# Maintainer: Jeff Han + +# Contributor: lpzhong <278527840@qq.com> +# Maintainer: lpzhong <278527840@qq.com> + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname:0:4}/${pkgname:0:4}_${ARCH}_${OHOS_SDK_VER}_test.log +openharmonycheck() { + res=0 + ## checkNetWork + ping www.baidu.com -c3 >> /dev/null + if [ $? -ne 0 ] + then + echo "the network not ready, the test depends the network! make sure the network is OK!!" + return 1 + fi + + cd ${builddir}/${ARCH}-build + cp ../../curl_test.sh ./ + touch data.txt + bash curl_test.sh > ${logfile} 2>&1 + res=$? + cd $OLDPWD + + return $res +} diff --git a/thirdparty/curl_8_8_0/README.OpenSource b/thirdparty/curl_8_8_0/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..90e27b865a4d657958ebb98616760b1fbb666199 --- /dev/null +++ b/thirdparty/curl_8_8_0/README.OpenSource @@ -0,0 +1,38 @@ +[ + { + "Name": "curl", + "License": "curl", + "License File": "https://github.com/curl/curl/blob/master/COPYING", + "Version Number": "curl-8_8_0", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/curl/curl/archive/refs/tags/curl-8_8_0.tar.gz", + "Description": "Curl is a command-line tool for transferring data specified with URL syntax. Find out how to use curl by reading the curl.1 man page or the MANUAL document. Find out how to install Curl by reading the INSTALL document." + }, + { + "Name": "openssl", + "License": "OpenSSL License and Original SSLeay License", + "License File": "https://www.openssl.org/source/license-openssl-ssleay.txt", + "Version Number": "1.1.1w", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://gitee.com/mirrors/openssl/repository/archive/OpenSSL_1_1_1w.zip", + "Description": "OpenSSL is a robust, commercial-grade, full-featured Open Source Toolkit for the Transport Layer Security (TLS) protocol formerly known as the Secure Sockets Layer (SSL) protocol." + }, + { + "Name": "zstd", + "License": "BSD-3-Clause or GPL-2.0", + "License File": ["https://github.com/facebook/zstd/blob/dev/LICENSE","https://github.com/facebook/zstd/blob/dev/COPYING"], + "Version Number": "v1.5.4", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/facebook/zstd/releases/download/v1.5.4/zstd-1.5.4.tar.gz", + "Description": "Zstandard, or zstd as short version, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios." + }, + { + "Name": "nghttp2", + "License": "MIT", + "License File": "https://github.com/nghttp2/nghttp2/blob/master/COPYING", + "Version Number": "v1.52.0", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/nghttp2/nghttp2/archive/refs/tags/v1.52.0.tar.gz", + "Description": "This is an implementation of the Hypertext Transfer Protocol version 2 in C." + } +] diff --git a/thirdparty/curl_8_8_0/README_zh.md b/thirdparty/curl_8_8_0/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..70b69ff7091d4f09aa5397ceab11e88620ec2474 --- /dev/null +++ b/thirdparty/curl_8_8_0/README_zh.md @@ -0,0 +1,11 @@ +# curl三方库说明 +## 功能简介 +curl是一个C库用于网络请求。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 4.0.8.1 (API Version 10 Release) +- 三方库版本:curl-8_8_0 +- 当前适配的功能:支持网络请求 + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/curl_8_8_0/SHA512SUM b/thirdparty/curl_8_8_0/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..26a71e8bbc7f195d04b78549259794beef1ebbc5 --- /dev/null +++ b/thirdparty/curl_8_8_0/SHA512SUM @@ -0,0 +1,2 @@ +0ce6b62b2fb8b1a64c1f4459dc10768512071ab7db4e72752bb7f28084fcefdbc76332ecbd8c9d2c5dcef7f2d4925f5310f84ab0df1ed7343d0303540c8db537 curl-curl-8_8_0.zip +a85903d2f2396e811146ecc7d6e26bef933211dc559430a430399ea6a3805a28188fa17dfb8a09b08f52281d786dc8e5e357f7e949459371d2734a7da62b863f curl_oh_pkg.patch \ No newline at end of file diff --git a/thirdparty/curl_8_8_0/curl_oh_pkg.patch b/thirdparty/curl_8_8_0/curl_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..3a0f2c4a54b7010e34e8b1075876a586abf40921 --- /dev/null +++ b/thirdparty/curl_8_8_0/curl_oh_pkg.patch @@ -0,0 +1,15 @@ +diff -rupN curl-curl-8_0_1/lib/CMakeLists.txt curl-curl-8_0_1_patch/lib/CMakeLists.txt +--- curl-curl-8_0_1/lib/CMakeLists.txt 2023-03-20 21:49:10.000000000 +0800 ++++ curl-curl-8_0_1_patch/lib/CMakeLists.txt 2023-05-10 14:51:49.579039952 +0800 +@@ -94,7 +94,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR + # CMake on those ancient systems + CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR + +- CMAKE_SYSTEM_NAME STREQUAL "Haiku") ++ CMAKE_SYSTEM_NAME STREQUAL "Haiku" OR ++ ++ # OpenHarmony ++ CMAKE_SYSTEM_NAME STREQUAL "OHOS") + + math(EXPR CMAKESONAME "${VERSIONCHANGE} - ${VERSIONDEL}") + set(CMAKEVERSION "${CMAKESONAME}.${VERSIONDEL}.${VERSIONADD}") diff --git a/thirdparty/curl_8_8_0/curl_test.sh b/thirdparty/curl_8_8_0/curl_test.sh new file mode 100644 index 0000000000000000000000000000000000000000..409d253e21ec72017e4985aa18deec8b35e363d6 --- /dev/null +++ b/thirdparty/curl_8_8_0/curl_test.sh @@ -0,0 +1,239 @@ +#!/bin/bash +# curl 基本功能测试,由于 curl 原生测试环境较为复杂,无法在交付时间内,在OpenHarmony搭建成功。因此采用脚本对核心功能进行测试。 +CURL=./src/curl + +# DEST_FILE=test_result_linux.txt +DEST_FILE=test_result_OpenHarmony.txt + +## 测试拉取整个网页 +function testWebSite() { + URL=www.baidu.com + TEST_SITE=./tmp.xml + RESULT_FILE=test.xml + + busybox wget -O $RESULT_FILE $URL + + $CURL -o $TEST_SITE $URL + if [ $? -ne 0 ]; then + echo "run curl failed!" >> $DEST_FILE + return -1 + fi + cmp $RESULT_FILE $TEST_SITE + retval=$? + if [ $retval -ne 0 ] ; + then + echo "testWebSite result failed!" >> $DEST_FILE + else + echo "testWebSite result success!" >> $DEST_FILE + fi + + rm $RESULT_FILE $TEST_SITE +} + +## 测试拉取一个文件 +function testWebData() { + URL=http://www.baidu.com/img/bdlogo.gif + SP="/" + FNAME=${URL##*$SP} + RESULT=test_$FNAME + + busybox wget -O $RESULT $URL + + $CURL -O $URL + if [ $? -ne 0 ]; then + echo "run curl failed!" >> $DEST_FILE + return -1 + fi + + cmp $RESULT $FNAME + retval=$? + if [ $retval -ne 0 ] ; + then + echo "testWebData result failed!" >> $DEST_FILE + else + echo "testWebData result success!" >> $DEST_FILE + fi + + rm $RESULT $FNAME +} + + +##测试GET请求方式 +function testHttpGet() { + URL=http://aiezu.com/test.php + tmp=`$CURL $URL` + res=`echo $tmp |grep -n "GET"` + if [ -z "$res" ]; then + echo "testHttpGet failed!" >> $DEST_FILE + return -1 + fi + + res=`echo $tmp |grep -n "Array"` + if [ -z "$res" ]; then + echo "testHttpGet failed!" >> $DEST_FILE + return -1 + fi + + echo "testHttpGet success!" >> $DEST_FILE + return 0 +} + +## 测试特定方式发送GET请求数据 +function testHttpGetParam(){ + URL=http://aiezu.com/test.php + PARAMS="en=aiezu&cn=爱E族" + tmp=`$CURL -G --data $PARAMS $URL` + res=`echo $tmp |grep -n "GET"` + if [ -z "$res" ]; then + echo "testHttpGetParam failed!" >> $DEST_FILE + return -1 + fi + + res=`echo $tmp |grep -n "Array"` + if [ -z "$res" ]; then + echo "testHttpGetParam failed!" >> $DEST_FILE + return -1 + fi + + echo "testHttpGetParam success!" >> $DEST_FILE + return 0 +} + +##测试POST请求方式 +function testHttpPost() { + URL=http://aiezu.com/test.php + PARAMS="--data 'name=爱E族&site=aiezu.com' --data-urlencode 'code=/&?'" + tmp=`$CURL $PARAMS $URL` + res=`echo $tmp |grep -n "POST"` + if [ -z "$res" ]; then + echo "testHttpPost failed!" >> $DEST_FILE + return -1 + fi + + res=`echo $tmp |grep -n "Array"` + if [ -z "$res" ]; then + echo "testHttpPost failed!" >> $DEST_FILE + return -1 + fi + + echo "testHttpPost success!" >> $DEST_FILE + return 0 +} + +##测试POST发送表单请求方式 +function testHttpPostForm(){ + URL=http://aiezu.com/test.php + PARAMS1="name=爱E族" + PARAMS2="site=aiezu.com" + tmp=`$CURL --form $PARAMS1 -F $PARAMS2 $URL` + res=`echo $tmp |grep -n "POST"` + if [ -z "$res" ]; then + echo "testHttpPostForm failed!" >> $DEST_FILE + return -1 + fi + + res=`echo $tmp |grep -n "Array"` + if [ -z "$res" ]; then + echo "testHttpPostForm failed!" >> $DEST_FILE + return -1 + fi + + echo "testHttpPostForm success!" >> $DEST_FILE + return 0 +} + +##测试POST请求方式上传本地文件 +function testHttpPostFile() { + URL=http://aiezu.com/test.php + PARAMS=data.txt + + if [ ! -f "$PARAMS" ]; then + echo "no test data file!" >> $DEST_FILE + echo "testHttpPostFile failed!" >> $DEST_FILE + return -1 + fi + + tmp=`$CURL --form file=@$PARAMS $URL` + res=`echo $tmp |grep -n "POST"` + if [ -z "$res" ]; then + echo "testHttpPostFile failed!" >> $DEST_FILE + return -1 + fi + + res=`echo $tmp |grep -n "Array"` + if [ -z "$res" ]; then + echo "testHttpPostFile failed!" >> $DEST_FILE + return -1 + fi + + echo "testHttpPostFile success!" >> $DEST_FILE + return 0 +} + +##测试POST请求方式上传JSON数据 +function testHttpPostJson() { + URL=http://aiezu.com/test.php + PARAMS="{"name":"爱E族","site":"aiezu.com"}" + + tmp=`$CURL -H "Content-Type: application/json" --data $PARAMS $URL` + res=`echo $tmp |grep -n "POST"` + if [ -z "$res" ]; then + echo "testHttpPostJson failed!" >> $DEST_FILE + return -1 + fi + + res=`echo $tmp |grep -n "Array"` + if [ -z "$res" ]; then + echo "testHttpPostJson failed!" >> $DEST_FILE + return -1 + fi + + echo "testHttpPostJson success!" >> $DEST_FILE + return 0 +} + +if [ ! -f "$CURL" ]; then + echo "no curl cmd file!" >> $DEST_FILE + exit 1 +fi + +echo "Start Test CURL!" > $DEST_FILE +echo "" >> $DEST_FILE +retval=0 +echo "start testWebSite" >> $DEST_FILE +testWebSite +retval=`expr $retval + $?` +echo "start testWebData" >> $DEST_FILE +testWebData +retval=`expr $retval + $?` +echo "start testHttpGet" >> $DEST_FILE +testHttpGet +retval=`expr $retval + $?` +echo "start testHttpGetParam" >> $DEST_FILE +testHttpGetParam +retval=`expr $retval + $?` +echo "start testHttpPost" >> $DEST_FILE +testHttpPost +retval=`expr $retval + $?` +echo "start testHttpPostForm" >> $DEST_FILE +testHttpPostForm +retval=`expr $retval + $?` +echo "start testHttpPostFile" >> $DEST_FILE +testHttpPostFile +retval=`expr $retval + $?` +echo "start testHttpPostJson" >> $DEST_FILE +testHttpPostJson +retval=`expr $retval + $?` +echo "" >> $DEST_FILE +echo "Test CURL OVER!!" >> $DEST_FILE + +cat $DEST_FILE + +if [ $retval -ne 0 ] +then + exit 1 +else + exit 0 +fi + +#EOF diff --git a/thirdparty/curl_8_8_0/docs/hap_integrate.md b/thirdparty/curl_8_8_0/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..ddaeae4b5f02a213936df1eef35887d9ffae30ff --- /dev/null +++ b/thirdparty/curl_8_8_0/docs/hap_integrate.md @@ -0,0 +1,65 @@ +# curl_8_8_0集成到应用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 4.0.8.1 (API Version 10 Release)](http://download.ci.openharmony.cn/version/Master_Version/OpenHarmony_4.0.8.1/20230608_091016/version-Master_Version-OpenHarmony_4.0.8.1-20230608_091016-ohos-sdk-full.tar.gz) +- [DevEco Studio 3.1 Release](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_package_901_9/81/v3/tgRUB84wR72nTfE8Ir_xMw/devecostudio-windows-3.1.0.501.zip?HW-CC-KV=V1&HW-CC-Date=20230621T074329Z&HW-CC-Expire=315360000&HW-CC-Sign=22F6787DF6093ECB4D4E08F9379B114280E1F65DA710599E48EA38CB24F3DBF2) +- [准备三方库构建环境](../../../lycium/README.md#1编译环境准备) +- [准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/curl_8_8_0 #三方库curl_8_8_0的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 在lycium目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ``` + cd lycium + ./build.sh curl_8_8_0 + ``` + +- 三方库头文件及生成的库 + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + curl_8_8_0/arm64-v8a curl_8_8_0/armeabi-v7a + zstd/arm64-v8a zstd/armeabi-v7a + nghttp2/arm64-v8a nghttp2/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录 + +  ![thirdparty_install_dir](pic/curl_install_dir_1.jpg) +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + +  ![thirdparty_install_dir](pic/curl_install_dir_2.jpg) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libcurl.so) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/curl/${OHOS_ARCH}/include) + ``` + +## 参考资料 +- [润和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/curl_8_8_0/docs/pic/curl_install_dir_1.jpg b/thirdparty/curl_8_8_0/docs/pic/curl_install_dir_1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..550b05625298e8eb0f68d1f31a75cb5c2c4a0f04 Binary files /dev/null and b/thirdparty/curl_8_8_0/docs/pic/curl_install_dir_1.jpg differ diff --git a/thirdparty/curl_8_8_0/docs/pic/curl_install_dir_2.jpg b/thirdparty/curl_8_8_0/docs/pic/curl_install_dir_2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ea3accb82af686252786c5ddc283118eb0592592 Binary files /dev/null and b/thirdparty/curl_8_8_0/docs/pic/curl_install_dir_2.jpg differ diff --git a/thirdparty/curl_8_8_0/docs/pic/curl_usage.jpg b/thirdparty/curl_8_8_0/docs/pic/curl_usage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7717531b954b571873bd0bf43a11bfe83887a43f Binary files /dev/null and b/thirdparty/curl_8_8_0/docs/pic/curl_usage.jpg differ