Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer
Submodule .devcontainer added at 98c1ae
30 changes: 30 additions & 0 deletions .github/workflows/xpbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
jobs:
linux:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.1
with:
cmake-workflow-preset: Linux
runon: ubuntu-latest
secrets: inherit
linux-arm64:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.1
with:
cmake-workflow-preset: Linux
runon: ubuntu-24.04-arm
secrets: inherit
macos:
uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.1
with:
cmake-workflow-preset: Darwin
secrets: inherit
windows:
uses: externpro/externpro/.github/workflows/build-windows.yml@25.05.1
with:
cmake-workflow-preset: Windows
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/xprelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
workflow_dispatch:
inputs:
workflow_run_url:
description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)'
required: true
type: string
jobs:
# Upload build artifacts as release assets
release-from-build:
uses: externpro/externpro/.github/workflows/release-from-build.yml@25.05.1
with:
workflow_run_url: ${{ github.event.inputs.workflow_run_url }}
artifact_pattern: "*.tar.xz"
permissions:
contents: write
id-token: write
attestations: write
secrets: inherit
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
*.exe
bzip2
bzip2recover

# externpro
.env
_bld*/
docker-compose.override.yml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule ".devcontainer"]
path = .devcontainer
url = https://github.com/externpro/externpro
73 changes: 73 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
cmake_minimum_required(VERSION 3.31)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.devcontainer/cmake)
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES xproinc)
project(bzip2 VERSION 1.0.8 LANGUAGES C)
include(flags)
include(GNUInstallDirs)
set(lib_name bz2)
########################################
add_definitions(-D_FILE_OFFEST_BITS=64)
########################################
set(${lib_name}_libsrcs
blocksort.c
huffman.c
crctable.c
randtable.c
compress.c
decompress.c
bzlib.c
bzlib.h
bzlib_private.h
)
########################################
add_library(${lib_name} STATIC ${${lib_name}_libsrcs})
target_include_directories(${lib_name} PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
########################################
add_executable(bzip2 bzip2.c)
target_link_libraries(bzip2 ${lib_name})
set_target_properties(bzip2 PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
########################################
add_executable(bzip2recover bzip2recover.c)
set_target_properties(bzip2recover PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
########################################
include(CTest)
add_test(NAME bzip2_check
COMMAND ${CMAKE_COMMAND}
-DCMD=$<TARGET_FILE:bzip2>
-DSRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBIN_DIR=${CMAKE_CURRENT_BINARY_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/run_bzip2_test.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
########################################
set(targetsFile ${PROJECT_NAME}-targets)
set(exe bzip2)
set(lib ${lib_name})
if(DEFINED XP_NAMESPACE)
string(PREPEND exe "${XP_NAMESPACE}::")
string(PREPEND lib "${XP_NAMESPACE}::")
endif()
xpPackageDevel(TARGETS_FILE ${targetsFile} LIBRARIES ${lib} EXE ${exe})
install(TARGETS ${lib_name} EXPORT ${targetsFile}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(TARGETS bzip2 bzip2recover EXPORT ${targetsFile}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Release
)
install(PROGRAMS $<TARGET_FILE:bzip2> DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Release RENAME bunzip2${CMAKE_EXECUTABLE_SUFFIX})
install(PROGRAMS $<TARGET_FILE:bzip2> DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Release RENAME bzcat${CMAKE_EXECUTABLE_SUFFIX})
install(FILES bzlib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
if(DEFINED XP_NAMESPACE)
set(nameSpace NAMESPACE ${XP_NAMESPACE}::)
endif()
if(NOT DEFINED XP_INSTALL_CMAKEDIR)
set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake)
endif()
install(EXPORT ${targetsFile} DESTINATION ${XP_INSTALL_CMAKEDIR} ${nameSpace})
8 changes: 8 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 8,
"include": [
".devcontainer/cmake/presets/xpLinuxNinja.json",
".devcontainer/cmake/presets/xpDarwinNinja.json",
".devcontainer/cmake/presets/xpWindowsVs2022.json"
]
}
14 changes: 14 additions & 0 deletions CMakePresetsBase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": 8,
"configurePresets": [
{
"name": "config-base",
"hidden": true,
"binaryDir": "${sourceDir}/_bld-${presetName}",
"cacheVariables": {
"XP_INSTALL_CMAKEDIR": "share/cmake",
"XP_NAMESPACE": "xpro"
}
}
]
}
2 changes: 1 addition & 1 deletion bzip2recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
#ifdef __GNUC__
typedef unsigned long long int MaybeUInt64;
# define MaybeUInt64_FMT "%Lu"
# define MaybeUInt64_FMT "%llu"
#else
#ifdef _MSC_VER
typedef unsigned __int64 MaybeUInt64;
Expand Down
1 change: 1 addition & 0 deletions docker-compose.sh
1 change: 1 addition & 0 deletions docker-compose.yml
27 changes: 27 additions & 0 deletions run_bzip2_test.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set(commands
# Compress sample files
"'${CMD}' -1 < '${SRC_DIR}/sample1.ref' > '${BIN_DIR}/sample1.rb2'"
"'${CMD}' -2 < '${SRC_DIR}/sample2.ref' > '${BIN_DIR}/sample2.rb2'"
"'${CMD}' -3 < '${SRC_DIR}/sample3.ref' > '${BIN_DIR}/sample3.rb2'"
# Decompress sample files
"'${CMD}' -d < '${SRC_DIR}/sample1.bz2' > '${BIN_DIR}/sample1.tst'"
"'${CMD}' -d < '${SRC_DIR}/sample2.bz2' > '${BIN_DIR}/sample2.tst'"
"'${CMD}' -ds < '${SRC_DIR}/sample3.bz2' > '${BIN_DIR}/sample3.tst'"
# Verify compressed files
"'${CMAKE_COMMAND}' -E compare_files '${SRC_DIR}/sample1.bz2' '${BIN_DIR}/sample1.rb2'"
"'${CMAKE_COMMAND}' -E compare_files '${SRC_DIR}/sample2.bz2' '${BIN_DIR}/sample2.rb2'"
"'${CMAKE_COMMAND}' -E compare_files '${SRC_DIR}/sample3.bz2' '${BIN_DIR}/sample3.rb2'"
# Verify decompressed files
"'${CMAKE_COMMAND}' -E compare_files '${BIN_DIR}/sample1.tst' '${SRC_DIR}/sample1.ref'"
"'${CMAKE_COMMAND}' -E compare_files '${BIN_DIR}/sample2.tst' '${SRC_DIR}/sample2.ref'"
"'${CMAKE_COMMAND}' -E compare_files '${BIN_DIR}/sample3.tst' '${SRC_DIR}/sample3.ref'"
)
foreach(cmd IN LISTS commands)
execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "Running: ${cmd}"
COMMAND bash -c "${cmd}" RESULT_VARIABLE result
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Command failed: ${cmd}\nExit code: ${result}")
endif()
endforeach()