diff --git a/thirdparty/json11-1.0.0/HPKBUILD b/thirdparty/json11-1.0.0/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..2de0d4b836f22c0aafcadd2d0376b5bc88b79e3b --- /dev/null +++ b/thirdparty/json11-1.0.0/HPKBUILD @@ -0,0 +1,72 @@ +# 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: wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn>, wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +pkgname=json11-1.0.0 +pkgver=v1.0.0 +pkgrel=0 +pkgdesc="json11 is a tiny JSON library for C++11, providing JSON parsing and serialization." +url="https://github.com/dropbox/json11/tree/v1.0.0" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT license") +depends=() +makedepends=() +source="https://github.com/dropbox/json11/archive/refs/tags/v1.0.0.zip" + +downloadpackage=true +autounpack=true +buildtools=cmake +patchflag=true + +builddir=json11-1.0.0 +packagename=json11-v1.0.0.zip + +# 为编译设置环境,如设置环境变量,创建编译目录等 +prepare() { + if $patchflag + then + cd $builddir + #在原库根目录下的CMakeLists.txt中打开构建单元测试的开关,并激活ctest + patch -p1 < `pwd`/../json11-1.0.0_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 "$@" -DCMAKE_C_FLAGS="-Wno-unused-command-line-argument" \ + -DCMAKE_CXX_FLAGS="-Wno-unused-command-line-argument" -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 -C $ARCH-build install >> $buildlog 2>&1 + cd $OLDPWD +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +cleanbuild() { + rm -rf ${PWD}/$builddir +} \ No newline at end of file diff --git a/thirdparty/json11-1.0.0/HPKCHECK b/thirdparty/json11-1.0.0/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..45087f23bbfe1b9cac2c3352e606b765ef4a975f --- /dev/null +++ b/thirdparty/json11-1.0.0/HPKCHECK @@ -0,0 +1,33 @@ +# 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: wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn>, wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +source HPKBUILD > /dev/null 2>&1 # 导入HPKBUILD文件 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${OHOS_SDK_VER}_test.log + + +# 在OH环境执行测试的接口 +openharmonycheck() { + res=0 + cd ${builddir}/${ARCH}-build # 进入到测试目录 + ctest > $logfile 2>&1 + res=$? + if [ $res -ne 0 ];then + mkdir ${LYCIUM_FAULT_PATH}/${pkgname} + cp Testing/Temporary/LastTest.log ${LYCIUM_FAULT_PATH}/${pkgname}/ + fi + cd $OLDPWD + return $res +} \ No newline at end of file diff --git a/thirdparty/json11-1.0.0/README.OpenSource b/thirdparty/json11-1.0.0/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..6f8ca3e59c8a353e2b15bbaff133ded8da8e4675 --- /dev/null +++ b/thirdparty/json11-1.0.0/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "json11-1.0.0", + "License": "MIT license", + "License File": "https://github.com/dropbox/json11/blob/master/LICENSE.txt", + "Version Number": "v1.0.0", + "Owner": "2942375747@qq.com", + "Upstream URL": "https://github.com/dropbox/json11", + "Description": "json11 is a tiny JSON library for C++11, providing JSON parsing and serialization." + } +] \ No newline at end of file diff --git a/thirdparty/json11-1.0.0/README_zh.md b/thirdparty/json11-1.0.0/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..29a2cb79b14f3cb7430740992975c5c24b887062 --- /dev/null +++ b/thirdparty/json11-1.0.0/README_zh.md @@ -0,0 +1,9 @@ +# json11-1.0.0三方库说明 +## 功能简介 +json11是c++ 11的一个小型JSON库,提供JSON解析和序列化。 +## 三方库版本: +- v1.0.0 +## 使用约束: +- [IDE和SDK版本](../../docs/constraint.md) +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) \ No newline at end of file diff --git a/thirdparty/json11-1.0.0/SHA512SUM b/thirdparty/json11-1.0.0/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..551513bceb12936c7cb6d8192f27cbdeeb5c0f19 --- /dev/null +++ b/thirdparty/json11-1.0.0/SHA512SUM @@ -0,0 +1 @@ +88f1735b977550feb03cf57aad37a56a348f9e266679512da5c3beeb96f294339aa48fac5069837db7ba3aa02a19a8ca9432f36ad9a57570248e13d0a21c4407 json11-v1.0.0.zip \ No newline at end of file diff --git a/thirdparty/json11-1.0.0/docs/hap_integrate.md b/thirdparty/json11-1.0.0/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..8a0fb48c71df8d32f15741965936a47ccad233ec --- /dev/null +++ b/thirdparty/json11-1.0.0/docs/hap_integrate.md @@ -0,0 +1,79 @@ +# json11集成到应用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/json11-1.0.0 #三方库json11-1.0.0的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库简介 + ├── json11-1.0.0_oh_pkg.patch #用于json11-1.0.0库编译的补丁 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh json11-1.0.0 + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + json11-1.0.0/arm64-v8a json11-1.0.0/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的头文件和静态库文件拷贝到该目录下,如下图所示: +   + +  ![thirdparty_install_dir](pic/json11_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/json11/${OHOS_ARCH}/lib/libjson11.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/json11/${OHOS_ARCH}/include) + ``` + +## 测试三方库 +- 编译出可执行的文件,使用原库自带的测试用例来做测试 [准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +进入到构建目录运行测试用例(注意arm64-v8a为构建64位的目录,armeabi-v7a为构建32位的目录)。执行结果如图所示 + +```shell + cd /data/tpc_c_cplusplus/thirdparty/json11-1.0.0/json11-1.0.0/arm64-v8a-build/ + ctest +``` + ![json11_test](pic/json11_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) \ No newline at end of file diff --git a/thirdparty/json11-1.0.0/docs/pic/json11_install_dir.png b/thirdparty/json11-1.0.0/docs/pic/json11_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..ece76bae89b3b7ae3ba155e618e3fa3ca8f74337 Binary files /dev/null and b/thirdparty/json11-1.0.0/docs/pic/json11_install_dir.png differ diff --git a/thirdparty/json11-1.0.0/docs/pic/json11_test.png b/thirdparty/json11-1.0.0/docs/pic/json11_test.png new file mode 100644 index 0000000000000000000000000000000000000000..ce8c21c1b0651c8c59c19c52ca6bf5dc5745545b Binary files /dev/null and b/thirdparty/json11-1.0.0/docs/pic/json11_test.png differ diff --git a/thirdparty/json11-1.0.0/json11-1.0.0_oh_pkg.patch b/thirdparty/json11-1.0.0/json11-1.0.0_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..00f0f8fb737397a5b16b6476175c95e645edcb1e --- /dev/null +++ b/thirdparty/json11-1.0.0/json11-1.0.0_oh_pkg.patch @@ -0,0 +1,20 @@ +diff -urN json11-1.0.0_old/CMakeLists.txt json11-1.0.0/CMakeLists.txt +--- json11-1.0.0_old/CMakeLists.txt 2017-06-21 07:48:22.000000000 +0800 ++++ json11-1.0.0/CMakeLists.txt 2024-10-07 20:10:12.364267842 +0800 +@@ -8,7 +8,7 @@ + + enable_testing() + +-option(JSON11_BUILD_TESTS "Build unit tests" OFF) ++option(JSON11_BUILD_TESTS "Build unit tests" ON) + option(JSON11_ENABLE_DR1467_CANARY "Enable canary test for DR 1467" OFF) + + if(CMAKE_VERSION VERSION_LESS "3") +@@ -50,6 +50,7 @@ + + add_executable(json11_test test.cpp) + target_link_libraries(json11_test json11) ++ add_test(NAME Json11Test COMMAND json11_test) + endif() + + install(TARGETS json11 DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE})