diff --git a/thirdparty/log4cplus/HPKBUILD b/thirdparty/log4cplus/HPKBUILD new file mode 100755 index 0000000000000000000000000000000000000000..fc16d642b4c3f6e25e8d997f709a2548cf3dc9fe --- /dev/null +++ b/thirdparty/log4cplus/HPKBUILD @@ -0,0 +1,55 @@ +# Contributor: huangminzhong +# Maintainer: huangminzhong +pkgname=log4cplus +pkgver=REL_2_1_0 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD" "Apache license 2.0") +depends=() +makedepends=() +install= +source="https://github.com/log4cplus/$pkgname/archive/refs/tags/$pkgver.tar.gz" +downloadpackage=true +autounpack=true +syncsubmodule=true # 用于同步子模块 + +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $syncsubmodule == true ];then + cd "$builddir" + # 同步子模块,这里采用git submodule update容易失败,进行git clone下载 + git clone https://github.com/philsquared/Catch.git -b v2.13.9 catch >> `pwd`/build.log 2>&1 + git clone https://github.com/log4cplus/ThreadPool.git threadpool >> `pwd`/build.log 2>&1 + cd $OLDPWD + syncsubmodule=false + fi +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > $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!" +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir # ${PWD}/$packagename +} diff --git a/thirdparty/log4cplus/README.OpenSource b/thirdparty/log4cplus/README.OpenSource new file mode 100755 index 0000000000000000000000000000000000000000..353049b644fea5213aa1703a470c3fa42c747405 --- /dev/null +++ b/thirdparty/log4cplus/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "log4cplus", + "License": "BSD/Apache license", + "License File": "LICENSE", + "Version Number": "REL_2_1_0", + "Owner": "huangminzhong2@huawei.com", + "Upstream URL": "https://github.com/log4cplus/log4cplus", + "Description": "log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration" + } +] diff --git a/thirdparty/log4cplus/README_zh.md b/thirdparty/log4cplus/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..2aa00879e9801f159ab5b47c72c40dc62d58d5f5 --- /dev/null +++ b/thirdparty/log4cplus/README_zh.md @@ -0,0 +1,17 @@ +# log4cplus三方库说明 + +## 功能简介 + +log4cplus是一个简单易用的C++日志记录API,它对日志管理和配置提供了线程安全、灵活和任意粒度的控制. + +## 使用约束 + +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:REL_2_1_0 +- 当前适配的功能:支持输出日志并将日志保存到本地 +- [BSD/Apache license](https://github.com/log4cplus/log4cplus/blob/master/LICENSE) + +## 集成方式 + +- [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/log4cplus/SHA512SUM b/thirdparty/log4cplus/SHA512SUM new file mode 100755 index 0000000000000000000000000000000000000000..51a50e4471b85794735a0967498c52099d28a9a3 --- /dev/null +++ b/thirdparty/log4cplus/SHA512SUM @@ -0,0 +1 @@ +fd26ae73e898af6896046e5e567bfc664bc8e81568c8cdbe5ff6316054b875af7fa946f7b1f011a96b0d3b53dc3f7f9411cbc2ffa07b674777cb0def2743ede8 log4cplus-REL_2_1_0.tar.gz \ No newline at end of file diff --git a/thirdparty/log4cplus/docs/hap_integrate.md b/thirdparty/log4cplus/docs/hap_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..9827e12051303a96790b81f1dbed5b648af082db --- /dev/null +++ b/thirdparty/log4cplus/docs/hap_integrate.md @@ -0,0 +1,91 @@ +# log4cplus集成到应用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环境准备) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/log4cplus #三方库log4cplus的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将log4cplus拷贝至tools/main目录下 + + ```shell + cd tpc_c_cplusplus + cp thirdparty/log4cplus tools/main -rf + ``` + +- 在tools目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + + ```shell + cd tools + ./build.sh log4cplus + ``` + +- 三方库头文件及生成的库 + + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + log4cplus/arm64-v8a log4cplus/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + +  ![thirdparty_install_dir](../../thirdparty_template/docs/pic/xxx_install_dir.png) + + 其中`xxx`代表三方库名,即为`log4cplus` + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/log4cplus/${OHOS_ARCH}/lib/liblog4cplusS.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/log4cplus/${OHOS_ARCH}/include) + ``` + + ![log4cplus_usage](../../thirdparty_template/docs/pic/xxx_usage.png) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![log4cplus_test](pic/log4cplus_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/log4cplus/docs/pic/log4cplus_test.png b/thirdparty/log4cplus/docs/pic/log4cplus_test.png new file mode 100755 index 0000000000000000000000000000000000000000..9e4b88e844970a987aab6b4105b28385de9659fa Binary files /dev/null and b/thirdparty/log4cplus/docs/pic/log4cplus_test.png differ