diff --git a/xz/BUILD.gn b/xz/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d46e25d54cc33973faae70fcc12ffb0687341129 --- /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 0000000000000000000000000000000000000000..391733f7e486b60005cb386898e1bba4d23e5815 --- /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 0000000000000000000000000000000000000000..4bd18d2ba0cc48fcccbe70d3d6d0aad5c35a61c6 --- /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 0000000000000000000000000000000000000000..1dd967bf31a2b227b64199bc9c96ec382b3c9beb --- /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 0000000000000000000000000000000000000000..09237318ec2ad19212fe05b85e39e4354cc765d4 --- /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 0000000000000000000000000000000000000000..69b6eac1db2729a171ae41438ca5330e6f9f053f --- /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 Binary files /dev/null and b/xz/docs/pic/test_result.jpg differ diff --git a/xz/docs/rom_integrate.md b/xz/docs/rom_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..a4730fddbbc65e5e4b32ebdb1b17f70a971ee238 --- /dev/null +++ b/xz/docs/rom_integrate.md @@ -0,0 +1,144 @@ +# xz如何集成到系统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-Beta1/zh-cn/release-notes/OpenHarmony-v3.2-beta1.md#%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96) + +## 增加构建脚本及配置文件 + +- 下载本仓库代码 + + ```shell + cd ~/ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + cd tpc_c_cplusplus/xz # 进入到仓库代码库目录 + ``` + + ```shell + xz + |-- adapted # 存放三方库适配需要的代码文件 + |-- docs # 存放三方库相关文档的文件夹 + |-- BUILD.gn # 构建脚本,支持rom包集成 + |-- bundle.json # 三方库组件定义文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将本仓库xz文件夹拷贝到third_party下 + + ```shell + cp ~/tpc_c_cplusplus/xz ~/openharmony/third_party/ -arf + ``` + +## 准备三方库源码 + +- 将源码下载到xz目录并将其解压出来。 + +``` shell +cd ~/openharmony/third_party/xz # 进入到xz目录 +git clone https://git.tukaani.org/xz.git -b v5.2.6 # 下载三方库xz 5.26版本代码 +``` + +## 系统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)
+相关配置已在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)