Skip to content

Commit

Permalink
[Test-linux] Add option for downloading and building for p7zip
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Oct 31, 2023
1 parent 96c896d commit 5bb8b32
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 29 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/test_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,25 @@ jobs:
bit7z_auto_format: [OFF, ON]
bit7z_regex_matching: [OFF, ON]
bit7z_link_libcpp: [OFF, ON]
bit7z_7zip_version: [22.01, 23.01]
bit7z_7zip_version: [16.02, 22.01, 23.01]
bit7z_build_for_p7zip: [OFF, ON]
include:
- c_compiler: gcc-9
cpp_compiler: g++-9
use_system_7zip: OFF
- c_compiler: gcc-10
cpp_compiler: g++-10
use_system_7zip: OFF
- c_compiler: gcc-11
cpp_compiler: g++-11
use_system_7zip: OFF
- c_compiler: gcc-12
cpp_compiler: g++-12
use_system_7zip: OFF
- c_compiler: gcc-13
cpp_compiler: g++-13
use_system_7zip: OFF
- c_compiler: clang-13
cpp_compiler: clang++-13
use_system_7zip: OFF
- c_compiler: clang-14
cpp_compiler: clang++-14
use_system_7zip: OFF
- c_compiler: clang-15
cpp_compiler: clang++-15
use_system_7zip: OFF
exclude:
- c_compiler: gcc-9
bit7z_link_libcpp: ON
Expand All @@ -56,6 +49,24 @@ jobs:
bit7z_link_libcpp: ON
- c_compiler: gcc-13
bit7z_link_libcpp: ON
- c_compiler: gcc-9
bit7z_7zip_version: 16.02
- c_compiler: gcc-10
bit7z_7zip_version: 16.02
- c_compiler: gcc-11
bit7z_7zip_version: 16.02
- c_compiler: gcc-12
bit7z_7zip_version: 16.02
- c_compiler: clang-13
bit7z_7zip_version: 16.02
- c_compiler: clang-14
bit7z_7zip_version: 16.02
- bit7z_7zip_version: 16.02
bit7z_build_for_p7zip: OFF
- bit7z_7zip_version: 23.01
bit7z_build_for_p7zip: ON
- bit7z_7zip_version: 22.01
bit7z_build_for_p7zip: ON

steps:
- uses: actions/checkout@v3
Expand All @@ -78,4 +89,4 @@ jobs:
sevenzip_version: ${{ matrix.bit7z_7zip_version }}
build_type: ${{ matrix.build_type }}
build_flags: |
-DBIT7Z_TESTS_USE_SYSTEM_7ZIP=OFF -DBIT7Z_AUTO_FORMAT=${{ matrix.bit7z_auto_format }} -DBIT7Z_REGEX_MATCHING=${{ matrix.bit7z_regex_matching }} -DBIT7Z_LINK_LIBCPP=${{ matrix.bit7z_link_libcpp }}
-DBIT7Z_TESTS_USE_SYSTEM_7ZIP=${{ matrix.bit7z_build_for_p7zip }} -DBIT7Z_BUILD_FOR_P7ZIP=${{ matrix.bit7z_build_for_p7zip }} -DBIT7Z_AUTO_FORMAT=${{ matrix.bit7z_auto_format }} -DBIT7Z_REGEX_MATCHING=${{ matrix.bit7z_regex_matching }} -DBIT7Z_LINK_LIBCPP=${{ matrix.bit7z_link_libcpp }}
16 changes: 13 additions & 3 deletions cmake/BuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,23 @@ if( NOT BIT7Z_CUSTOM_7ZIP_PATH STREQUAL "" )

if ( BIT7Z_7ZIP_VERSION VERSION_LESS_EQUAL 16.04 AND UNIX )
message( STATUS "Detected p7zip's source code!" )
target_compile_definitions( ${LIB_TARGET} PUBLIC BIT7Z_FOR_P7ZIP )
set( BIT7Z_BUILD_FOR_P7ZIP ON )
endif()
endif()
endif()
else()
set( BIT7Z_7ZIP_VERSION "23.01" CACHE STRING "The version of 7-zip to be used by bit7z" )
message( STATUS "7-zip version: ${BIT7Z_7ZIP_VERSION}" )
if ( UNIX )
option( BIT7Z_BUILD_FOR_P7ZIP "Enable or disable building bit7z for p7zip rather than 7-zip" )
message( STATUS "Build bit7z for p7zip: ${BIT7Z_BUILD_FOR_P7ZIP}" )
endif()
if ( NOT BIT7Z_BUILD_FOR_P7ZIP )
set( BIT7Z_7ZIP_VERSION "23.01" CACHE STRING "The version of 7-zip to be used by bit7z" )
message( STATUS "7-zip version: ${BIT7Z_7ZIP_VERSION}" )
endif()
endif()

if( BIT7Z_BUILD_FOR_P7ZIP )
target_compile_definitions( ${LIB_TARGET} PUBLIC BIT7Z_BUILD_FOR_P7ZIP )
endif()

option( BIT7Z_BUILD_TESTS "Enable or disable building the testing executable" )
Expand Down
19 changes: 14 additions & 5 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ if( NOT ( EXISTS ${CPM_DOWNLOAD_LOCATION} ) )
endif()
include( ${CPM_DOWNLOAD_LOCATION} )

# No custom path to 7-Zip's source code was specified by the user, so we download it.
if( BIT7Z_CUSTOM_7ZIP_PATH STREQUAL "" )
# 7-zip source code
CPMAddPackage( NAME 7-zip
GITHUB_REPOSITORY "rikyoz/7-Zip"
VERSION ${BIT7Z_7ZIP_VERSION}
DOWNLOAD_ONLY YES )
if ( BIT7Z_BUILD_FOR_P7ZIP )
# p7zip source code (calling the package as 7-zip just for simplify the code).
CPMAddPackage( NAME 7-zip
GITHUB_REPOSITORY "rikyoz/p7zip"
VERSION 16.02
DOWNLOAD_ONLY YES )
else()
# 7-zip source code
CPMAddPackage( NAME 7-zip
GITHUB_REPOSITORY "rikyoz/7-Zip"
VERSION ${BIT7Z_7ZIP_VERSION}
DOWNLOAD_ONLY YES )
endif()
if( 7-zip_ADDED )
message( STATUS "7-zip source code available at ${7-zip_SOURCE_DIR}" )
add_library( 7-zip INTERFACE IMPORTED )
Expand Down
22 changes: 11 additions & 11 deletions tests/src/test_bitarchivereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ TEMPLATE_TEST_CASE( "BitArchiveReader: Reading archives containing only a single
REQUIRE_FALSE( info.isEncrypted() );
REQUIRE_ARCHIVE_CONTENT( info, testArchive );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
if ( testArchive.format() == BitFormat::Rar || testArchive.format() == BitFormat::Rar5 ) {
SKIP( "Can't test Rar/Rar5 format using p7zip" );
}
Expand Down Expand Up @@ -252,7 +252,7 @@ TEMPLATE_TEST_CASE( "BitArchiveReader: Reading archives containing multiple file
REQUIRE_FALSE( info.isEncrypted() );
REQUIRE_ARCHIVE_CONTENT( info, testArchive );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
if ( testArchive.format() == BitFormat::Rar || testArchive.format() == BitFormat::Rar5 ) {
SKIP( "Can't test Rar/Rar5 format using p7zip" );
}
Expand Down Expand Up @@ -297,7 +297,7 @@ TEMPLATE_TEST_CASE( "BitArchiveReader: Reading archives containing multiple item
REQUIRE_FALSE( info.isEncrypted() );
REQUIRE_ARCHIVE_CONTENT( info, testArchive );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
if ( testArchive.format() == BitFormat::Rar || testArchive.format() == BitFormat::Rar5 ) {
SKIP( "Can't test Rar/Rar5 format using p7zip" );
}
Expand Down Expand Up @@ -355,7 +355,7 @@ TEMPLATE_TEST_CASE( "BitArchiveReader: Reading archives containing encrypted ite
REQUIRE( info.isEncrypted() );
REQUIRE_ARCHIVE_CONTENT( info, testArchive );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
if ( testArchive.format() == BitFormat::Rar || testArchive.format() == BitFormat::Rar5 ) {
SKIP( "Can't test Rar/Rar5 format using p7zip" );
}
Expand Down Expand Up @@ -411,7 +411,7 @@ TEMPLATE_TEST_CASE( "BitArchiveReader: Reading header-encrypted archives",
REQUIRE( info.isEncrypted() );
REQUIRE_ARCHIVE_CONTENT( info, testArchive );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
if ( testArchive.format() == BitFormat::Rar || testArchive.format() == BitFormat::Rar5 ) {
SKIP( "Can't test Rar/Rar5 format using p7zip" );
}
Expand Down Expand Up @@ -471,7 +471,7 @@ TEST_CASE( "BitArchiveReader: Reading metadata of multi-volume archives", "[bita
const ArchivedItem expectedItem{ clouds, clouds.name };
REQUIRE_ARCHIVE_ITEM( BitFormat::Rar5, info.items()[ 0 ], expectedItem );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
SKIP( "Can't test Rar5 format using p7zip" );
#else
REQUIRE_ARCHIVE_TESTS( info );
Expand All @@ -488,7 +488,7 @@ TEST_CASE( "BitArchiveReader: Reading metadata of multi-volume archives", "[bita
const ArchivedItem expectedItem{ clouds, clouds.name };
REQUIRE_ARCHIVE_ITEM( BitFormat::Rar, info.items()[ 0 ], expectedItem );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
SKIP( "Can't test Rar format using p7zip" );
#else
REQUIRE_ARCHIVE_TESTS( info );
Expand Down Expand Up @@ -545,7 +545,7 @@ TEST_CASE( "BitArchiveReader: Solid archive detection", "[bitarchivereader]" ) {
const BitArchiveReader info( lib, BIT7Z_STRING( "solid.rar" ), BitFormat::Rar5 );
REQUIRE( info.isSolid() );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
SKIP( "Can't test Rar5 format using p7zip" );
#else
REQUIRE_ARCHIVE_TESTS( info );
Expand All @@ -562,7 +562,7 @@ TEST_CASE( "BitArchiveReader: Solid archive detection", "[bitarchivereader]" ) {
const BitArchiveReader info( lib, BIT7Z_STRING( "non_solid.rar" ), BitFormat::Rar5 );
REQUIRE( !info.isSolid() );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
SKIP( "Can't test Rar5 format using p7zip" );
#else
REQUIRE_ARCHIVE_TESTS( info );
Expand Down Expand Up @@ -1026,7 +1026,7 @@ TEST_CASE( "BitArchiveReader: Format detection of archives", "[bitarchivereader]
const BitArchiveReader reader{ lib, file.string< bit7z::tchar >() };
REQUIRE( reader.detectedFormat() == test.format );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
if ( test.format == BitFormat::Rar || test.format == BitFormat::Rar5 ) {
SKIP( "Can't test Rar/Rar5 format using p7zip" );
}
Expand All @@ -1043,7 +1043,7 @@ TEST_CASE( "BitArchiveReader: Format detection of archives", "[bitarchivereader]
const BitArchiveReader reader{ lib, fileStream };
REQUIRE( reader.detectedFormat() == test.format );

#ifdef BIT7Z_FOR_P7ZIP
#ifdef BIT7Z_BUILD_FOR_P7ZIP
if ( test.format == BitFormat::Rar || test.format == BitFormat::Rar5 ) {
SKIP( "Can't test Rar/Rar5 format using p7zip" );
}
Expand Down

0 comments on commit 5bb8b32

Please sign in to comment.