diff --git a/thirdparty/zxing-cpp/HPKBUILD b/thirdparty/zxing-cpp/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..864277c5f78255b9874d16b45dddd4c4e9383bd4 --- /dev/null +++ b/thirdparty/zxing-cpp/HPKBUILD @@ -0,0 +1,50 @@ +# Contributor: wupingyuan +# Maintainer: wupingyuan +pkgname=zxing-cpp +pkgver=v2.0.0 +pkgrel=0 +pkgdesc="ZXing-C++ (zebra crossing) is an open-source, multi-format linear/matrix barcode image processing library implemented in C++." +url="https://github.com/zxing-cpp/zxing-cpp" +archs=("armeabi-v7a" "arm64-v8a") +license=("Apache License 2.0") +depends=() +makedepends=() +install= +source="https://github.com/$pkgname/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +prepare() { + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DBUILD_SHARED_LIBS=OFF -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > `pwd`/$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 + ret=$? + cd $OLDPWD + return $ret +} + +check() { + echo "The test must be on an OpenHarmony device!" + # 在OpenHarmony开发板中执行用例 + # ./ZXingReader -format QRCode qrcode.png + # ./ZXingWriter -size 200x200 QRCode http://test.com outqrcode.png +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/zxing-cpp/README.OpenSource b/thirdparty/zxing-cpp/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..8a4d870b769042aa170acc649489c53824cab57e --- /dev/null +++ b/thirdparty/zxing-cpp/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "zxing-cpp", + "License": "Apache License 2.0", + "License File": "LICENSE", + "Version Number": "v2.0.0", + "Owner": "wupingyuan@huawei.com", + "Upstream URL": "https://github.com/zxing-cpp/zxing-cpp/archive/refs/tags/v2.0.0.tar.gz", + "Description": "ZXing-C++ (zebra crossing) is an open-source, multi-format linear/matrix barcode image processing library implemented in C++." + } +] diff --git a/thirdparty/zxing-cpp/README_zh.md b/thirdparty/zxing-cpp/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..8475493fc3644372e97027ddda63b99a26707f44 --- /dev/null +++ b/thirdparty/zxing-cpp/README_zh.md @@ -0,0 +1,12 @@ +# zxing-cpp三方库说明 +## 功能简介 +zxing-cpp是一个二维码生成和解析的库。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v2.0.0 +- 当前适配的功能:二维码生成和解析 +- [Apache License 2.0](https://github.com/zxing-cpp/zxing-cpp) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/zxing-cpp/SHA512SUM b/thirdparty/zxing-cpp/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..fa274178539badd389a91f17800532a9ce51e93b --- /dev/null +++ b/thirdparty/zxing-cpp/SHA512SUM @@ -0,0 +1 @@ +fa22164f834a42194eafd0d3e9c09d953233c69843ac6e79c8d6513314be28d8082382b436c379368e687e0eed05cb5e566d2893ec6eb29233a36643904ae083 zxing-cpp-2.0.0.tar.gz \ No newline at end of file diff --git a/thirdparty/zxing-cpp/docs/hap_integrate.md b/thirdparty/zxing-cpp/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..8931c53224faacb7902e239e6fdf31498e9e68f4 --- /dev/null +++ b/thirdparty/zxing-cpp/docs/hap_integrate.md @@ -0,0 +1,82 @@ +# zxing-cpp集成到应用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环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/zxing-cpp #三方库zxing-cpp的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将zxing-cpp拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/zxing-cpp tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh zxing-cpp + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + zxing-cpp/arm64-v8a zxing-cpp/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/zxing-cpp_install_dir.jpg) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zxing-cpp/${OHOS_ARCH}/lib/libZXing.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zxing-cpp/${OHOS_ARCH}/include) + ``` + ![zxing-cpp_usage](pic/zxing-cpp_usage.jpg) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +- 将编译生成的ZXingReader、ZXingWriter可执行文件及测试文件二维码qrcode.png准备好 + +- 将准备好的文件推送到开发板,在windows命令行进行如下操作 + + ``` + hdc_std shell mount -o remount,rw / #修改系统权限为可读写 + hdc_std file send ZXingReader /data #将可执行文件推入开发板data目录 + hdc_std file send ZXingWriter /data + hdc_std file send libc++_shared.so /system/lib64 + hdc_std file send qrcode.png /data #将测试文件推入开发板data目录 + hdc_std shell #进入开发板 + chmod 777 ZXingReader #添加权限 + chmod 777 ZXingWriter #添加权限 + ./ZXingReader -format QRCode qrcode.png #执行测试用例 + ./ZXingWriter -size 200x200 QRCode http://test.com qrcodenew.png + ``` + + ![zxing-cpp_test](pic/zxing-cpp_test.jpg) + +## 参考资料 +- [润和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/zxing-cpp/docs/pic/zxing-cpp_install_dir.jpg b/thirdparty/zxing-cpp/docs/pic/zxing-cpp_install_dir.jpg new file mode 100644 index 0000000000000000000000000000000000000000..eb60b4f552270da29c3bf604d29300b9ec230dc3 Binary files /dev/null and b/thirdparty/zxing-cpp/docs/pic/zxing-cpp_install_dir.jpg differ diff --git a/thirdparty/zxing-cpp/docs/pic/zxing-cpp_test.jpg b/thirdparty/zxing-cpp/docs/pic/zxing-cpp_test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..67d7a5f8cc2c9baeba78826d8d02979017bfbdef Binary files /dev/null and b/thirdparty/zxing-cpp/docs/pic/zxing-cpp_test.jpg differ diff --git a/thirdparty/zxing-cpp/docs/pic/zxing-cpp_usage.jpg b/thirdparty/zxing-cpp/docs/pic/zxing-cpp_usage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..deeadafb74d18beb2b86f2eb5ca781ebeee77834 Binary files /dev/null and b/thirdparty/zxing-cpp/docs/pic/zxing-cpp_usage.jpg differ