diff --git a/zxing-cpp/BUILD.gn b/zxing-cpp/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0a75ebc0cced174b1ca2da80794001465f9ec4a9 --- /dev/null +++ b/zxing-cpp/BUILD.gn @@ -0,0 +1,183 @@ +import("//build/ohos.gni") + +declare_args() { + enable_zxing_cpp_test = false +} + +config("config") { + cflags = [ + "-fPIC", + "-Wall", + "-frtti", + "-fexceptions", + "-Wno-error=missing-field-initializers", + "-Wno-error=missing-braces", + ] + + cflags_cc = cflags +} + +ohos_source_set("zxing-cpp_source") { + sources = [ + "//third_party/zxing-cpp/core/src/BarcodeFormat.cpp", + "//third_party/zxing-cpp/core/src/BinaryBitmap.cpp", + "//third_party/zxing-cpp/core/src/BitArray.cpp", + "//third_party/zxing-cpp/core/src/BitMatrix.cpp", + "//third_party/zxing-cpp/core/src/BitMatrixIO.cpp", + "//third_party/zxing-cpp/core/src/BitSource.cpp", + "//third_party/zxing-cpp/core/src/CharacterSet.cpp", + "//third_party/zxing-cpp/core/src/ConcentricFinder.cpp", + "//third_party/zxing-cpp/core/src/Content.cpp", + "//third_party/zxing-cpp/core/src/DecodeHints.cpp", + "//third_party/zxing-cpp/core/src/ECI.cpp", + "//third_party/zxing-cpp/core/src/GTIN.cpp", + "//third_party/zxing-cpp/core/src/GenericGF.cpp", + "//third_party/zxing-cpp/core/src/GenericGFPoly.cpp", + "//third_party/zxing-cpp/core/src/GlobalHistogramBinarizer.cpp", + "//third_party/zxing-cpp/core/src/GridSampler.cpp", + "//third_party/zxing-cpp/core/src/HRI.cpp", + "//third_party/zxing-cpp/core/src/HybridBinarizer.cpp", + "//third_party/zxing-cpp/core/src/MultiFormatReader.cpp", + "//third_party/zxing-cpp/core/src/MultiFormatWriter.cpp", + "//third_party/zxing-cpp/core/src/PerspectiveTransform.cpp", + "//third_party/zxing-cpp/core/src/ReadBarcode.cpp", + "//third_party/zxing-cpp/core/src/ReedSolomonDecoder.cpp", + "//third_party/zxing-cpp/core/src/ReedSolomonEncoder.cpp", + "//third_party/zxing-cpp/core/src/Result.cpp", + "//third_party/zxing-cpp/core/src/ResultPoint.cpp", + "//third_party/zxing-cpp/core/src/TextDecoder.cpp", + "//third_party/zxing-cpp/core/src/TextEncoder.cpp", + "//third_party/zxing-cpp/core/src/TextUtfEncoding.cpp", + "//third_party/zxing-cpp/core/src/Utf.cpp", + "//third_party/zxing-cpp/core/src/WhiteRectDetector.cpp", + "//third_party/zxing-cpp/core/src/ZXBigInteger.cpp", + "//third_party/zxing-cpp/core/src/aztec/AZDecoder.cpp", + "//third_party/zxing-cpp/core/src/aztec/AZDetector.cpp", + "//third_party/zxing-cpp/core/src/aztec/AZEncoder.cpp", + "//third_party/zxing-cpp/core/src/aztec/AZHighLevelEncoder.cpp", + "//third_party/zxing-cpp/core/src/aztec/AZReader.cpp", + "//third_party/zxing-cpp/core/src/aztec/AZToken.cpp", + "//third_party/zxing-cpp/core/src/aztec/AZWriter.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMBitLayout.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMDataBlock.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMDecoder.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMDetector.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMECEncoder.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMHighLevelEncoder.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMReader.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMSymbolInfo.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMVersion.cpp", + "//third_party/zxing-cpp/core/src/datamatrix/DMWriter.cpp", + "//third_party/zxing-cpp/core/src/libzueci/zueci.c", + "//third_party/zxing-cpp/core/src/maxicode/MCBitMatrixParser.cpp", + "//third_party/zxing-cpp/core/src/maxicode/MCDecoder.cpp", + "//third_party/zxing-cpp/core/src/maxicode/MCReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCodabarReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCodabarWriter.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCode128Patterns.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCode128Reader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCode128Writer.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCode39Reader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCode39Writer.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCode93Reader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODCode93Writer.cpp", + "//third_party/zxing-cpp/core/src/oned/ODDataBarCommon.cpp", + "//third_party/zxing-cpp/core/src/oned/ODDataBarExpandedBitDecoder.cpp", + "//third_party/zxing-cpp/core/src/oned/ODDataBarExpandedReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODDataBarReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODEAN13Writer.cpp", + "//third_party/zxing-cpp/core/src/oned/ODEAN8Writer.cpp", + "//third_party/zxing-cpp/core/src/oned/ODITFReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODITFWriter.cpp", + "//third_party/zxing-cpp/core/src/oned/ODMultiUPCEANReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODRowReader.cpp", + "//third_party/zxing-cpp/core/src/oned/ODUPCAWriter.cpp", + "//third_party/zxing-cpp/core/src/oned/ODUPCEANCommon.cpp", + "//third_party/zxing-cpp/core/src/oned/ODUPCEWriter.cpp", + "//third_party/zxing-cpp/core/src/oned/ODWriterHelper.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFBarcodeValue.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFBoundingBox.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFCodewordDecoder.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFDecodedBitStreamParser.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFDetectionResult.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFDetectionResultColumn.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFDetector.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFEncoder.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFHighLevelEncoder.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFModulusGF.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFModulusPoly.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFReader.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFScanningDecoder.cpp", + "//third_party/zxing-cpp/core/src/pdf417/PDFWriter.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRBitMatrixParser.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRCodecMode.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRDataBlock.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRDecoder.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRDetector.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QREncoder.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRErrorCorrectionLevel.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRFormatInformation.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRMaskUtil.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRMatrixUtil.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRReader.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRVersion.cpp", + "//third_party/zxing-cpp/core/src/qrcode/QRWriter.cpp", + "//third_party/zxing-cpp/core/src/stb_image.c", + ] + include_dirs = [ + "//third_party/zxing-cpp/", + "//third_party/zxing-cpp/core", + "//third_party/zxing-cpp/core/src", + "//third_party/zxing-cpp/core/oned", + ] + configs = [ ":config" ] +} + +ohos_executable("ZXingReader") { + sources = [ "//third_party/zxing-cpp/example/ZXingReader.cpp" ] + include_dirs = [ + "//third_party/zxing-cpp/core", + "//third_party/zxing-cpp/core/src", + "//third_party/zxing-cpp/core/oned", + ] + + configs = [ ":config" ] + + deps = [ "//third_party/zxing-cpp:libzxing-cpp" ] + subsystem_name = "thirdparty" + part_name = "zxing-cpp" + output_name = "ZXingReader" +} + +ohos_executable("ZXingWriter") { + sources = [ "//third_party/zxing-cpp/example/ZXingWriter.cpp" ] + include_dirs = [ + "//third_party/zxing-cpp/core", + "//third_party/zxing-cpp/core/src", + "//third_party/zxing-cpp/core/oned", + ] + + configs = [ ":config" ] + + deps = [ "//third_party/zxing-cpp:libzxing-cpp" ] + subsystem_name = "thirdparty" + part_name = "zxing-cpp" + output_name = "ZXingWriter" +} + +ohos_shared_library("libzxing-cpp") { + deps = [ ":zxing-cpp_source" ] + part_name = "zxing-cpp" + output_name = "zxing-cpp" +} + +group("zxing_cpp_targets") { + deps = [ ":libzxing-cpp" ] + if (enable_zxing_cpp_test) { + deps += [ + ":ZXingReader", + ":ZXingWriter", + ] + } +} diff --git a/zxing-cpp/CHANGELOG.md b/zxing-cpp/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..4963dc7546e7cc84baf8e836c544ddf43f554025 --- /dev/null +++ b/zxing-cpp/CHANGELOG.md @@ -0,0 +1,3 @@ +# 1.0.0 + +添加BUILD.gn和cmake,适配在ohos上的编译 diff --git a/zxing-cpp/CMakeLists.txt b/zxing-cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ae6998dca7a6a0e2f35786a8dbbe624d2074fe9a --- /dev/null +++ b/zxing-cpp/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.4.1) +project(zxing_cpp) +set(CMAKE_CXX_STANDARD 17) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/core + ${CMAKE_CURRENT_SOURCE_DIR}/core/src) + +file(GLOB libzxing core/src/*.cpp) +file(GLOB libzxing_qrcode core/src/qrcode/*.cpp) +file(GLOB libzxing_pdf417 core/src/pdf417/*.cpp) +file(GLOB libzxing_oned core/src/oned/*.cpp) +file(GLOB libzxing_maxicode core/src/maxicode/*.cpp) +file(GLOB libzxing_libzueci core/src/libzueci/*.c) +file(GLOB libzxing_datamatrix core/src/datamatrix/*.cpp) +file(GLOB libzxing_aztec core/src/aztec/*.cpp) +file(GLOB libzxing_c core/src/*.c) +add_library(zxing SHARED ${libzxing} ${libzxing_qrcode} ${libzxing_pdf417} + ${libzxing_oned} ${libzxing_maxicode} ${libzxing_libzueci} + ${libzxing_datamatrix} ${libzxing_aztec} ${libzxing_c} ) + + +file( + GLOB_RECURSE mains RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/example/ZXingReader.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/example/ZXingWriter.cpp" +) +foreach(mainfile IN LISTS mains) + get_filename_component(mainname ${mainfile} NAME_WE) + add_executable(${mainname} ${mainfile}) +target_link_libraries(${mainname} PUBLIC zxing) +endforeach() + + + diff --git a/zxing-cpp/README.OpenSource b/zxing-cpp/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..4ada0151b7b44867cd9eb21a40158f9c1338a3dc --- /dev/null +++ b/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", + "Description": "ZXing-C++ ("zebra crossing") is an open-source, multi-format linear/matrix barcode image processing library implemented in C++." + } +] diff --git a/zxing-cpp/README_zh.md b/zxing-cpp/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..974ddf421c53e42e43ed218529860c6c7bb3cab0 --- /dev/null +++ b/zxing-cpp/README_zh.md @@ -0,0 +1,19 @@ +# zxing-cpp 三方库说明 + +## 功能简介 + +zxing-cpp是一个二维码生成和解析的库。 + +## 使用约束 + +- Rom版本:OpenHarmony3.2 beta2 +- IDE版本:DevEco Studio 3.1 Beta1 +- API版本:9 +- 三方库版本:v2.0.0 +- 当前适配的功能:二维码生成和解析 +- License:[Apache License 2.0](https://github.com/zxing-cpp/zxing-cpp/blob/master/LICENSE) + +## 集成方式 + +- [系统Rom包集成](./docs/rom_integrate.md) ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/zxing-cpp/adapted/ZXVersion.h b/zxing-cpp/adapted/ZXVersion.h new file mode 100644 index 0000000000000000000000000000000000000000..78fde4106a23f6755ed56ae98a8a5e138ecf5831 --- /dev/null +++ b/zxing-cpp/adapted/ZXVersion.h @@ -0,0 +1,11 @@ +/* +* Copyright 2019 Nu-book Inc. +*/ +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +// Version numbering +#define ZXING_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define ZXING_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define ZXING_VERSION_PATCH @PROJECT_VERSION_PATCH@ diff --git a/zxing-cpp/bundle.json b/zxing-cpp/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..a900538549975335bd697313250d370368be5c65 --- /dev/null +++ b/zxing-cpp/bundle.json @@ -0,0 +1,35 @@ +{ + "name": "@ohos/zxing-cpp", + "description": "ZXing-C++ is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.", + "version": "v2.0.0", + "license": "Apache License 2.0", + "publishAs": "", + "segment": { + "destPath": "third_party/zxing-cpp" + }, + "dirs": {}, + "scripts": {}, + "readmePath": { + "en": "README" + }, + "component": { + "name": "zxing-cpp", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": ["standard"], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//third_party/zxing-cpp:zxing_cpp_targets" + ], + "inner_kits": [], + "test": [] + } + } +} \ No newline at end of file diff --git a/zxing-cpp/docs/hap_integrate.md b/zxing-cpp/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..94fc0b86a4f2fc2e855a70761982f47de795ebd4 --- /dev/null +++ b/zxing-cpp/docs/hap_integrate.md @@ -0,0 +1,50 @@ +# zxing-cpp如何集成到应用hap +## 准备应用工程 +本库是基于DevEco Studio 3.1 Beta1版本,在RK3568开发板上验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +### 准备应用开发环境 +开发环境的准备参考:[开发环境准备](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md#%E5%B7%A5%E7%A8%8B%E5%87%86%E5%A4%87) +### 增加构建脚本及配置文件 +- 下载本仓库,并解压 +- 三方库目录结构 + ``` + tpc_c_cplusplus/zxing-cpp #三方库zxing-cpp的目录结构如下 + ├── adapted #存放三方库适配需要的代码文件 + ├── docs #存放三方库相关文档的文件夹 + ├── CmakeLists.txt #构建脚本,支持hap包集成 + ├── bundle.json #三方库组件定义文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` +- 将zxing-cpp拷贝至工程xxxx/entry/src/main/cpp/thirdparty目录下 +### 准备三方库源码 +- 三方库下载地址:[zxing-cpp](https://github.com/zxing-cpp/zxing-cpp), 版本:v2.10.1 + 解压后修改库文件名为zxing-cpp,拷贝至工程xxxx/entry/src/main/cpp/thirdparty/zxing-cpp目录下 +- 依赖库地址:[stb](https://github.com/nothings/stb),版本:master + 解压后把文件stb/deprecated/stb_image.c、stb/stb_image.h、stb/stb_image_write.h拷贝到zxing-cpp/core/src目录 +## 应用中使用三方库 +- 将三方库加入工程中,目录结构如下 + ``` + demo/entry/src/main/cpp + ├── thirdparty #三方库存放目录 + │ ├── zxing-cpp #三方库zxing-cpp + ├── CMakeLists.txt #工程目录的构建脚本 + ├── ..... #工程目录的其他文件 + ``` +- 在工程顶级CMakeLists.txt中引入三方库,增加如下代码 + ``` + add_subdirectory(thirdparty/zxing-cpp) #引入子目录下的CMakeLists.txt + target_link_libraries(工程库名 PUBLIC zxing-cpp) #工程依赖三方库zxing-cpp + target_include_directories(工程库名 PRIVATE thirdparty/zxing-cpp/include) + ``` +## 编译工程 +编译工程,安装应用可以参考 [应用的安装和运行](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md#%E5%AE%89%E8%A3%85%E8%B0%83%E8%AF%95) + +## 运行效果 +- 在 [zxing-cpp](https://gitee.com/openharmony-tpc/openharmony_tpc_samples/tree/master/zxing-cpp)中,运行效果如下图 +  ![演示](pic/hap.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/zxing-cpp/docs/pic/hap.jpg b/zxing-cpp/docs/pic/hap.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ec6741faf3addbc804d28540ef1216c55d288809 Binary files /dev/null and b/zxing-cpp/docs/pic/hap.jpg differ diff --git a/zxing-cpp/docs/pic/result.png b/zxing-cpp/docs/pic/result.png new file mode 100644 index 0000000000000000000000000000000000000000..a2f0629289efaf51977efb6f941cc20d84400b98 Binary files /dev/null and b/zxing-cpp/docs/pic/result.png differ diff --git a/zxing-cpp/docs/rom_integrate.md b/zxing-cpp/docs/rom_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..60809f0408e10175c92e17210745c7b3aac60e26 --- /dev/null +++ b/zxing-cpp/docs/rom_integrate.md @@ -0,0 +1,149 @@ +# zxing-cpp如何集成到系统Rom + +## 准备源码工程 + +本库是基于OpenHarmony-v3.2-Beta2版本,在RK3568开发板上验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +### 准备系统Rom源码 + +系统源码获取请参考:[OpenHarmony源码下载](https://gitee.com/openharmony/docs/blob/OpenHarmony-v3.2-Beta3/zh-cn/release-notes/OpenHarmony-v3.2-beta2.md) + +### 增加构建脚本及配置文件 + +- 下载本仓库代码 + + ``` + cd ~ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ``` + tpc_c_cplusplus/zxing-cpp #三方库zxing-cpp的目录结构如下 + ├── adapted #存放三方库适配需要的代码文件 + ├── docs #存放三方库相关文档的文件夹 + ├── BUILD.gn #构建脚本,支持rom包集成 + ├── bundle.json #三方库组件定义文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将三方库拷贝到OpenHarmony源码的third_party目录下 + + ``` + cp ~/tpc_c_cplusplus/zxing-cpp ~/openharmony/third_party -rf + ``` + +### 准备三方库源码 + +``` +cd ~/openharmony/third_party/ #进入三方库目录 +git clone https://github.com/zxing-cpp/zxing-cpp.git #下载三方库源码 + +git clone https://github.com/nothings/stb.git #下载依赖库源码 +cp ~/openharmony/third_party/zxing-cpp/stb/stb_image_write.h ~/openharmony/third_party/zxing-cpp/core/src/stb_image_write.h +cp ~/openharmony/third_party/zxing-cpp/stb/stb_image.h ~/openharmony/third_party/zxing-cpp/core/src/stb_image.h +cp ~/openharmony/third_party/zxing-cpp/stb/deprecated/stb_image.c ~/openharmony/third_party/zxing-cpp/core/src/stb_image.c +``` + +## 系统Rom中引入三方库 + +准备完三方库代码后,我们需要将三方库加入到编译构建体系中。标准系统编译构建可以参考文档[标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) 我们默认三方库是属于OpenHarmony的thirdparty子系统,如果需要自己定义子系统参考文档[如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) 新增需要编译的组件,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件中,新增需要编译的组件,如下代码段所示,在thirdparty子系统下面新增zxing-cpp组件 + +``` + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "zxing-cpp", + "features": [] + } + ] + } +``` + +## 系统Rom中引入三方库测试程序 + +zxing-cpp原生库提供了测试用例,如需要引入测试程序,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件,对应组件的features中打开编译选项: + +``` +{ + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "zxing-cpp", + "features": [ "enable_zxing_cpp_test=true" ] + } + ] +} +``` + +## 编译工程 + +在OpenHarmony源码根目录下 + +``` +cd ~/openharmony +``` + +- 执行编译 + + ``` + ./build.sh --product-name rk3568 --ccache + ``` + +- 生成文件的路径 + + 可执行文件和库生成在out/rk3568/thirdparty/zxing-cpp + +## 运行效果 + +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都烧录整个镜像,我们使用hdc_std工具将文件推到开发板上 + +- 首先将hdc_std工具编译出来 工具编译出来所在路径out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe + + ``` + hb set #源码根目录下使用hb set 选择产品ohos-sdk + hb build #然后编译 + ``` + +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令行 + +- 将编译生成的ZXingWriter和ZXingReader可执行文件及原生库下的测试文件qrcode.png准备好 + +- 将准备好的文件推送到开发板,在windows命令行进行如下操作 + + ``` + hdc_std shell mount -o remount,rw / #修改系统权限为可读写 + hdc_std file send ZXingWriter /data #将可执行文件推入开发板data目录 + hdc_std file send ZXingReader /data #将可执行文件推入开发板data目录 + hdc_std file send libzxing-cpp.z.so /system/lib64 + hdc_std file send libzxing-cpp.z.so /system/lib + hdc_std file send qrcode.png /data #将测试文件推入开发板data目录 + hdc_std shell #进入开发板 + chmod 777 ZXingWriter #添加权限 + chmod 777 ZXingReader #添加权限 + ./ZXingReader –format QRCode /data/qrcode.png #解析二维码 + ./ZXingWriter –size 200x200 QRCode http://test.com /data/qrcodenew.png #生成二维码 + ``` + +- 运行测试程序 效果如下图 + +- ![result](pic/result.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) +- [如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) +- [标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) \ No newline at end of file