diff --git a/thirdparty/apr/HPKBUILD b/thirdparty/apr/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..96c2a0311d94d2d333812dec70d797d4c50f0a3a --- /dev/null +++ b/thirdparty/apr/HPKBUILD @@ -0,0 +1,112 @@ +# 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: dingqian <1052888395@qq.com> +# Maintainer: dingqian <1052888395@qq.com> + +pkgname=apr +pkgver=1.7.4 +pkgrel=0 +pkgdesc="APR is a software library that creates and maintains a set of APIs that map to the underlying operating system" +url="https://apr.apache.org" +archs=("armeabi-v7a" "arm64-v8a") +license=("Apache License 2.0") +depends=("libtool") +makedepends=(python autoconf) + +source="https://dlcdn.apache.org/$pkgname/${pkgname}-$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +patchflag=true +buildtools="configure" + +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +source envset.sh +host= + +prepare() { + cp -rf ${builddir} $builddir-${ARCH}-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + elif [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + else + echo "$ARCH not support!" + return -1 + fi + + if $patchflag + then + cd $builddir + # 三方库中线程未实现, + patch -p1 < `pwd`/../apr_oh_pkg.patch + # patch只需要打一次,关闭打patch + patchflag=false + cd $OLDPWD + fi +} + +build() { + cd $builddir-${ARCH}-build + ./configure "$@" --host=$host CFLAGS="-Wno-error=int-conversion" --enable-so --with-mpm=worker \ + ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_process_shared_works=yes apr_cv_mutex_robust_shared=yes \ + apr_cv_tcp_nodelay_with_cork=yes ap_void_ptr_lt_long=no --prefix=$LYCIUM_ROOT/usr/$pkgname/$ARCH TCP_NODELAY=0 TCP_CORK=0 \ + ac_cv_struct_rlimit=yes ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes ap_cv_void_ptr_lt_long=no \ + apr_cv_process_shared_works=yes apr_cv_mutex_robust_shared=yes > `pwd`/build.log 2>&1 + make -d -j4 VERBOSE=1 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + cd $builddir-${ARCH}-build/test + make -d -j4 VERBOSE=1 >> `pwd`/build.log 2>&1 + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-${ARCH}-build + make install >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + elif [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + else + echo "$ARCH not support!" + return -1 + fi + + unset host + return $ret +} + +check() { + echo "The test must be on an OpenHarmony device!" + # cd $builddir-${ARCH}-build/test + # ./testall +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/${builddir} ${PWD}/${builddir}-armeabi-v7a-build ${PWD}/${builddir}-arm64-v8a-build #${PWD}/$packagename +} + diff --git a/thirdparty/apr/HPKCHECK b/thirdparty/apr/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..8f4d0014e9eea6be51c4361f9b2b12764c688b67 --- /dev/null +++ b/thirdparty/apr/HPKCHECK @@ -0,0 +1,27 @@ +# 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: luozhu <1393302983@qq.com> +# Maintainer: luozhu <1393302983@qq.com> + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +openharmonycheck() { + res=0 + cd $builddir-${ARCH}-build/test + ./testall > ${logfile} 2>&1 + res=$? + cd $OLDPWD + return $res +} \ No newline at end of file diff --git a/thirdparty/apr/OAT.xml b/thirdparty/apr/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..c2cd820f7f651fb29f55ae2db126d2fd44be3cc6 --- /dev/null +++ b/thirdparty/apr/OAT.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/thirdparty/apr/README.OpenSource b/thirdparty/apr/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..d5d24fd15c89cd6531d4569546a04985a820b77a --- /dev/null +++ b/thirdparty/apr/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "apr", + "License": "Apache License 2.0", + "License File": "http://www.apache.org/licenses/", + "Version Number": "1.7.4", + "Owner": "1393302983@qq.com", + "Upstream URL": "https://dlcdn.apache.org/apr/apr-1.7.4.tar.gz", + "Description": "APR is a software library that creates and maintains a set of APIs that map to the underlying operating system." + } +] diff --git a/thirdparty/apr/README_zh.md b/thirdparty/apr/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..0bd924d8a088ad4c60f37a029519b816513001cb --- /dev/null +++ b/thirdparty/apr/README_zh.md @@ -0,0 +1,11 @@ +# apr三方库说明 +## 功能简介 +apr是一个是创建和维护软件库,提供一组映射到下层操作系统的API。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 4.0.8.1 (API Version 10 Release) +- 三方库版本:1.7.4 +- 当前适配的功能:内存管理和内存池,原子操作,动态库处理等 + +## 集成方式 ++ [应用hap包集成](docs/hap_ingtegrate.md) \ No newline at end of file diff --git a/thirdparty/apr/SHA512SUM b/thirdparty/apr/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..ea0bc7bfdd9231e8f3abc62a9e0473be911b8b55 --- /dev/null +++ b/thirdparty/apr/SHA512SUM @@ -0,0 +1,2 @@ +a8c90062eb78b6a33efc968959d1aadc1a73a4d40dbdb7d2745be54471de6d4c28dc154c85e9c5b9a172ac81735b69636d22b3b85d0b7d7c7f7e2670609da3cc apr-1.7.4.tar.gz +5d7ab96341c188c3832b321067a5f212703beacf2471e29478dc7f476bc5e70821a054efb51c997451768932b65ff702bab72d65be8e116e6a11bb90c3e5e80d apr_oh_pkg.patch diff --git a/thirdparty/apr/apr_oh_pkg.patch b/thirdparty/apr/apr_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..b560076fdc248296defe0f19514c87c01620e8bb --- /dev/null +++ b/thirdparty/apr/apr_oh_pkg.patch @@ -0,0 +1,43 @@ +--- apr-1.7.4/test/testlock.c 2022-09-13 01:00:36.000000000 +0800 ++++ apr-1.7.4/test/testlock-new.c 2023-08-22 10:58:01.325976646 +0800 +@@ -538,7 +538,6 @@ + #if APR_HAS_TIMEDLOCKS + abts_run_test(suite, test_thread_timedmutex, NULL); + #endif +- abts_run_test(suite, test_thread_nestedmutex, NULL); + abts_run_test(suite, test_thread_unnestedmutex, NULL); + abts_run_test(suite, test_thread_rwlock, NULL); + abts_run_test(suite, test_cond, NULL); +--- apr-1.7.4/test/testcond.c 2007-11-18 08:35:57.000000000 +0800 ++++ apr-1.7.4/test/testcond-new.c 2023-08-22 11:00:28.145299823 +0800 +@@ -659,9 +659,7 @@ + abts_run_test(suite, dynamic_binding, NULL); + abts_run_test(suite, broadcast_threads, NULL); + fnptr.func = nested_lock_and_wait; +- abts_run_test(suite, nested_wait, &fnptr); + fnptr.func = nested_lock_and_unlock; +- abts_run_test(suite, nested_wait, &fnptr); + abts_run_test(suite, pipe_producer_consumer, NULL); + abts_run_test(suite, ping_pong, NULL); + #endif +--- apr-1.7.4/network_io/unix/sockets.c 2015-03-20 09:31:17.000000000 +0800 ++++ apr-1.7.4/network_io/unix/sockets-new.c 2023-08-22 11:49:19.856038926 +0800 +@@ -340,7 +340,7 @@ + #endif /* TCP_NODELAY_INHERITED */ + #if APR_O_NONBLOCK_INHERITED + if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) { +- apr_set_option(*new, APR_SO_NONBLOCK, 1); ++ apr_set_option(*new, APR_SO_NONBLOCK, 0); + } + #endif /* APR_O_NONBLOCK_INHERITED */ + +--- apr-1.7.4/test/testsock.c 2023-08-22 11:36:10.655568812 +0800 ++++ apr-1.7.4/test/testsock-new.c 2023-08-22 11:50:51.215628649 +0800 +@@ -677,7 +677,6 @@ + socket_name = IPV4_SOCKET_NAME; + abts_run_test(suite, test_addr_info, NULL); + abts_run_test(suite, test_addr_copy, NULL); +- abts_run_test(suite, test_serv_by_name, NULL); + abts_run_test(suite, test_create_bind_listen, NULL); + abts_run_test(suite, test_send, NULL); + abts_run_test(suite, test_recv, NULL); diff --git a/thirdparty/apr/docs/hap_ingtegrate.md b/thirdparty/apr/docs/hap_ingtegrate.md new file mode 100644 index 0000000000000000000000000000000000000000..2440269ef008f2fb5405a0a0ed9bf0f8b47bad76 --- /dev/null +++ b/thirdparty/apr/docs/hap_ingtegrate.md @@ -0,0 +1,78 @@ +# apr集成到应用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)](https://gitee.com/link?target=http%3A%2F%2Fdownload.ci.openharmony.cn%2Fversion%2FMaster_Version%2FOpenHarmony_4.0.8.1%2F20230608_091058%2Fversion-Master_Version-OpenHarmony_4.0.8.1-20230608_091058-ohos-sdk-public.tar.gz) +- [DevEco Studio 3.1 Release](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2F81%2Fv3%2FtgRUB84wR72nTfE8Ir_xMw%2Fdevecostudio-windows-3.1.0.501.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230621T074329Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D22F6787DF6093ECB4D4E08F9379B114280E1F65DA710599E48EA38CB24F3DBF2) +- [准备三方库构建环境](../../../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/apr # 三方库apr的目录结构如下 + ├── docs # 三方库相关文档的文件夹 + ├── HPKBUILD # 编译脚本 + ├── HPKCHECK # 测试脚本 + ├── OAT.xml # OAT开源审查文本 + ├── apr_oh_pkg.patch # patch文件 + ├── README.OpenSource # 说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md # 三方库说明文档 + ├── SHA512SUM # 三方库校验文件 + ``` + +- 在lycium目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + ``` + cd lycium + ./build.sh apr + ``` +- 三方库头文件及生成的库 + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + apr/arm64-v8a apr/armeabi-v7a + libtool/arm64-v8a libtool/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库和依赖库拷贝到该目录下,如下图所示 +   +![thirdparty_install_dir](pic/apr_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/apr/${OHOS_ARCH}/lib/libapr-1.a) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libtool/${OHOS_ARCH}/lib/libltdl.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/apr/${OHOS_ARCH}/include) + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libtool/${OHOS_ARCH}/include) + ``` + +![apr_usage](pic/apr_usage.png) + +## 测试三方库 +三方库的测试使用自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +- 将编译生成的可执行文件及生成的动态库准备好 + +- 将准备好的文件推送到开发板,进入到构建的目录添加执行文件权限和lib库环境执行./testall + ![apr_test](pic/apr_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/apr/docs/pic/apr_install_dir.png b/thirdparty/apr/docs/pic/apr_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..3ad023c5268ad7b7b34f6de76eab8ff66b433af2 Binary files /dev/null and b/thirdparty/apr/docs/pic/apr_install_dir.png differ diff --git a/thirdparty/apr/docs/pic/apr_test.png b/thirdparty/apr/docs/pic/apr_test.png new file mode 100644 index 0000000000000000000000000000000000000000..66b12e6b25b39345b245ed19c99a3875a1ee698b Binary files /dev/null and b/thirdparty/apr/docs/pic/apr_test.png differ diff --git a/thirdparty/apr/docs/pic/apr_usage.png b/thirdparty/apr/docs/pic/apr_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..7d796a4f75007d0705d75708efde3bc3c5aec537 Binary files /dev/null and b/thirdparty/apr/docs/pic/apr_usage.png differ