diff --git a/libtiff/BUILD.gn b/libtiff/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c3434fc98c6e8d83c921df8bf21275551cda5ad4 --- /dev/null +++ b/libtiff/BUILD.gn @@ -0,0 +1,319 @@ +# Copyright (c) 2021 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. + +import("//build/ohos.gni") + +declare_args() { + enable_libtiff_test = false +} + +config("libtiff_config") { + include_dirs = [ + "libtiff/libtiff/libtiff", + "//third_party/libjpeg", + "//third_party/zlib", + "adapted", + ] +} + +ohos_shared_library("libtiff_shared") { + sources = [ + "libtiff/libtiff/tif_aux.c", + "libtiff/libtiff/tif_close.c", + "libtiff/libtiff/tif_codec.c", + "libtiff/libtiff/tif_color.c", + "libtiff/libtiff/tif_compress.c", + "libtiff/libtiff/tif_dir.c", + "libtiff/libtiff/tif_dirinfo.c", + "libtiff/libtiff/tif_dirread.c", + "libtiff/libtiff/tif_dirwrite.c", + "libtiff/libtiff/tif_dumpmode.c", + "libtiff/libtiff/tif_error.c", + "libtiff/libtiff/tif_extension.c", + "libtiff/libtiff/tif_fax3.c", + "libtiff/libtiff/tif_fax3sm.c", + "libtiff/libtiff/tif_flush.c", + "libtiff/libtiff/tif_getimage.c", + "libtiff/libtiff/tif_jbig.c", + "libtiff/libtiff/tif_jpeg.c", + "libtiff/libtiff/tif_jpeg_12.c", + "libtiff/libtiff/tif_lerc.c", + "libtiff/libtiff/tif_luv.c", + "libtiff/libtiff/tif_lzma.c", + "libtiff/libtiff/tif_lzw.c", + "libtiff/libtiff/tif_next.c", + "libtiff/libtiff/tif_ojpeg.c", + "libtiff/libtiff/tif_open.c", + "libtiff/libtiff/tif_packbits.c", + "libtiff/libtiff/tif_pixarlog.c", + "libtiff/libtiff/tif_predict.c", + "libtiff/libtiff/tif_print.c", + "libtiff/libtiff/tif_read.c", + "libtiff/libtiff/tif_strip.c", + "libtiff/libtiff/tif_swab.c", + "libtiff/libtiff/tif_thunder.c", + "libtiff/libtiff/tif_tile.c", + "libtiff/libtiff/tif_unix.c", + "libtiff/libtiff/tif_version.c", + "libtiff/libtiff/tif_warning.c", + "libtiff/libtiff/tif_webp.c", + "libtiff/libtiff/tif_write.c", + "libtiff/libtiff/tif_zip.c", + "libtiff/libtiff/tif_zstd.c", + ] + configs = [ ":libtiff_config" ] + deps = [ + "//third_party/libjpeg:libjpeg_static", + "//third_party/zlib:libz", + ] + part_name = "libtiff" +} + +config("test_config") { + include_dirs = [ + "libtiff/tools", + "libtiff/libtiff", + "libtiff/port", + "adapted", + ] + + cflags_cc = [] +} +ohos_executable("fax2ps") { + sources = [ "libtiff/tools/fax2ps.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("fax2tiff") { + sources = [ "libtiff/tools/fax2tiff.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("pal2rgb") { + sources = [ "libtiff/tools/pal2rgb.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("ppm2tiff") { + sources = [ "libtiff/tools/ppm2tiff.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("raw2tiff") { + sources = [ "libtiff/tools/raw2tiff.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("rgb2ycbcr") { + sources = [ "libtiff/tools/rgb2ycbcr.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("thumbnail") { + sources = [ "libtiff/tools/thumbnail.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiff2bw") { + sources = [ "libtiff/tools/tiff2bw.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiff2pdf") { + sources = [ "libtiff/tools/tiff2pdf.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiff2ps") { + sources = [ "libtiff/tools/tiff2ps.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiff2rgba") { + sources = [ "libtiff/tools/tiff2rgba.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffcmp") { + sources = [ "libtiff/tools/tiffcmp.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffcp") { + sources = [ "libtiff/tools/tiffcp.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffcrop") { + sources = [ "libtiff/tools/tiffcrop.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffdither") { + sources = [ "libtiff/tools/tiffdither.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffdump") { + sources = [ "libtiff/tools/tiffdump.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffinfo") { + sources = [ "libtiff/tools/tiffinfo.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffmedian") { + sources = [ "libtiff/tools/tiffmedian.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffset") { + sources = [ "libtiff/tools/tiffset.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +ohos_executable("tiffsplit") { + sources = [ "libtiff/tools/tiffsplit.c" ] + + configs = [ ":test_config" ] + + deps = [ ":libtiff_shared" ] + + part_name = "libtiff" +} + +group("libtiff") { + deps = [ ":libtiff_shared" ] + + if (enable_libtiff_test) { + deps += [ + ":fax2ps", + ":fax2tiff", + ":pal2rgb", + ":ppm2tiff", + ":raw2tiff", + ":rgb2ycbcr", + ":thumbnail", + ":tiff2bw", + ":tiff2pdf", + ":tiff2ps", + ":tiff2rgba", + ":tiffcmp", + ":tiffcp", + ":tiffcrop", + ":tiffdither", + ":tiffdump", + ":tiffinfo", + ":tiffmedian", + ":tiffset", + ":tiffsplit", + ] + } +} diff --git a/libtiff/README.OpenSource b/libtiff/README.OpenSource new file mode 100755 index 0000000000000000000000000000000000000000..262d6f3c8faf336c6a56de035f67258e3dbd2f11 --- /dev/null +++ b/libtiff/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libtiff", + "License": "libtiff License", + "License File": "COPYRIGHT", + "Version Number": "v4.3.0", + "Owner": "huangminzhong2@huawei.com", + "Upstream URL": "https://gitlab.com/libtiff/libtiff.git", + "Description": "a small collection of tools for doingsimple manipulations of TIFF images, and documentation on the library and tools." + } +] diff --git a/libtiff/README_zh.md b/libtiff/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..1e1ddb5ef5a1c0a2eaf27a0880f976286aa867bc --- /dev/null +++ b/libtiff/README_zh.md @@ -0,0 +1,23 @@ +# libtiff三方库说明 +## 功能简介 +libtiff是一个用来读写标签图片(tiff)的库。该库还支持如下文件格式的转化。 +## 使用约束 +- ROM版本:OpenHarmony-v3.2-Beta1 + +- 三方库版本:v4.3.0 + +- 当前适配的功能:支持如下格式转换 + + | 源文件格式 | 转化后格式 | + | :--------: | :--------: | + | tiff | tiff | + | pgm | tiff | + | g3 | tiff | + | pbm | tiff | + | ppm | tiff | + | tiff | pdf | + | tiff | ps | + +- [libtiff license](https://gitlab.com/libtiff/libtiff/-/blob/v4.3.0/COPYRIGHT) +## 集成方式 ++ [系统Rom包集成](docs/rom_integrate.md) diff --git a/libtiff/adapted/libport_config.h b/libtiff/adapted/libport_config.h new file mode 100755 index 0000000000000000000000000000000000000000..d708dae412500182d5a8cf02d4d75b1129c29751 --- /dev/null +++ b/libtiff/adapted/libport_config.h @@ -0,0 +1,13 @@ +/* libtiff/libport_config.h.cmake.in. Not generated, but originated from autoheader. */ +/* This file must be kept up-to-date with needed substitutions from port/libport_config.h.in. */ + +#ifndef _LIBPORT_CONFIG_H_ +#define _LIBPORT_CONFIG_H_ + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +#endif /* _LIBPORT_CONFIG_H_ */ diff --git a/libtiff/adapted/tif_config.h b/libtiff/adapted/tif_config.h new file mode 100755 index 0000000000000000000000000000000000000000..98948a208be7e269614a99994cde840a175082ab --- /dev/null +++ b/libtiff/adapted/tif_config.h @@ -0,0 +1,155 @@ +/* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */ +/* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */ + +#include "tiffconf.h" + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 + +/* enable partial strip reading for large strips (experimental) */ +/* #undef CHUNKY_STRIP_READ_SUPPORT */ + +/* Support C++ stream API (requires C++ compiler) */ +#define CXX_SUPPORT 1 + +/* enable deferred strip/tile offset/size loading (experimental) */ +/* #undef DEFER_STRILE_LOAD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */ +#define HAVE_DECL_OPTARG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +/* #undef HAVE_FSEEKO */ + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GLUT_GLUT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GL_GLUT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GL_GLU_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GL_GL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `jbg_newlen' function. */ +#define HAVE_JBG_NEWLEN 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENGL_GLU_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENGL_GL_H */ + +/* Define to 1 if you have the `setmode' function. */ +/* #undef HAVE_SETMODE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* 8/12 bit libjpeg dual mode enabled */ +/* #undef JPEG_DUAL_MODE_8_12 */ + +/* Support LERC compression */ +/* #undef LERC_SUPPORT */ + +/* 12bit libjpeg primary include file with path */ +#define LIBJPEG_12_PATH "" + +/* Support LZMA2 compression */ +/* #undef LZMA_SUPPORT */ + +/* Name of package */ +#define PACKAGE "LibTIFF Software" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "tiff@lists.maptools.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "LibTIFF Software" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "LibTIFF Software 4.3.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "tiff" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "4.3.0" + +/* Size of size_t */ +#define SIZEOF_SIZE_T 8 + +/* Default size of the strip in bytes (when strip chopping enabled) */ +#define STRIP_SIZE_DEFAULT 8192 + +/* define to use win32 IO system */ +/* #undef USE_WIN32_FILEIO */ + +/* Version number of package */ +#define VERSION "4.3.0" + +/* Support WEBP compression */ +/* #undef WEBP_SUPPORT */ + +/* Support ZSTD compression */ +/* #undef ZSTD_SUPPORT */ + + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +#if !defined(__MINGW32__) +# define TIFF_SIZE_FORMAT "zu" +#endif +#if SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId64 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu64 +# endif +#elif SIZEOF_SIZE_T == 4 +# define TIFF_SSIZE_FORMAT PRId32 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu32 +# endif +#else +# error "Unsupported size_t size; please submit a bug report" +#endif diff --git a/libtiff/adapted/tiffconf.h b/libtiff/adapted/tiffconf.h new file mode 100755 index 0000000000000000000000000000000000000000..ce51e612b83c3d1f39d77af86e6611027fdde589 --- /dev/null +++ b/libtiff/adapted/tiffconf.h @@ -0,0 +1,127 @@ +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + + +#include +#include +#include + + +/* Signed 16-bit type */ +#define TIFF_INT16_T int16_t + +/* Signed 32-bit type */ +#define TIFF_INT32_T int32_t + +/* Signed 64-bit type */ +#define TIFF_INT64_T int64_t + +/* Signed 8-bit type */ +#define TIFF_INT8_T int8_t + +/* Unsigned 16-bit type */ +#define TIFF_UINT16_T uint16_t + +/* Unsigned 32-bit type */ +#define TIFF_UINT32_T uint32_t + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T uint64_t + +/* Unsigned 8-bit type */ +#define TIFF_UINT8_T uint8_t + +/* Signed size type */ +#define TIFF_SSIZE_T int64_t + +/* Compatibility stuff. */ + +/* Define as 0 or 1 according to the floating point format supported by the + machine */ +#define HAVE_IEEEFP 1 + +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian + (Intel) */ +#define HOST_BIGENDIAN 0 + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Support JPEG compression (requires IJG JPEG library) */ +#define JPEG_SUPPORT 1 + +/* Support JBIG compression (requires JBIG-KIT library) */ +/* #undef JBIG_SUPPORT */ + +/* Support LERC compression */ +/* #undef LERC_SUPPORT */ + +/* Support LogLuv high dynamic range encoding */ +#define LOGLUV_SUPPORT 1 + +/* Support LZW algorithm */ +#define LZW_SUPPORT 1 + +/* Support NeXT 2-bit RLE algorithm */ +#define NEXT_SUPPORT 1 + +/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation + fails with unpatched IJG JPEG library) */ +#define OJPEG_SUPPORT 1 + +/* Support Macintosh PackBits algorithm */ +#define PACKBITS_SUPPORT 1 + +/* Support Pixar log-format algorithm (requires Zlib) */ +#define PIXARLOG_SUPPORT 1 + +/* Support ThunderScan 4-bit RLE algorithm */ +#define THUNDER_SUPPORT 1 + +/* Support Deflate compression */ +#define ZIP_SUPPORT 1 + +/* Support libdeflate enhanced compression */ +/* #undef LIBDEFLATE_SUPPORT */ + +/* Support strip chopping (whether or not to convert single-strip uncompressed + images to multiple strips of ~8Kb to reduce memory usage) */ +#define STRIPCHOP_DEFAULT 1 + +/* Enable SubIFD tag (330) support */ +#define SUBIFD_SUPPORT 1 + +/* Treat extra sample as alpha (default enabled). The RGBA interface will + treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many + packages produce RGBA files but don't mark the alpha properly. */ +#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 + +/* Support MS MDI magic number files as TIFF */ +#define MDI_SUPPORT 1 + +/* + * Feature support definitions. + * XXX: These macros are obsoleted. Don't use them in your apps! + * Macros stays here for backward compatibility and should be always defined. + */ +#define COLORIMETRY_SUPPORT +#define YCBCR_SUPPORT +#define CMYK_SUPPORT +#define ICC_SUPPORT +#define PHOTOSHOP_SUPPORT +#define IPTC_SUPPORT + +#endif /* _TIFFCONF_ */ diff --git a/libtiff/bundle.json b/libtiff/bundle.json new file mode 100755 index 0000000000000000000000000000000000000000..8b9b9f0874a39656011a18f3f44acd5d3dfbec1e --- /dev/null +++ b/libtiff/bundle.json @@ -0,0 +1,33 @@ +{ + "name": "@ohos/libtiff", + "description": "a small collection of tools for doingsimple manipulations of TIFF images, and documentation on the library and tools.", + "version": "v4.3.0", + "license": "libtiff License", + "publishAs": "", + "segment": { + "destPath": "third_party/libtiff" + }, + "dirs": {}, + "scripts": {}, + "readmePath": { + "en": "README" + }, + "component": { + "name": "libtiff", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": ["standard"], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": ["//third_party/libtiff:libtiff"], + "inner_kits": [], + "test": [] + } + } +} diff --git a/libtiff/docs/pic/result.png b/libtiff/docs/pic/result.png new file mode 100755 index 0000000000000000000000000000000000000000..f48367939c2d4529a678cb3341df611935cc127c Binary files /dev/null and b/libtiff/docs/pic/result.png differ diff --git a/libtiff/docs/rom_integrate.md b/libtiff/docs/rom_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..22510b1704ef2207f15edea9defdb4183a261605 --- /dev/null +++ b/libtiff/docs/rom_integrate.md @@ -0,0 +1,111 @@ +# libtiff如何集成到系统Rom +## 准备源码工程 +本库是基于OpenHarmony-v3.2-Beta1版本,在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-Beta2/zh-cn/release-notes/OpenHarmony-v3.2-beta1.md) +### 增加构建脚本及配置文件 +- 下载本仓库代码 + ``` + cd ~ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/libtiff #三方库xerces-c的目录结构如下 + ├── adapted #存放三方库适配需要的代码文件 + ├── docs #存放三方库相关文档的文件夹 + ├── BUILD.gn #构建脚本,支持rom包集成 + ├── bundle.json #三方库组件定义文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` +- 将三方库拷贝到OpenHarmony源码的third_party目录下 + ``` + cp ~/tpc_c_cplusplus/libtiff ~/openharmony/third_party -rf + ``` +### 准备三方库源码 +``` +cd ~/openharmony/third_party/libtiff #进入三方库目录 +git clone https://gitlab.com/libtiff/libtiff.git -b v4.3.0 --depth=1 #下载三方库源码 +``` +## 系统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子系统下面新增libtiff组件 + +``` + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "libtiff", + "features": [] + } + ] + } + +``` +## 系统Rom中引入三方库测试程序 +如果需要编译测试用例,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件,对应组件的features中打开编译选项,如下 +``` + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "libtiff", + "features": ["enable_libtiff_test=true"] + } + ] + } +``` +## 编译工程 +在OpenHarmony源码根目录下 +``` +cd ~/openharmony +``` +- 选择平台 + ``` + hb set #hb set 命令会列出所有可选平台,这里我们选择rk3568 + ``` +- 执行编译 + ``` + hb build --target-cpu arm #编译32位系统 + hb build --target-cpu arm64 #编译64位系统 + ``` +- 生成文件的路径,可执行文件和库文件都在out/rk3568/thirdparty/libtiff目录下,同时也打包到了镜像中 +## 运行效果 +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都烧录整个镜像,我们使用hdc_std工具将文件推到开发板上 +- 首先将hdc_std工具编译出来 + 工具编译出来所在路径out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe + + ``` + hb set #源码根目录下使用hb set 选择产品ohos-sdk + hb build #然后编译 + ``` +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令行 +- 将原生库测试需要的所有文件打包成libtiff.tar,并拷贝到windows下 +- 将文件推送到开发板,在windows命令行进行如下操作 + ``` + hdc_std shell mount -oremount,rw / #修改系统权限为可读写 + hdc_std file send libtiff.tar / #将文件包推入开发板 + hdc_std shell #进入开发板 + tar xvf libtiff.tar #解压 + #注意需要将库拷贝到/system/lib 或者/system/lib64目录下 + ``` +- 运行测试程序 + 测试用例非常多,这里演示其中几个用例,如下图 + ![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