7zip: install headers
PATCH 1/3 7zip: install headers
From: Peter Marko <[email protected]>
This is needed for bit7z recipe.
But in general, using 7-zip as a library also requires headers.
Leave our Windows headers.
Install also readme as it contains version information and is used by bit7z.
--- meta-oe/recipes-extended/7zip/7zip_24.09.bb | 9 +++++++++ 1 file changed, 9 insertions(+)
meta-oe/recipes-extended/7zip/7zip_24.09.bb +9 -0
@@ -59,6 +59,15 @@ do_install() { install -d ${D}${libdir} install -m 0755 ${S}/CPP/7zip/Bundles/Format7zF/b/${INSTALLDIR}/7z.so ${D}${libdir}/lib7z.so ln -rsn ${D}${libdir}/lib7z.so ${D}${bindir}/7z.so + + # install headers (for development) and readme (for version information) + for header_file in $(find ${S}/CPP/${BPN} ${S}/CPP/Common ${S}/C -name "*.h"); do + header_dir=$(dirname $(echo $header_file | sed "s|${S}/||")) + install -d ${D}${includedir}/${BPN}/$header_dir + install -m 0644 $header_file ${D}${includedir}/${BPN}/$header_dir + done + install -d ${D}${includedir}/${BPN}/DOC + install -m 0644 ${S}/DOC/readme.txt ${D}${includedir}/${BPN}/DOC } PROVIDES += "p7zip"
PATCH 2/3 bit7z: add new recipe
From: Peter Marko <[email protected]>
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
--- ...ge-in-BitPropVariant-on-Arm-architec.patch | 41 +++++++++++++++ ...Fix-reinterpret-cast-compiler-errors.patch | 52 +++++++++++++++++++ ...1-cmake-disable-dependency-inclusion.patch | 29 +++++++++++ meta-oe/recipes-extended/7zip/bit7z_4.0.9.bb | 29 +++++++++++ 4 files changed, 151 insertions(+) create mode 100644 meta-oe/recipes-extended/7zip/bit7z/0001-Fix-int8_t-storage-in-BitPropVariant-on-Arm-architec.patch create mode 100644 meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch create mode 100644 meta-oe/recipes-extended/7zip/bit7z/0001-cmake-disable-dependency-inclusion.patch create mode 100644 meta-oe/recipes-extended/7zip/bit7z_4.0.9.bb
meta-oe/recipes-extended/7zip/bit7z/0001-Fix-int8_t-storage-in-BitPropVariant-on-Arm-architec.patch new file +41 -0
@@ -0,0 +1,41 @@ +From d504abaf2b0a514193f52df42098bc16de4718b2 Mon Sep 17 00:00:00 2001 +From: Oz <[email protected]> +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 <[email protected]> +--- + 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() {
meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch new file +52 -0
52 lines not on this page · raw message
meta-oe/recipes-extended/7zip/bit7z/0001-cmake-disable-dependency-inclusion.patch new file +29 -0
@@ -0,0 +1,29 @@ +From 5e23482b89dfbed025eb5e505aba6420512bd9c3 Mon Sep 17 00:00:00 2001 +From: Peter Marko <[email protected]> +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 <[email protected]> +--- + 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 )
meta-oe/recipes-extended/7zip/bit7z_4.0.9.bb new file +29 -0
@@ -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} +}
PATCH 3/3 bit7z: add ptest support
In reply to Peter MarkoFrom: Peter Marko <[email protected]>
Main problem with ptest for this component is that it uses cmake's FetchContent and CPM to get dependencies.
This adds lot of ugly code to the recipe including conditional patch.
Second big problem is that tests need BIT7Z_DISABLE_USE_STD_FILESYSTEM which uses test library. This means that when building with ptests, the code is significantly different than when building without it. But in production case we don't want to use testing library... This is known at upstream and will be fixed eventually as github CI is failing on this too when submitting unrelated patches upstream.
Other considerations:
* created patch for new cmake option to pass path to test data on target
* created patch for new cmake option to pass path to lib7zip on target
* skipped test which consumes too much RAM (it passes if machine has plenty of RAM)
* testdata contains files for other architectures, so INSANE_SKIP is needed for ptest package
* created patch for tests failing with musl
Tests usually take 9s on my build machine so added them to fast ptests. However since the dependency 7zip recipe does not build on 64-bit architectures, I could not add it to PTESTS_FAST_META_OE.
--- ...tests-on-target-when-cross-compiling.patch | 45 +++++++++++++ ...ecifying-path-to-7z-library-in-tests.patch | 48 ++++++++++++++ .../7zip/bit7z/0001-Fix-tests-with-musl.patch | 51 +++++++++++++++ meta-oe/recipes-extended/7zip/bit7z/run-ptest | 18 ++++++ meta-oe/recipes-extended/7zip/bit7z_4.0.9.bb | 64 ++++++++++++++++++- 5 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 meta-oe/recipes-extended/7zip/bit7z/0001-Allow-running-tests-on-target-when-cross-compiling.patch create mode 100644 meta-oe/recipes-extended/7zip/bit7z/0001-Allow-specifying-path-to-7z-library-in-tests.patch create mode 100644 meta-oe/recipes-extended/7zip/bit7z/0001-Fix-tests-with-musl.patch create mode 100644 meta-oe/recipes-extended/7zip/bit7z/run-ptest
meta-oe/recipes-extended/7zip/bit7z/0001-Allow-running-tests-on-target-when-cross-compiling.patch new file +45 -0
@@ -0,0 +1,45 @@ +From 9f0eed91d32ec2f310bd5c23af187f888394fcb4 Mon Sep 17 00:00:00 2001 +From: Peter Marko <[email protected]> +Date: Wed, 2 Apr 2025 09:33:03 +0200 +Subject: [PATCH] Allow running tests on target when cross-compiling + +When bit7z is Cross-compiled, target device does not contain +source/build directory anymore and thus path to test data is different. +Make it possible to pass the new path to cmake. + +Upstream-Status: Pending +Signed-off-by: Peter Marko <[email protected]> +--- + tests/CMakeLists.txt | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt +index 60da280..dbdff1f 100644 +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -49,6 +49,11 @@ add_executable( ${TESTS_TARGET_PUBLIC} ${SOURCE_FILES} ${PUBLIC_API_SOURCE_FILES + + if( BIT7Z_TESTS_FILESYSTEM ) + set( BIT7Z_TESTS_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/data ) ++ if( NOT BIT7Z_TESTS_DATA_DIR_TARGET ) ++ set( BIT7Z_TESTS_DATA_DIR_TARGET ${BIT7Z_TESTS_DATA_DIR} ) ++ else() ++ message( STATUS "Custom test data dir on target: ${BIT7Z_TESTS_DATA_DIR_TARGET}" ) ++ endif() + + include( FetchContent ) + FetchContent_Declare( bit7z-test-data +@@ -61,11 +66,11 @@ if( BIT7Z_TESTS_FILESYSTEM ) + message( STATUS "Tests data directory: ${BIT7Z_TESTS_DATA_DIR}" ) + target_compile_definitions( ${TESTS_TARGET} PRIVATE + BIT7Z_TESTS_FILESYSTEM +- BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR}" ) ++ BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR_TARGET}" ) + target_compile_definitions( ${TESTS_TARGET_PUBLIC} PRIVATE + BIT7Z_TESTS_PUBLIC_API_ONLY + BIT7Z_TESTS_FILESYSTEM +- BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR}" ) ++ BIT7Z_TESTS_DATA_DIR="${BIT7Z_TESTS_DATA_DIR_TARGET}" ) + if( NOT EXISTS ${BIT7Z_TESTS_DATA_DIR}/test_filesystem/empty ) + file( MAKE_DIRECTORY ${BIT7Z_TESTS_DATA_DIR}/test_filesystem/empty ) + endif()
meta-oe/recipes-extended/7zip/bit7z/0001-Allow-specifying-path-to-7z-library-in-tests.patch new file +48 -0
48 lines not on this page · raw message
meta-oe/recipes-extended/7zip/bit7z/0001-Fix-tests-with-musl.patch new file +51 -0
51 lines not on this page · raw message
meta-oe/recipes-extended/7zip/bit7z/run-ptest new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh + +# Disabled tests: +# "winapi: Allocating BSTR string from nullptr C strings" +# this test is memory hungry, it allocates 800MB chunks +# it succeeds when there is enough free RAM, but most machines don't have it + +if /usr/lib/bit7z/ptest/bit7z-tests ~"winapi: Allocating BSTR string from nullptr C strings"; then + echo "PASS: bit7z-tests" +else + echo "FAIL: bit7z-tests" +fi + +if /usr/lib/bit7z/ptest/bit7z-tests-public; then + echo "PASS: bit7z-tests-public" +else + echo "FAIL: bit7z-tests-public" +fi
meta-oe/recipes-extended/7zip/bit7z_4.0.9.bb +62 -2
86 lines not on this page · raw message