From ca56ee67da74c47e65363af52f6e7049624d8e50 Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Tue, 8 Nov 2022 11:15:34 +0800 Subject: [PATCH] add new thirdparty xz Signed-off-by: zhongluping <278527840@qq.com> --- xz/BUILD.gn | 210 +++++++++++++++ xz/README.OpenSource | 11 + xz/README_zh.md | 16 ++ xz/adapted/config.h | 515 ++++++++++++++++++++++++++++++++++++ xz/adapted/test_file.sh | 74 ++++++ xz/bundle.json | 33 +++ xz/docs/pic/test_result.jpg | Bin 0 -> 10231 bytes xz/docs/rom_integrate.md | 144 ++++++++++ 8 files changed, 1003 insertions(+) create mode 100644 xz/BUILD.gn create mode 100644 xz/README.OpenSource create mode 100644 xz/README_zh.md create mode 100644 xz/adapted/config.h create mode 100755 xz/adapted/test_file.sh create mode 100644 xz/bundle.json create mode 100755 xz/docs/pic/test_result.jpg create mode 100644 xz/docs/rom_integrate.md diff --git a/xz/BUILD.gn b/xz/BUILD.gn new file mode 100644 index 00000000..d46e25d5 --- /dev/null +++ b/xz/BUILD.gn @@ -0,0 +1,210 @@ +# Copyright (c) 2019-2022 Huawei Device Co., Ltd. All rights reserved. +# 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") +import("//build/ohos/ndk/ndk.gni") + +declare_args() { + enable_xz_test = false +} + +config("xz_config") { + cflags = [ + "-DHAVE_CONFIG_H", + "-DTUKLIB_SYMBOL_PREFIX=lzma_", + "-fvisibility=hidden", + "-fno-builtin", + "-Wall", + "-Wextra", + "-Wvla", + "-Wformat=2", + "-Winit-self", + "-Wmissing-include-dirs", + "-Wstrict-aliasing", + "-Wfloat-equal", + "-Wundef", + "-Wshadow", + "-Wpointer-arith", + "-Wbad-function-cast", + "-Wwrite-strings", + "-Waggregate-return", + "-Wstrict-prototypes", + "-Wold-style-definition", + "-Wmissing-prototypes", + "-Wmissing-declarations", + "-Wmissing-noreturn", + "-Wredundant-decls", + "-Wno-incompatible-pointer-types", + "-fPIC", + "-DPIC", + ] +} + +ohos_shared_library("xz_shared") { + sources = [ + "xz/src/common/tuklib_cpucores.c", + "xz/src/common/tuklib_physmem.c", + "xz/src/liblzma/check/check.c", + "xz/src/liblzma/check/crc32_fast.c", + "xz/src/liblzma/check/crc32_table.c", + "xz/src/liblzma/check/crc64_fast.c", + "xz/src/liblzma/check/crc64_table.c", + "xz/src/liblzma/check/sha256.c", + "xz/src/liblzma/common/alone_decoder.c", + "xz/src/liblzma/common/alone_encoder.c", + "xz/src/liblzma/common/auto_decoder.c", + "xz/src/liblzma/common/block_buffer_decoder.c", + "xz/src/liblzma/common/block_buffer_encoder.c", + "xz/src/liblzma/common/block_decoder.c", + "xz/src/liblzma/common/block_encoder.c", + "xz/src/liblzma/common/block_header_decoder.c", + "xz/src/liblzma/common/block_header_encoder.c", + "xz/src/liblzma/common/block_util.c", + "xz/src/liblzma/common/common.c", + "xz/src/liblzma/common/easy_buffer_encoder.c", + "xz/src/liblzma/common/easy_decoder_memusage.c", + "xz/src/liblzma/common/easy_encoder.c", + "xz/src/liblzma/common/easy_encoder_memusage.c", + "xz/src/liblzma/common/easy_preset.c", + "xz/src/liblzma/common/filter_buffer_decoder.c", + "xz/src/liblzma/common/filter_buffer_encoder.c", + "xz/src/liblzma/common/filter_common.c", + "xz/src/liblzma/common/filter_decoder.c", + "xz/src/liblzma/common/filter_encoder.c", + "xz/src/liblzma/common/filter_flags_decoder.c", + "xz/src/liblzma/common/filter_flags_encoder.c", + "xz/src/liblzma/common/hardware_cputhreads.c", + "xz/src/liblzma/common/hardware_physmem.c", + "xz/src/liblzma/common/index.c", + "xz/src/liblzma/common/index_decoder.c", + "xz/src/liblzma/common/index_encoder.c", + "xz/src/liblzma/common/index_hash.c", + "xz/src/liblzma/common/outqueue.c", + "xz/src/liblzma/common/stream_buffer_decoder.c", + "xz/src/liblzma/common/stream_buffer_encoder.c", + "xz/src/liblzma/common/stream_decoder.c", + "xz/src/liblzma/common/stream_encoder.c", + "xz/src/liblzma/common/stream_encoder_mt.c", + "xz/src/liblzma/common/stream_flags_common.c", + "xz/src/liblzma/common/stream_flags_decoder.c", + "xz/src/liblzma/common/stream_flags_encoder.c", + "xz/src/liblzma/common/vli_decoder.c", + "xz/src/liblzma/common/vli_encoder.c", + "xz/src/liblzma/common/vli_size.c", + "xz/src/liblzma/delta/delta_common.c", + "xz/src/liblzma/delta/delta_decoder.c", + "xz/src/liblzma/delta/delta_encoder.c", + "xz/src/liblzma/lz/lz_decoder.c", + "xz/src/liblzma/lz/lz_encoder.c", + "xz/src/liblzma/lz/lz_encoder_mf.c", + "xz/src/liblzma/lzma/fastpos_table.c", + "xz/src/liblzma/lzma/lzma2_decoder.c", + "xz/src/liblzma/lzma/lzma2_encoder.c", + "xz/src/liblzma/lzma/lzma_decoder.c", + "xz/src/liblzma/lzma/lzma_encoder.c", + "xz/src/liblzma/lzma/lzma_encoder_optimum_fast.c", + "xz/src/liblzma/lzma/lzma_encoder_optimum_normal.c", + "xz/src/liblzma/lzma/lzma_encoder_presets.c", + "xz/src/liblzma/rangecoder/price_table.c", + "xz/src/liblzma/simple/arm.c", + "xz/src/liblzma/simple/armthumb.c", + "xz/src/liblzma/simple/ia64.c", + "xz/src/liblzma/simple/powerpc.c", + "xz/src/liblzma/simple/simple_coder.c", + "xz/src/liblzma/simple/simple_decoder.c", + "xz/src/liblzma/simple/simple_encoder.c", + "xz/src/liblzma/simple/sparc.c", + "xz/src/liblzma/simple/x86.c", + ] + + include_dirs = [ + "//third_party/xz/xz", + "//third_party/xz/adapted", + "//third_party/xz/xz/src/liblzma", + "//third_party/xz/xz/src/liblzma/api", + "//third_party/xz/xz/src/liblzma/lzma", + "//third_party/xz/xz/src/liblzma/common", + "//third_party/xz/xz/src/liblzma/check", + "//third_party/xz/xz/src/liblzma/lz", + "//third_party/xz/xz/src/liblzma/rangecoder", + "//third_party/xz/xz/src/liblzma/api/lzma", + "//third_party/xz/xz/src/liblzma/delta", + "//third_party/xz/xz/src/liblzma/simple", + "//third_party/xz/xz/src/common", + ] + + configs = [ ":xz_config" ] + + part_name = "xz" + + subsystem_name = "thirdparty" +} + +ohos_executable("xz_test") { + sources = [ + "xz//src/xz/message.c", + "xz/src/common/tuklib_exit.c", + "xz/src/common/tuklib_mbstr_fw.c", + "xz/src/common/tuklib_mbstr_width.c", + "xz/src/common/tuklib_open_stdxxx.c", + "xz/src/common/tuklib_progname.c", + "xz/src/xz/args.c", + "xz/src/xz/coder.c", + "xz/src/xz/file_io.c", + "xz/src/xz/hardware.c", + "xz/src/xz/list.c", + "xz/src/xz/main.c", + "xz/src/xz/mytime.c", + "xz/src/xz/options.c", + "xz/src/xz/signals.c", + "xz/src/xz/suffix.c", + "xz/src/xz/util.c", + ] + include_dirs = [ + "xz/src/common/", + "xz/src/liblzma/api", + "//third_party/xz/adapted", + ] + configs = [ ":xz_config" ] + deps = [ ":xz_shared" ] + cflags = [ "-DLOCALEDIR=\"./\"" ] + part_name = "xz" +} + +ohos_executable("xzdec") { + sources = [ + "xz/src/common/tuklib_exit.c", + "xz/src/common/tuklib_progname.c", + "xz/src/xzdec/xzdec.c", + ] + include_dirs = [ + "xz/src/common/", + "xz/src/liblzma/api", + "//third_party/xz/adapted", + ] + configs = [ ":xz_config" ] + deps = [ ":xz_shared" ] + + part_name = "xz" +} + +group("xz") { + deps = [ ":xz_shared" ] + + if (enable_xz_test == true) { + deps += [ + ":xz_test", + ":xzdec", + ] + } +} diff --git a/xz/README.OpenSource b/xz/README.OpenSource new file mode 100644 index 00000000..391733f7 --- /dev/null +++ b/xz/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "xz", + "License": "GPLv2", + "License File": "COPYING.GPLv2", + "Version Number": "5.2.6", + "Owner": "huangminzhong2@huawei.com", + "Upstream URL": "https://tukaani.org/xz/", + "Description": "XZ Utils is free general-purpose data compression software with a high compression ratio. " + } +] diff --git a/xz/README_zh.md b/xz/README_zh.md new file mode 100644 index 00000000..4bd18d2b --- /dev/null +++ b/xz/README_zh.md @@ -0,0 +1,16 @@ +# xz 三方库说明 + +## 功能简介 + +XZ 是免费的通用数据压缩软件,具有较高的压缩比。 + +## 使用约束 + +- ROM版本:OpenHarmony3.2 Beta1 +- 三方库版本:5.2.6 +- 当前适配的功能:完成了 .lzma 格式文件的压缩、解压缩 +- [License : GPLv2](https://git.tukaani.org/?p=xz.git;a=blob;f=COPYING.GPLv2;h=d159169d1050894d3ea3b98e1c965c4058208fe1;hb=8dfed05bdaa4873833ba24279f02ad2db25effea) + +## 集成方式 + +- [系统Rom包集成](docs/rom_integrate.md) diff --git a/xz/adapted/config.h b/xz/adapted/config.h new file mode 100644 index 00000000..1dd967bf --- /dev/null +++ b/xz/adapted/config.h @@ -0,0 +1,515 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* How many MiB of RAM to assume if the real amount cannot be determined. */ +#define ASSUME_RAM 128 + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#define ENABLE_NLS 1 + +/* Define to 1 if bswap_16 is available. */ +/* #undef HAVE_BSWAP_16 */ + +/* Define to 1 if bswap_32 is available. */ +/* #undef HAVE_BSWAP_32 */ + +/* Define to 1 if bswap_64 is available. */ +/* #undef HAVE_BSWAP_64 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BYTESWAP_H */ + +/* Define to 1 if Capsicum is available. */ +/* #undef HAVE_CAPSICUM */ + +/* Define to 1 if the system has the type `CC_SHA256_CTX'. */ +/* #undef HAVE_CC_SHA256_CTX */ + +/* Define to 1 if you have the `CC_SHA256_Init' function. */ +/* #undef HAVE_CC_SHA256_INIT */ + +/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +/* #undef HAVE_CFLOCALECOPYCURRENT */ + +/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ + +/* Define to 1 if crc32 integrity check is enabled. */ +#define HAVE_CHECK_CRC32 1 + +/* Define to 1 if crc64 integrity check is enabled. */ +#define HAVE_CHECK_CRC64 1 + +/* Define to 1 if sha256 integrity check is enabled. */ +#define HAVE_CHECK_SHA256 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_COMMONCRYPTO_COMMONDIGEST_H */ + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +#define HAVE_DCGETTEXT 1 + +/* Define to 1 if you have the declaration of `CLOCK_MONOTONIC', and to 0 if + you don't. */ +#define HAVE_DECL_CLOCK_MONOTONIC 1 + +/* Define to 1 if you have the declaration of `program_invocation_name', and + to 0 if you don't. */ +#define HAVE_DECL_PROGRAM_INVOCATION_NAME 1 + +/* Define to 1 if any of HAVE_DECODER_foo have been defined. */ +#define HAVE_DECODERS 1 + +/* Define to 1 if arm decoder is enabled. */ +#define HAVE_DECODER_ARM 1 + +/* Define to 1 if armthumb decoder is enabled. */ +#define HAVE_DECODER_ARMTHUMB 1 + +/* Define to 1 if delta decoder is enabled. */ +#define HAVE_DECODER_DELTA 1 + +/* Define to 1 if ia64 decoder is enabled. */ +#define HAVE_DECODER_IA64 1 + +/* Define to 1 if lzma1 decoder is enabled. */ +#define HAVE_DECODER_LZMA1 1 + +/* Define to 1 if lzma2 decoder is enabled. */ +#define HAVE_DECODER_LZMA2 1 + +/* Define to 1 if powerpc decoder is enabled. */ +#define HAVE_DECODER_POWERPC 1 + +/* Define to 1 if sparc decoder is enabled. */ +#define HAVE_DECODER_SPARC 1 + +/* Define to 1 if x86 decoder is enabled. */ +#define HAVE_DECODER_X86 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if any of HAVE_ENCODER_foo have been defined. */ +#define HAVE_ENCODERS 1 + +/* Define to 1 if arm encoder is enabled. */ +#define HAVE_ENCODER_ARM 1 + +/* Define to 1 if armthumb encoder is enabled. */ +#define HAVE_ENCODER_ARMTHUMB 1 + +/* Define to 1 if delta encoder is enabled. */ +#define HAVE_ENCODER_DELTA 1 + +/* Define to 1 if ia64 encoder is enabled. */ +#define HAVE_ENCODER_IA64 1 + +/* Define to 1 if lzma1 encoder is enabled. */ +#define HAVE_ENCODER_LZMA1 1 + +/* Define to 1 if lzma2 encoder is enabled. */ +#define HAVE_ENCODER_LZMA2 1 + +/* Define to 1 if powerpc encoder is enabled. */ +#define HAVE_ENCODER_POWERPC 1 + +/* Define to 1 if sparc encoder is enabled. */ +#define HAVE_ENCODER_SPARC 1 + +/* Define to 1 if x86 encoder is enabled. */ +#define HAVE_ENCODER_X86 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getopt_long' function. */ +#define HAVE_GETOPT_LONG 1 + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#define HAVE_GETTEXT 1 + +/* Define if you have the iconv() function and it works. */ +/* #undef HAVE_ICONV */ + +/* Define to 1 if you have the header file. */ +// #define HAVE_IMMINTRIN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 to enable bt2 match finder. */ +#define HAVE_MF_BT2 1 + +/* Define to 1 to enable bt3 match finder. */ +#define HAVE_MF_BT3 1 + +/* Define to 1 to enable bt4 match finder. */ +#define HAVE_MF_BT4 1 + +/* Define to 1 to enable hc3 match finder. */ +#define HAVE_MF_HC3 1 + +/* Define to 1 to enable hc4 match finder. */ +#define HAVE_MF_HC4 1 + +/* Define to 1 if getopt.h declares extern int optreset. */ +/* #undef HAVE_OPTRESET */ + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `pthread_condattr_setclock' function. */ +#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1 + +/* Have PTHREAD_PRIO_INHERIT. */ +#define HAVE_PTHREAD_PRIO_INHERIT 1 + +/* Define to 1 if you have the `SHA256Init' function. */ +/* #undef HAVE_SHA256INIT */ + +/* Define to 1 if the system has the type `SHA256_CTX'. */ +/* #undef HAVE_SHA256_CTX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHA256_H */ + +/* Define to 1 if you have the `SHA256_Init' function. */ +/* #undef HAVE_SHA256_INIT */ + +/* Define to 1 if the system has the type `SHA2_CTX'. */ +/* #undef HAVE_SHA2_CTX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHA2_H */ + +/* Define to 1 if optimizing for size. */ +/* #undef HAVE_SMALL */ + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* 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_STRING_H 1 + +/* Define to 1 if `st_atimensec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_ATIMENSEC */ + +/* Define to 1 if `st_atimespec.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC */ + +/* Define to 1 if `st_atim.st__tim.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */ + +/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1 + +/* Define to 1 if `st_uatime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_UATIME */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BYTEORDER_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_CAPSICUM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_ENDIAN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `utime' function. */ +/* #undef HAVE_UTIME */ + +/* Define to 1 if you have the `utimes' function. */ +/* #undef HAVE_UTIMES */ + +/* Define to 1 or 0, depending whether the compiler supports simple visibility + declarations. */ +#define HAVE_VISIBILITY 1 + +/* Define to 1 if you have the `wcwidth' function. */ +#define HAVE_WCWIDTH 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Define to 1 if you have the `_futime' function. */ +/* #undef HAVE__FUTIME */ + +/* Define to 1 if _mm_movemask_epi8 is available. */ +#define HAVE__MM_MOVEMASK_EPI8 1 + +/* Define to 1 if the GNU C extension __builtin_assume_aligned is supported. + */ +#define HAVE___BUILTIN_ASSUME_ALIGNED 1 + +/* Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported. + */ +#define HAVE___BUILTIN_BSWAPXX 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 when using POSIX threads (pthreads). */ +#define MYTHREAD_POSIX 1 + +/* Define to 1 when using Windows Vista compatible threads. This uses features + that are not available on Windows XP. */ +/* #undef MYTHREAD_VISTA */ + +/* Define to 1 when using Windows 95 (and thus XP) compatible threads. This + avoids use of features that were added in Windows Vista. */ +/* #undef MYTHREAD_WIN95 */ + +/* Define to 1 to disable debugging code. */ +#define NDEBUG 1 + +/* Name of package */ +#define PACKAGE "xz" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "XZ Utils" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "XZ Utils 5.2.6" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "xz" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "https://tukaani.org/xz/" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "5.2.6" + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if the number of available CPU cores can be detected with + cpuset(2). */ +/* #undef TUKLIB_CPUCORES_CPUSET */ + +/* Define to 1 if the number of available CPU cores can be detected with + pstat_getdynamic(). */ +/* #undef TUKLIB_CPUCORES_PSTAT_GETDYNAMIC */ + +/* Define to 1 if the number of available CPU cores can be detected with + sched_getaffinity() */ +#define TUKLIB_CPUCORES_SCHED_GETAFFINITY 1 + +/* Define to 1 if the number of available CPU cores can be detected with + sysconf(_SC_NPROCESSORS_ONLN) or sysconf(_SC_NPROC_ONLN). */ +/* #undef TUKLIB_CPUCORES_SYSCONF */ + +/* Define to 1 if the number of available CPU cores can be detected with + sysctl(). */ +/* #undef TUKLIB_CPUCORES_SYSCTL */ + +/* Define to 1 if the system supports fast unaligned access to 16-bit and + 32-bit integers. */ +#define TUKLIB_FAST_UNALIGNED_ACCESS 1 + +/* Define to 1 if the amount of physical memory can be detected with + _system_configuration.physmem. */ +/* #undef TUKLIB_PHYSMEM_AIX */ + +/* Define to 1 if the amount of physical memory can be detected with + getinvent_r(). */ +/* #undef TUKLIB_PHYSMEM_GETINVENT_R */ + +/* Define to 1 if the amount of physical memory can be detected with + getsysinfo(). */ +/* #undef TUKLIB_PHYSMEM_GETSYSINFO */ + +/* Define to 1 if the amount of physical memory can be detected with + pstat_getstatic(). */ +/* #undef TUKLIB_PHYSMEM_PSTAT_GETSTATIC */ + +/* Define to 1 if the amount of physical memory can be detected with + sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES). */ +#define TUKLIB_PHYSMEM_SYSCONF 1 + +/* Define to 1 if the amount of physical memory can be detected with sysctl(). + */ +/* #undef TUKLIB_PHYSMEM_SYSCTL */ + +/* Define to 1 if the amount of physical memory can be detected with Linux + sysinfo(). */ +/* #undef TUKLIB_PHYSMEM_SYSINFO */ + +/* Define to 1 to use unsafe type punning, e.g. char *x = ...; *(int *)x = + 123; which violates strict aliasing rules and thus is undefined behavior + and might result in broken code. */ +/* #undef TUKLIB_USE_UNSAFE_TYPE_PUNNING */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Version number of package */ +#define VERSION "5.2.6" + +/* 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 + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to rpl_ if the getopt replacement functions and variables should be + used. */ +/* #undef __GETOPT_PREFIX */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint16_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +/* #undef uintptr_t */ diff --git a/xz/adapted/test_file.sh b/xz/adapted/test_file.sh new file mode 100755 index 00000000..09237318 --- /dev/null +++ b/xz/adapted/test_file.sh @@ -0,0 +1,74 @@ +# Copyright (c) 2022 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. + +#!/bin/sh +XZ=./xz_test +success=0 +failed=0 + +test -x "$XZ" || XZ= +if test -z "$XZ"; then + echo "NO xz test!!" + exit 77 +fi +echo "" +echo "test good xz files" +for I in ./files/good-*.xz +do + if "$XZ" -dc "$I" > /dev/null; then + let success=$success+1 + else + echo "Good file failed: $I" + let failed=$failed+1 + fi +done + +echo "test bad xz files" +for I in ./files/bad-*.xz +do + if "$XZ" -dc "$I" > /dev/null 2>&1; then + let failed=$failed+1 + echo "Bad file failed: $I" + else + let success=$success+1 + fi +done + +echo "test good lzma files" +for I in ./files/good-*.lzma +do + if "$XZ" -dc "$I" > /dev/null; then + let success=$success+1 + else + echo "Good file failed: $I" + let failed=$failed+1 + fi +done + +echo "test bad lzma files" +for I in ./files/bad-*.lzma +do + if test -n "$XZ" && "$XZ" -dc "$I" > /dev/null 2>&1; then + let failed=$failed+1 + echo "Bad file failed: $I" + else + let success=$success+1 + fi +done +echo "" +let total=$success+$failed +echo "XZ TEST OVER" +echo "test items : $total" +echo "SUCCESS:$success" +echo "FAILED:$failed" +#EOF diff --git a/xz/bundle.json b/xz/bundle.json new file mode 100644 index 00000000..69b6eac1 --- /dev/null +++ b/xz/bundle.json @@ -0,0 +1,33 @@ +{ + "name": "@ohos/xz", + "description": "XZ Utils is free general-purpose data compression software with a high compression ratio.", + "version": "3.1", + "license": "GPLv2", + "publishAs": "code-segment", + "segment": { + "destPath": "third_party/xz" + }, + "dirs": {}, + "scripts": {}, + "readmePath": { + "en": "README" + }, + "component": { + "name": "xz", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": [], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": ["//third_party/xz:xz"], + "inner_kits": [], + "test": [] + } + } +} \ No newline at end of file diff --git a/xz/docs/pic/test_result.jpg b/xz/docs/pic/test_result.jpg new file mode 100755 index 0000000000000000000000000000000000000000..1b7e4fc7c7b4a566dbcc9d79770b7dabf8407242 GIT binary patch literal 10231 zcmeHtXH-*Nx9$$1H|Z@XU69_3ARry-O7FcF=|oBZX`&be0qLSN1yOnjQIHM_C?ymr z0YO5GZvX?~#B=UB=No5?`=aOje%v2-XUwrzM)ufQ&)RFw`OIhTvzfE60L=|8T`d3v z0s)Tr4{){&SZhXjxdVWK0U!tf04YEO1_4C)5eRQLz~FyB{~7}(H2*RF^~Ho1AjF^W zL+bY?bpJj6bsYdodI|uw@G}IU4v-QPlMoY;l8}&)k&%*9GEh-cP*Aec(O+P=$i{K$ zA{#q9C$A_!C$}&UJG+3~6=87+X=!N=euZoDl1idd(vrV!0wN_D zfx!fXU?L(yJX}yT{&#?omWYl^;yN+Ci4zHTAcJJwqY_dcwb~xWo1gZ0rJRG}$;g?Q zSybwTr8pyN9QjcW_8(Sa<~V&fSE> zq~w%)sTrA%v$AuZp7cLM0{tsCHh3tReqQ&DPA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{{_C6z#4Iz8Ml-$p>ofp+j#g+E9cGj|~&6i9k>MOH+2}?d0QFXXJ8XN|v_tH?Z zM(G@AkZ(4bEZjG1z&b;_oE~U!D=}Zmxa*}Dx#oyARcTOJF*wb~=ouXyp>dN)+!?Tg znr&AJ?vj|!Q(3V&#Rn!a*j%wEz6KsR2s;CoYz|{s@C`Z#SS@TFatg=1u0I1V6k^0w zM*dprK59c9EAI}gvcF#(zMM-GXL?YQr~5cIoauJ#2I9~M{-P?~N0&NT_Lt(tJ=C)p z?$z;bi(M#?)3)-_8`;$u1U5nu)J-Hgk`Y*vo9jbmMc3VR8F5%;g|hcC^SLtN5?{dgMuG^nQ`g%ZACA{;w@HE}vv> zx=ic@5RTxzY)M(9z-9OwkBRt3#Z7IQ^&g-r<%Uep+ncaibCYU)JASSF5$YbWoFwBg z=`@f3HK0n)o-Y+uxTHFf@L}Gjy1UysmFHk8b|P!QSX@Ub_Rbe722f|{N?40Wwg|sb zQ>#y)uPB!klO?`~?@7fY_Om;OmwxOHTEBarXOY-51R-=KkFnVcb+WL|ry56m=m;_c z(m_0&1ybO9n!q`cAprlnNi9^78-3EvgNjfN&wK!dj!8U}N<+lxqmF%KQvrcz|GZ7$ z5Usdz?4^N@?%Gqhyu$3p@$vWRa1O)S^?IKP5$UDcBT=CzKMYKt{Akbbky6d`2)^N-(0_|F*he> +我们默认三方库是属于OpenHarmony的thirdparty子系统,如果需要自己定义子系统参考文档[如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md)
+相关配置已在bundle.json中完成,我们只需要在产品定义中添加xz组件即可。 + +- 在产品配置文件中添加xz的组件
+ 打开//vendor/hihope/rk3568/config.json文件,找到thirdparty子系统并添加xz的组件 + + ``` json + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "xz", + "features": [] + } + ] + }, + ``` + +## 系统Rom中引入三方库测试程序 + +如果需要编译测试用例,在OpenHarmony源码的vendor/hihope/rk356/config.json文件,对应组件的features中打开编译选项,如下 + +``` json + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "xz", + "features": ["enable_xz_test=true"] + } + ] + }, +``` + +## 编译工程 + +- 选择产品 + +```shell +hb set ## hb set 命令会列出所有可选平台,这里我们选择rk3568 +``` + +- 运行编译 + +```shell +hb build --target-cpu arm ## 编译32位系统 +hb build --target-cpu arm64 ## 编译64位系统 +``` + +- 生成文件的路径,可执行文件和库文件都在out/rk3568/thirdparty/xz目录下,同时也打包到了镜像中 + +## 运行效果 + +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都烧录整个镜像,我们使用hdc_std工具将文件推到开发板上 + +- 首先将hdc_std工具编译出来 + + ```shell + hb set #源码根目录下使用hb set 选择产品ohos-sdk + hb build #最后工具编译出来在out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe + ``` + +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令行 +- 将原生库测试需要的所有文件打包成xz.tar,并拷贝到windows下 +- 将文件推送到开发板,在windows命令行进行如下操作 + + ```shell + hdc_std shell mount -o remount,rw / #修改系统权限为可读写 + hdc_std file send xz.tar / #将文件包推入开发板 + hdc_std shell #进入开发板 + tar xvf xz.tar #解压 + #注意需要将库拷贝到/system/lib 或者/system/lib64目录下 + ``` + +- 运行效果
+ 原生库提供了多个测试脚本,这里以运行测试xz与lzma文件的[test_file.sh](../adapted/test_file.sh)为例显示运行效果,如下图: +  ![result](./pic/test_result.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) -- Gitee