diff --git a/thirdparty/yaml-cpp/HPKBUILD b/thirdparty/yaml-cpp/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..2ddd9235669443b64892943e243471402a1331eb --- /dev/null +++ b/thirdparty/yaml-cpp/HPKBUILD @@ -0,0 +1,70 @@ +# Copyright (c) 2024 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: dingchenjie1 +# Maintainer: dingchenjie1 + +pkgname=yaml-cpp +pkgver=0.8.0 +pkgrel=0 +pkgdesc="Yaml-cpp is a YAML parser and emitter in C++ matching the YAML 1.2 spec." +archs=("armeabi-v7a" "arm64-v8a") +url="https://github.com/jbeder/yaml-cpp" +license=( "MIT license" ) +depends=() +makedepends=() +source="https://github.com/jbeder/${pkgname}/archive/refs/tags/${pkgver}.tar.gz" + +downloadpackage=true +autounpack=true +buildtools="cmake" + +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +prepare() { + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + PKG_CONFIG_LIBDIR="${pkgconfigpath}" \ + $OHOS_SDK/native/build-tools/cmake/bin/cmake "$@" \ + -DCMAKE_C_FLAGS="-Wno-error=unused-command-line-argument -Wno-c++11-narrowing" \ + -DCMAKE_CXX_FLAGS="-Wno-error=unused-command-line-argument -Wno-c++11-narrowing" \ + -DYAML_CPP_BUILD_TESTS="on" \ + -B$ARCH-build -S./ > $buildlog 2>&1 + $MAKE VERBOSE=1 -C $ARCH-build >> $buildlog 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + $MAKE VERBOSE=1 -C $ARCH-build install >> $buildlog 2>&1 + cd $OLDPWD +} + +check() { + echo "The test must be on an OpenHarmony device!" + # 测试方式 + # 进入构建目录下tests目录 + # 执行: ctest +} + +# 清理环境 +cleanbuild() { + rm -rf ${PWD}/$builddir #${PWD}/$packagename + echo "rm -rf ${PWD}/$builddir" +} \ No newline at end of file diff --git a/thirdparty/yaml-cpp/HPKCHECK b/thirdparty/yaml-cpp/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..416606e5e616a266567518adcd7d483685cd4427 --- /dev/null +++ b/thirdparty/yaml-cpp/HPKCHECK @@ -0,0 +1,35 @@ +# Copyright (c) 2024 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: dingchenjie1 +# Maintainer: dingchenjie1 + +source HPKBUILD > /dev/null 2>&1 # 导入HPKBUILD文件 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +# 在OH环境执行测试的接口 +openharmonycheck() { + res=0 + cd ${builddir}/${ARCH}-build/tests + echo "cd ${builddir}/${ARCH}-build/tests" + ctest > ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + mkdir -p ${LYCIUM_FAULT_PATH}/${pkgname} + cp Testing/Temporary/LastTest.log ${LYCIUM_FAULT_PATH}/${pkgname}/ + fi + cd $OLDPWD + + return $res +} diff --git a/thirdparty/yaml-cpp/README.OpenSource b/thirdparty/yaml-cpp/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..3a24500568670601467bcc30a06e5631695958ce --- /dev/null +++ b/thirdparty/yaml-cpp/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "yaml-cpp", + "License": "MIT license", + "License File": "https://github.com/jbeder/yaml-cpp/blob/master/LICENSE", + "Version Number": "0.8.0", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz", + "Description": "Yaml-cpp is a YAML parser and emitter in C++ matching the YAML 1.2 spec." + } +] diff --git a/thirdparty/yaml-cpp/README_zh.md b/thirdparty/yaml-cpp/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..33386efc8195c2c98e630566588592fbb1fa46c8 --- /dev/null +++ b/thirdparty/yaml-cpp/README_zh.md @@ -0,0 +1,15 @@ +# yaml-cpp三方库说明 +## 功能简介 +yaml-cpp是c++中的YAML解析器和发射器,与YAML 1.2规范相匹配。 + +## 三方库版本 +- v0.8.0 + +## 已适配功能 +- 提供解析和生成YAML的能力。 + +## 使用约束 +- [IDE和SDK版本](../../docs/constraint.md) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/yaml-cpp/SHA512SUM b/thirdparty/yaml-cpp/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..f5e6019c384b10ef8f2ff702a022c251c105d0e1 --- /dev/null +++ b/thirdparty/yaml-cpp/SHA512SUM @@ -0,0 +1 @@ +aae9d618f906117d620d63173e95572c738db518f4ff1901a06de2117d8deeb8045f554102ca0ba4735ac0c4d060153a938ef78da3e0da3406d27b8298e5f38e yaml-cpp-0.8.0.tar.gz \ No newline at end of file diff --git a/thirdparty/yaml-cpp/docs/hap_integrate.md b/thirdparty/yaml-cpp/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..94a5ebada5277550721febf2003b9eb1c95e4137 --- /dev/null +++ b/thirdparty/yaml-cpp/docs/hap_integrate.md @@ -0,0 +1,79 @@ +# yaml-cpp 集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- [开发环境准备](../../../docs/hap_integrate_environment.md) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/yaml-cpp #三方库yoga的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库简介 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh yaml-cpp + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + yaml-cpp/arm64-v8a yaml-cpp/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录新建一个thirdparty目录,将生成的二进制文件以及头文件拷贝到该目录下,每种架构目录下包含了该库的头文件(include)、二进制文件(lib),如下图所示: +   + +  ![thirdparty_install_dir](pic/yaml-cpp_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/yaml-cpp/${OHOS_ARCH}/lib/libyaml-cpp.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/yaml-cpp/${OHOS_ARCH}/include) + ``` + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +进入到构建目录执行(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) +```shell + ctest #执行测试用例 +``` + ![yaml-cpp_test](pic/yaml-cpp_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) \ No newline at end of file diff --git a/thirdparty/yaml-cpp/docs/pic/yaml-cpp_install_dir.png b/thirdparty/yaml-cpp/docs/pic/yaml-cpp_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..209c2c57ec33095ce7acf1f44cbdb66d808e30a1 Binary files /dev/null and b/thirdparty/yaml-cpp/docs/pic/yaml-cpp_install_dir.png differ diff --git a/thirdparty/yaml-cpp/docs/pic/yaml-cpp_test.png b/thirdparty/yaml-cpp/docs/pic/yaml-cpp_test.png new file mode 100644 index 0000000000000000000000000000000000000000..ddeb4c0c51dd8f2483bcade79b6624cd6d1fa026 Binary files /dev/null and b/thirdparty/yaml-cpp/docs/pic/yaml-cpp_test.png differ diff --git a/thirdparty/yaml-cpp/docs/pic/yaml-cpp_usage.png b/thirdparty/yaml-cpp/docs/pic/yaml-cpp_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..a2fdb5cdd980e3a5a028bfddab13fc96ffa2a86a Binary files /dev/null and b/thirdparty/yaml-cpp/docs/pic/yaml-cpp_usage.png differ