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
Binary file added .github/resources/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 52 additions & 4 deletions .github/workflows/Test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ on:

env:
BUILD_TYPE: Release
VERSION_NAME: 1.1

jobs:
Test_windows:
Build_exec:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Config executables
run: |
Expand All @@ -33,5 +34,52 @@ jobs:
- name: Archive Executable
uses: actions/upload-artifact@v3
with:
name: SWPacker
path: ${{github.workspace}}\out\0.1\Release\
name: SWPacker-Exec
path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\
if-no-files-found: error

Build_Unpack_Shared:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Config executables
run: |
mkdir build && cd build
cmake -B ${{github.workspace}}\build -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UNPACK_LIB_SHARED=ON ..

- name: Build executables
run: |
cd ${{github.workspace}}\build
cmake --build ${{github.workspace}}\build --target SWEngine-unpacker_${{env.VERSION_NAME}} --config ${{env.BUILD_TYPE}}

- name: Archive Library
uses: actions/upload-artifact@v3
with:
name: SWPacker-shared-lib
path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\
if-no-files-found: error

Build_Unpack_Static:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Config executables
run: |
mkdir build && cd build
cmake -B ${{github.workspace}}\build -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UNPACK_LIB_STATIC=ON ..

- name: Build executables
run: |
cd ${{github.workspace}}\build
cmake --build ${{github.workspace}}\build --target SWEngine-unpacker_${{env.VERSION_NAME}} --config ${{env.BUILD_TYPE}}

- name: Archive library
uses: actions/upload-artifact@v3
with:
name: SWPacker-static-lib
path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\
if-no-files-found: error
31 changes: 28 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/out/ )

project( "SW Packer"
VERSION
1.0
1.1
DESCRIPTION
"Pack all resources into one file"
LANGUAGES
Expand All @@ -22,7 +22,7 @@ set( CMAKE_CXX_STANDARD_REQUIRED True )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/${CMAKE_PROJECT_VERSION} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/${CMAKE_PROJECT_VERSION} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/${CMAKE_PROJECT_VERSION} )
set(PREFIX_MESSAGE "[${PROJECT_NAME}] ")
set( PREFIX_MESSAGE "[${PROJECT_NAME}] ")

## <=====================================>

Expand All @@ -31,6 +31,31 @@ message(${PREFIX_MESSAGE} "Current cmake location: " ${CMAKE_CURRENT_SOURCE_DIR}
message(${PREFIX_MESSAGE} "Project location: " ${CMAKE_SOURCE_DIR})
message(${PREFIX_MESSAGE} "Project system: " ${CMAKE_SYSTEM_NAME})

option(SWFP_COMP "Define if the packer will enable compact process" )
option(BUILD_UNPACK_LIB_SHARED "Define if Unpacker is build as a library as shared" )
option(BUILD_UNPACK_LIB_STATIC "Define if Unpacker is build as a library as static" )

## IMPORTED STATIC LIBRARY NAME
set( STATIC_LIB_NAME
)

## IMPORTED STATIC LIBRARY .lib file
set( STATIC_LIB
)

list(LENGTH STATIC_LIB_NAME list_len)
math(EXPR LIST_LEN "${list_len} - 1")

if (${LIST_LEN} GREATER_EQUAL 0)
foreach(ctr RANGE ${LIST_LEN})
list(GET STATIC_LIB_NAME ${ctr} lib)
list(GET STATIC_LIB ${ctr} filelib)
add_library(${lib} STATIC IMPORTED)
set_target_properties(${lib} PROPERTIES
IMPORTED_LOCATION ${filelib}
)
endforeach()
endif ()

include(cmake/Packer.cmake)
include(cmake/UnPacker.cmake)
include(cmake/UnPacker.cmake)
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<p align="center">
<img src=".github/resources/images/logo.png"
style="height: 200px">
</p>

# SWPacker
## Description
SWPacker is program that allow to pack all files from a directory.
Expand All @@ -7,23 +12,43 @@ It builds a single file `.swfp` with all resources inside.
The compilation is simple, you can choose between two target: Packer and Unpacker.
```shell
mkdir "build" && cd build
cmake -G "Visual Studio 17 2022" - DCMAKE_BUILD_TYPE=[Debug/Release] ..
cmake --build . --target SWEngine-[packer/unpacker]_0.1 --config [Debug/Release]
cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=[Debug/Release] ..
cmake --build . --target SWEngine-[packer/unpacker]_1.1 --config [Debug/Release]
```
#### Option
You can define an option by using : `-D[option]=[value]`
- CMAKE_BUILD_TYPE: Debug/Release
- SWFP_COMP: ON/OFF
- BUILD_UNPACK_LIB_SHARED: ON/OFF
- BUILD_UNPACK_LIB_STATIC: ON/OFF

## Usage
### Packer
Simply run the executable and give the directory you want to pack.
```shell
./SWEngine-packer_0.1 [PATH_TO_DIRECTORY]
./SWEngine-packer [PATH_TO_DIRECTORY]
```

### UnPacker
Simply run the executable and give the directory where the file `.swfp` file is.
```shell
./SWEngine-unpacker_0.1 [PATH_TO_SWFP_FILE]
./SWEngine-unpacker [PATH_TO_SWFP_FILE]
```

### Compression
You're able to add a compression process in the packer (and decompress for unpacker).
To do so, go to `Packer.cpp` and find the `SWFP_COMP` macro and edit the code above to add
your own compression process. For `UnPacker.cpp` find `SWFP_COMP` and edit the code above.

To enable the compression process use `-DSWFP_COMP=ON` (default: OFF).

Note: There is a default compression algorithm: [zstd](https://github.com/facebook/zstd). \
The header is already include in the project just build a __static__ libraries and add it to the cmake. \
Add `zstd_static` to `STATIC_LIB_NAME` and `${CMAKE_SOURCE_DIR}/libraries/zstd_static.lib` to `STATIC_LIB` in the CMakeLists.txt.

## Authors
The project is made by [Guillaume Soisson](https://github.com/Alvarwow69). \
This project is based on raysan5 works for [rres](https://github.com/raysan5/rres)
The project is made by [Guillaume Soisson](https://github.com/Alvarwow69).

## Credits
This project is based on raysan5 works for [rres](https://github.com/raysan5/rres) \
This project use [zstd](https://github.com/facebook/zstd) to provide default compression process.
18 changes: 17 additions & 1 deletion cmake/Packer.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## PROJECT VAR
## <=====================================>
unset(EXEC)
set( EXEC "SWEngine-packer_${CMAKE_PROJECT_VERSION}" )
set( EXT cpp )
## <=====================================>
Expand All @@ -15,6 +16,8 @@ set( SRC_FOLDERS
)
## INCLUDE FOLDERS
set( INC_FOLDERS
${CMAKE_CURRENT_SOURCE_DIR}/libraries/

${CMAKE_CURRENT_SOURCE_DIR}/includes/
${CMAKE_CURRENT_SOURCE_DIR}/includes/file/
${CMAKE_CURRENT_SOURCE_DIR}/includes/pack/
Expand All @@ -39,7 +42,10 @@ add_executable(${EXEC} ${SRC})
## <=====================================>

target_compile_definitions(${EXEC} PUBLIC "SWFP_PACKER")

if (${SWFP_COMP})
message(${PREFIX_MESSAGE} "Compression process enabled!")
target_compile_definitions(${EXEC} PUBLIC "SWFP_COMP")
endif ()

## ADD INCLUDES
## <=====================================>
Expand All @@ -53,6 +59,16 @@ if(MSVC)
endif()
## <=====================================>

## STATIC LIBRARY LINKING
## <=====================================>
if (${STATIC_LIB_NAME})
target_link_libraries(${EXEC}
PUBLIC
${STATIC_LIB_NAME}
)
endif ()
## <=====================================>

if (${CMAKE_BUILD_TYPE} MATCHES Debug)
set_target_properties(${EXEC} PROPERTIES
DEBUG_POSTFIX "d")
Expand Down
35 changes: 31 additions & 4 deletions cmake/UnPacker.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## PROJECT VAR
## <=====================================>
unset(EXEC)
set( EXEC "SWEngine-unpacker_${CMAKE_PROJECT_VERSION}" )
set( EXT cpp )
## <=====================================>
Expand All @@ -15,6 +16,8 @@ set( SRC_FOLDERS
)
## INCLUDE FOLDERS
set( INC_FOLDERS
${CMAKE_CURRENT_SOURCE_DIR}/libraries/

${CMAKE_CURRENT_SOURCE_DIR}/includes/
${CMAKE_CURRENT_SOURCE_DIR}/includes/file/
${CMAKE_CURRENT_SOURCE_DIR}/includes/unpack/
Expand All @@ -31,15 +34,29 @@ endforeach()
file(GLOB SRC ${TMP})
## <=====================================>


## OUTPUT
## <=====================================>
## EXECUTABLE
add_executable(${EXEC} ${SRC})

if (NOT ${BUILD_UNPACK_LIB_SHARED} AND NOT ${BUILD_UNPACK_LIB_STATIC})
## EXECUTABLE
add_executable(${EXEC} ${SRC})
message(${PREFIX_MESSAGE} "Unpacker build as executable")
elseif (${BUILD_UNPACK_LIB_SHARED})
## SHARED LIB
add_library(${EXEC} SHARED ${SRC})
message(${PREFIX_MESSAGE} "Unpacker build as Shared library")
elseif (${BUILD_UNPACK_LIB_STATIC})
## STATIC LIB
add_library(${EXEC} STATIC ${SRC})
message(${PREFIX_MESSAGE} "Unpacker build as Static library")
endif ()

## <=====================================>

target_compile_definitions(${EXEC} PUBLIC "SWFP_UNPACKER")

if (${SWFP_COMP})
target_compile_definitions(${EXEC} PUBLIC "SWFP_COMP")
endif ()
## ADD INCLUDES
## <=====================================>
target_include_directories(${EXEC} PUBLIC ${INC_FOLDERS})
Expand All @@ -52,6 +69,16 @@ if(MSVC)
endif()
## <=====================================>

## STATIC LIBRARY LINKING
## <=====================================>
if (NOT ${STATIC_LIB_NAME} STREQUAL "")
target_link_libraries(${EXEC}
PUBLIC
${STATIC_LIB_NAME}
)
endif ()
## <=====================================>

if (${CMAKE_BUILD_TYPE} MATCHES Debug)
set_target_properties(${EXEC} PROPERTIES
DEBUG_POSTFIX "d")
Expand Down
Loading