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
4 changes: 2 additions & 2 deletions .github/workflows/Test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Config executables
run: |
Expand All @@ -34,4 +34,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: SWPacker
path: ${{github.workspace}}\out\0.1\Release\
path: ${{github.workspace}}\out\1.1\Release\
30 changes: 27 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,30 @@ 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" )

## 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)
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,41 @@ 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

## 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.
28 changes: 27 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,26 @@ if(MSVC)
endif()
## <=====================================>

## IMPORTED STATIC LIBRARY NAME
set( STATIC_LIB_NAME
zstd_static
)

## IMPORTED STATIC LIBRARY .lib file
set( STATIC_LIB
${CMAKE_SOURCE_DIR}/libraries/zstd_static.lib
)

## 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
18 changes: 16 additions & 2 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,16 @@ endforeach()
file(GLOB SRC ${TMP})
## <=====================================>


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

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 +56,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
Loading