bit7z: add new recipe

bit7z is a cross-platform C++ static library that allows the
compression/extraction of archive files through a clean and simple
wrapper interface to the dynamic libraries from the 7-Zip project.
It supports compression and extraction to and from the filesystem or
the memory, reading archives metadata, updating existing ones,
creating multi-volume archives, operation progress callbacks, and many
other functionalities.

Recipe comments:
* 2 patches needed for successful build+ptest were submitted upstream
* to upstream dependency inclusion patch we'd have to completely rework
  dependency handling and would be probably against their concepts

Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Peter Marko 2025-04-07 18:16:25 +02:00 committed by Khem Raj
parent c7001b4048
commit 3e7086cdde
No known key found for this signature in database
GPG Key ID: BB053355919D3314
4 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,41 @@
From d504abaf2b0a514193f52df42098bc16de4718b2 Mon Sep 17 00:00:00 2001
From: Oz <rik20@live.it>
Date: Fri, 17 Jan 2025 21:23:59 +0100
Subject: [PATCH] Fix int8_t storage in BitPropVariant on Arm architectures
Upstream-Status: Backport [https://github.com/rikyoz/bit7z/commit/d504abaf2b0a514193f52df42098bc16de4718b2]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
include/bit7z/bitwindows.hpp | 4 ++++
src/bitpropvariant.cpp | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/bit7z/bitwindows.hpp b/include/bit7z/bitwindows.hpp
index 5849b956..2f29a989 100644
--- a/include/bit7z/bitwindows.hpp
+++ b/include/bit7z/bitwindows.hpp
@@ -126,7 +126,11 @@ struct PROPVARIANT {
WORD wReserved2;
WORD wReserved3;
union {
+#if defined( __arm__ ) || defined( __aarch64__ )
+ signed char cVal;
+#else
char cVal;
+#endif
unsigned char bVal;
short iVal;
unsigned short uiVal;
diff --git a/src/bitpropvariant.cpp b/src/bitpropvariant.cpp
index 1e7f094f..642e1268 100644
--- a/src/bitpropvariant.cpp
+++ b/src/bitpropvariant.cpp
@@ -157,7 +157,7 @@ BitPropVariant::BitPropVariant( uint64_t value ) noexcept: PROPVARIANT() {
BitPropVariant::BitPropVariant( int8_t value ) noexcept: PROPVARIANT() {
vt = VT_I1;
wReserved1 = 0;
- cVal = static_cast< char >( value );
+ cVal = static_cast< decltype(cVal) >( value );
}
BitPropVariant::BitPropVariant( int16_t value ) noexcept: PROPVARIANT() {

View File

@ -0,0 +1,52 @@
From bedeec4d57d29be7de91697277ace00ba87d3e75 Mon Sep 17 00:00:00 2001
From: Peter Marko <peter.marko@siemens.com>
Date: Tue, 1 Apr 2025 15:23:51 +0200
Subject: [PATCH] Fix reinterpret-cast compiler errors
Building on 32-bit arm, following warning/error occurs:
src/internal/windows.cpp: In function 'bit7z::OLECHAR* AllocStringBuffer(LPCSTR, uint32_t)':
src/internal/windows.cpp:79:6: error: cast from 'unsigned char*' to 'bstr_prefix_t*' {aka 'unsigned int*'} increases required alignment of target type [-Werror=cast-align]
79 | *reinterpret_cast< bstr_prefix_t* >( bstrBuffer ) = byteLength;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
git/src/internal/windows.cpp:83:19: error: cast from 'unsigned char*' to 'bit7z::BSTR' {aka 'wchar_t*'} increases required alignment of target type [-Werror=cast-align]
83 | BSTR result = reinterpret_cast< BSTR >( bstrBuffer + sizeof( bstr_prefix_t ) );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
Fix it by using the desired variable size right away and thus avoid
casting to an array with different alignment.
Upstream-Status: Backport [https://github.com/rikyoz/bit7z/commit/b2789ea9b0fbb2a74dbf6764ddb72d60659a3bce]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
src/internal/windows.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/internal/windows.cpp b/src/internal/windows.cpp
index 9304aed7..7bee5959 100644
--- a/src/internal/windows.cpp
+++ b/src/internal/windows.cpp
@@ -68,19 +68,18 @@ auto AllocStringBuffer( LPCSTR str, uint32_t byteLength ) -> BSTR {
// Allocating memory for storing the BSTR as a byte array.
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc, cppcoreguidelines-owning-memory)
- auto* bstrBuffer = static_cast< byte_t* >( std::calloc( bufferSize, sizeof( byte_t ) ) );
+ auto* bstrBuffer = static_cast< bstr_prefix_t* >( std::calloc( bufferSize, sizeof( byte_t ) ) );
if ( bstrBuffer == nullptr ) { // Failed to allocate memory for the BSTR buffer.
return nullptr;
}
// Storing the number of bytes of the BSTR as a prefix of it.
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
- *reinterpret_cast< bstr_prefix_t* >( bstrBuffer ) = byteLength;
+ *bstrBuffer = byteLength;
// The actual BSTR must point after the byteLength prefix.
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic, cppcoreguidelines-pro-type-reinterpret-cast)
- BSTR result = reinterpret_cast< BSTR >( bstrBuffer + sizeof( bstr_prefix_t ) );
+ BSTR result = reinterpret_cast< BSTR >( bstrBuffer + 1 );
if ( str != nullptr ) {
// Copying byte-by-byte the input string to the BSTR.
// Note: flawfinder warns about not checking for buffer overflows; this is a false alarm,

View File

@ -0,0 +1,29 @@
From 5e23482b89dfbed025eb5e505aba6420512bd9c3 Mon Sep 17 00:00:00 2001
From: Peter Marko <peter.marko@siemens.com>
Date: Tue, 1 Apr 2025 11:31:38 +0200
Subject: [PATCH] cmake: disable dependency inclusion
In Yocto we don't download dependencies, they are satisfied from
sysroot.
This cmake file would try to download dependency management tool CPM
even if all dependencies are satisfied.
Upstream-Status: Inappropriate [OE-specific]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5378bb3..5916025 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -194,7 +194,7 @@ include( cmake/BuildOptions.cmake )
include( cmake/CompilerOptions.cmake )
# dependencies
-include( cmake/Dependencies.cmake )
+#include( cmake/Dependencies.cmake )
# 7-zip source code
target_link_libraries( ${LIB_TARGET} PRIVATE 7-zip )

View File

@ -0,0 +1,29 @@
SUMMARY = "A C++ static library offering a clean and simple interface to the 7-Zip shared libraries"
HOMEPAGE = "https://github.com/rikyoz/bit7z"
LICENSE = "MPL-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=48a3fe23ed1353e0995dadfda05ffdb6"
SRC_URI = " \
git://github.com/rikyoz/bit7z.git;protocol=https;branch=master \
file://0001-cmake-disable-dependency-inclusion.patch \
file://0001-Fix-reinterpret-cast-compiler-errors.patch \
file://0001-Fix-int8_t-storage-in-BitPropVariant-on-Arm-architec.patch \
"
SRCREV = "386e00ad3286e7a10e5bb6d05a5b41b523fce623"
S = "${WORKDIR}/git"
inherit cmake
DEPENDS = "7zip"
EXTRA_OECMAKE += "-DBIT7Z_CUSTOM_7ZIP_PATH=${STAGING_INCDIR}/7zip"
do_install() {
install -d ${D}${libdir}
install -m 0644 ${S}/lib/*/*.a ${D}${libdir}
install -d ${D}${includedir}/${BPN}
install -m 0644 ${S}/include/${BPN}/*.hpp ${D}${includedir}/${BPN}
}