Skip to content

Commit

Permalink
dev: minizip fdsafdsa
Browse files Browse the repository at this point in the history
  • Loading branch information
enzoevers committed Nov 28, 2024
1 parent 5b996de commit f6105db
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CoDeLib/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ check_required_components(CoDeLib)
include(CMakeFindDependencyMacro)

set(ZLIB_USE_STATIC_LIBS "ON")
find_dependency(ZLIB REQUIRED)
find_dependency(ZLIB REQUIRED)

find_dependency(minizip REQUIRED)
1 change: 0 additions & 1 deletion CoDeLib/Deflate_zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set(ZLIB_USE_STATIC_LIBS "ON")
find_package(ZLIB REQUIRED)
target_link_libraries(Deflate_zlib PRIVATE ZLIB::ZLIB)

message(STATUS "CoDeLib_PUBLIC_INCLUDE_PATH: ${CoDeLib_PUBLIC_INCLUDE_PATH}")
set(Deflate_zlib_PUBLIC_INCLUDE_PATH ${CoDeLib_PUBLIC_INCLUDE_PATH}/Deflate_zlib)
set(Deflate_zlib_PUBLIC_HEADERS
${Deflate_zlib_PUBLIC_INCLUDE_PATH}/Deflate_zlib.h
Expand Down
6 changes: 2 additions & 4 deletions CoDeLib/Zip_minizip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ target_include_directories(Zip_minizip PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

set(ZLIB_USE_STATIC_LIBS "ON")
find_package(ZLIB REQUIRED)
target_link_libraries(Zip_minizip PRIVATE ZLIB::ZLIB)
find_package(MINIZIP REQUIRED)
target_link_libraries(Zip_minizip PRIVATE MINIZIP::minizip)

message(STATUS "CoDeLib_PUBLIC_INCLUDE_PATH: ${CoDeLib_PUBLIC_INCLUDE_PATH}")
set(Zip_minizip_PUBLIC_INCLUDE_PATH ${CoDeLib_PUBLIC_INCLUDE_PATH}/Zip_minizip)
set(Zip_minizip_PUBLIC_HEADERS
${Zip_minizip_PUBLIC_INCLUDE_PATH}/Zip_minizip.h
Expand Down
8 changes: 7 additions & 1 deletion CoDeLib/Zip_minizip/src/Zip_minizip.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#include <CoDeLib/Zip_minizip/Zip_minizip.h>

#include <zip.h> // minizip

ZIP_RETURN_CODES Zip(FILE *inputs[] __attribute__((unused)),
FILE *output __attribute__((unused)),
void *options __attribute__((unused))) {

return ZIP_SUCCESS;
// TODO: Dummy code to test if it compiles and links
if (ZIP_OK) {
return ZIP_SUCCESS;
}
return ZIP_ERROR;
}

const struct IZip zip_minizip = {
Expand Down
8 changes: 6 additions & 2 deletions Scripts/BuildAndInstallCoDeLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def BuildAndInstallCoDeLib(
ExternalZlibLibInstallPath = Path(
ExternalLibPath / "zlib/Install" / targetPlatformString / BuildTypeString
)
ExternalMinizipNgLibInstallPath = Path(
ExternalLibPath / "minizip-ng/Install" / targetPlatformString / BuildTypeString
)

CoDeLibRootPath = Path(RepositoryRootPath / ProjectName)
BuildDirectory = Path(
Expand All @@ -70,14 +73,15 @@ def BuildAndInstallCoDeLib(
print("==============================")
print(ProjectName + ": Configuring ({})".format(BuildTypeString))
print("==============================")
configureCommand = 'cmake -G "{0}" -DCMAKE_TOOLCHAIN_FILE="{1}" -S "{2}" -B "{3}" -DCMAKE_INSTALL_PREFIX="{4}" -DZLIB_ROOT="{5}" -DCMAKE_BUILD_TYPE={6}'.format(
configureCommand = 'cmake -G "{0}" -DCMAKE_TOOLCHAIN_FILE="{1}" -S "{2}" -B "{3}" -DCMAKE_INSTALL_PREFIX="{4}" -DCMAKE_BUILD_TYPE={5} -DZLIB_ROOT="{6}" -DCMAKE_PREFIX_PATH="{7}"'.format(
buildEnv.GetCmakeGenerator(),
buildEnv.GetCustomToolChainPath(),
CoDeLibRootPath,
BuildDirectory,
InstallDirectory,
ExternalZlibLibInstallPath,
BuildTypeString,
ExternalZlibLibInstallPath,
ExternalMinizipNgLibInstallPath,
)
print(configureCommand)
subprocess.run(
Expand Down
84 changes: 84 additions & 0 deletions Scripts/BuildAndInstallExternalLibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,92 @@ def BuildAndInstallZlib(
)


##############################
# minizip-ng
##############################
def BuildAndInstallMinizipNg(
buildEnv: EnvironmentConfig.EnvironmentConfiguration,
buildConfig: EnvironmentConfig.BuildConfig = EnvironmentConfig.BuildConfig.DEBUG,
):
ProjectName = "minizip-ng"

BuildTypeString = EnvironmentConfig.BuildConfig.ToCMakeBuildType(buildConfig)
targetPlatformString = EnvironmentConfig.Platform.PlatformToOsName(
buildEnv.GetTargetPlatform()
)

TopLevelCMakeListsDirectory = Path(ExternalLibPath / ProjectName)
BuildDirectory = Path(
ExternalLibPath / ProjectName / "Build" / targetPlatformString / BuildTypeString
)
InstallDirectory = Path(
ExternalLibPath
/ ProjectName
/ "Install"
/ targetPlatformString
/ BuildTypeString
)

if not BuildDirectory.exists():
BuildDirectory.mkdir(parents=True)

if InstallDirectory.exists():
shutil.rmtree(InstallDirectory)
InstallDirectory.mkdir(parents=True)

os.chdir(RepositoryRootPath)

# All options for minizip-ng that are not needed are turned off (all off them) except for MZ_COMPAT
# In this project minizing-ng is used only for zip file creation and extraction
print("==============================")
print(ProjectName + ": Configuring ({})".format(BuildTypeString))
print("==============================")
configureCommand = 'cmake -G "{0}" -DCMAKE_TOOLCHAIN_FILE="{1}" -S {2} -B {3} -DCMAKE_INSTALL_PREFIX="{4}" -DCMAKE_BUILD_TYPE={5} -DBUILD_SHARED_LIBS=OFF -DMZ_COMPAT=ON -DMZ_ZLIB=OFF -DMZ_BZIP2=OFF -DMZ_LZMA=OFF -DMZ_ZSTD=OFF -DMZ_LIBCOMP=OFF -DMZ_FETCH_LIBS=OFF -DMZ_PKCRYPT=OFF -DMZ_WZAES=OFF -DMZ_OPENSSL=OFF -DMZ_LIBBSD=OFF -DMZ_ICONV=OFF'.format(
buildEnv.GetCmakeGenerator(),
buildEnv.GetCustomToolChainPath(),
TopLevelCMakeListsDirectory,
BuildDirectory,
InstallDirectory,
BuildTypeString,
)
print(configureCommand)
subprocess.run(
configureCommand,
shell=True,
check=True,
)

print("==============================")
print(ProjectName + ": Building ({})".format(BuildTypeString))
print("==============================")
buildCommand = "cmake --build {0}".format(BuildDirectory)
print(buildCommand)
subprocess.run(
buildCommand,
shell=True,
check=True,
)

print("==============================")
print(ProjectName + ": Installing ({})".format(BuildTypeString))
print("==============================")
installCommand = "cmake --install {0}".format(BuildDirectory)
print(installCommand)
subprocess.run(
installCommand,
shell=True,
check=True,
)


BuildEnv = EnvironmentConfig.EnvironmentConfiguration(
RepositoryRootPath, targetPlatform
)

# zlib
BuildAndInstallZlib(BuildEnv, EnvironmentConfig.BuildConfig.DEBUG)
BuildAndInstallZlib(BuildEnv, EnvironmentConfig.BuildConfig.RELEASE)

# minizip-ng
BuildAndInstallMinizipNg(BuildEnv, EnvironmentConfig.BuildConfig.DEBUG)
BuildAndInstallMinizipNg(BuildEnv, EnvironmentConfig.BuildConfig.RELEASE)
10 changes: 7 additions & 3 deletions Scripts/BuildBenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def BuildBenchmark(
ExternalZlibLibInstallPath = Path(
ExternalLibPath / "zlib/Install" / targetPlatformString / BuildTypeString
)
ExternalMinizipNgLibInstallPath = Path(
ExternalLibPath / "minizip-ng/Install" / targetPlatformString / BuildTypeString
)

BenchmarkRootPath = Path(RepositoryRootPath / ProjectName)
BuildDirectory = Path(
Expand All @@ -69,14 +72,15 @@ def BuildBenchmark(
print("==============================")
print(ProjectName + ": Configuring ({})".format(BuildTypeString))
print("==============================")
configureCommand = 'cmake -G "{0}" -DCMAKE_TOOLCHAIN_FILE="{1}" -DCMAKE_PREFIX_PATH="{2}" -S {3} -B {4} -DZLIB_ROOT="{5}" -DCMAKE_BUILD_TYPE={6}'.format(
configureCommand = 'cmake -G "{0}" -DCMAKE_TOOLCHAIN_FILE="{1}" -S {2} -B {3} -DCMAKE_BUILD_TYPE={4} -DZLIB_ROOT="{5}" -DCMAKE_PREFIX_PATH="{6};{7}"'.format(
buildEnv.GetCmakeGenerator(),
buildEnv.GetCustomToolChainPath(),
CoDeLibInstallDirectory,
BenchmarkRootPath,
BuildDirectory,
ExternalZlibLibInstallPath,
BuildTypeString,
ExternalZlibLibInstallPath,
CoDeLibInstallDirectory,
ExternalMinizipNgLibInstallPath,
)
subprocess.run(
configureCommand,
Expand Down
4 changes: 4 additions & 0 deletions Scripts/CleanAll.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
ExternalLibPath = Path(ProjectRootPath / "External")
ExternalZlibLibBuildPath = Path(ExternalLibPath / "zlib/Build")
ExternalZlibLibInstallPath = Path(ExternalLibPath / "zlib/Install")
ExternalMinizipNgLibBuildPath = Path(ExternalLibPath / "minizip-ng/Build")
ExternalMinizipNgLibInstallPath = Path(ExternalLibPath / "minizip-ng/Install")

DirectoriesToRemove = [
BenchmarkBuildPath,
CoDeLibBuildPath,
CoDeLibInstallPath,
ExternalZlibLibBuildPath,
ExternalZlibLibInstallPath,
ExternalMinizipNgLibBuildPath,
ExternalMinizipNgLibInstallPath,
]


Expand Down

0 comments on commit f6105db

Please sign in to comment.