diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 043eee7..4ec5299 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,17 +23,13 @@ jobs: env: CL: /MP DETOURS_TARGET_PROCESSOR: x86 - - name: Build minizip-ng + - name: Build zlib run: | - cmake -S "3rdParty\minizip-ng" -B "3rdParty\minizip-ng\build" -A Win32 ` - -DMZ_LZMA=OFF -DMZ_ZSTD=OFF ` - -DMZ_BZIP2=OFF -DMZ_PKCRYPT=OFF ` - -DMZ_WZAES=OFF -DMZ_SIGNING=OFF ` - -DMZ_DECOMPRESS_ONLY=ON ` + cmake -S "3rdParty\zlib" -B "3rdParty\zlib\build" -A Win32 ` -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ` -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` -DCMAKE_BUILD_TYPE=Release - cmake --build "3rdParty\minizip-ng\build" --config Release + cmake --build "3rdParty\zlib\build" --config Release - name: Build Spore-ModAPI run: | msbuild "3rdParty\Spore-ModAPI\Spore ModAPI" ` @@ -81,9 +77,6 @@ jobs: - uses: actions/checkout@v4 with: submodules: 'true' - - name: Install Packages - run: | - sudo apt-get -y install libminizip-dev build-essential - name: Prepare Environment run: | echo "GIT_REVISION=$(git describe --tags --always)" >> $GITHUB_ENV diff --git a/3rdParty/BuildMinizipNG.bat b/3rdParty/BuildMinizipNG.bat deleted file mode 100644 index 7e2450b..0000000 --- a/3rdParty/BuildMinizipNG.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -set MINIZIPNG_CUR_DIR=%~dp0 - -set MINIZIPNG_DIR=%MINIZIPNG_CUR_DIR%\minizip-ng - -rmdir /S /Q "%MINIZIPNG_DIR%\build" -mkdir "%MINIZIPNG_DIR%\build" - -set PATH=%PATH%;C:\Program Files\CMake\bin - -cmake -S "%MINIZIPNG_DIR%" -B "%MINIZIPNG_DIR%\build" -A Win32 ^ - -DMZ_LZMA=OFF -DMZ_ZSTD=OFF ^ - -DMZ_BZIP2=OFF -DMZ_PKCRYPT=OFF ^ - -DMZ_WZAES=OFF -DMZ_SIGNING=OFF ^ - -DMZ_DECOMPRESS_ONLY=ON ^ - -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ - -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^ - -DCMAKE_BUILD_TYPE=Release - -cmake --build "%MINIZIPNG_DIR%\build" --config Release \ No newline at end of file diff --git a/3rdParty/BuildZlib.bat b/3rdParty/BuildZlib.bat new file mode 100644 index 0000000..dd46d7a --- /dev/null +++ b/3rdParty/BuildZlib.bat @@ -0,0 +1,16 @@ +@echo off +set ZLIB_CUR_DIR=%~dp0 + +set ZLIB_DIR=%ZLIB_CUR_DIR%\zlib + +rmdir /S /Q "%ZLIB_DIR%\build" +mkdir "%ZLIB_DIR%\build" + +set PATH=%PATH%;C:\Program Files\CMake\bin + +cmake -S "%ZLIB_DIR%" -B "%ZLIB_DIR%\build" -A Win32 ^ + -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ + -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^ + -DCMAKE_BUILD_TYPE=Release + +cmake --build "%ZLIB_DIR%\build" --config Release \ No newline at end of file diff --git a/BuildRelease.bat b/BuildRelease.bat index 7db7579..238426b 100644 --- a/BuildRelease.bat +++ b/BuildRelease.bat @@ -19,7 +19,7 @@ mkdir "%OBJ_DIR%\SporeModLoader\ModLibs" mkdir "%OBJ_DIR%\SporeModLoader\SporeModManager" CALL "%THIRDPARTY_DIR%\BuildDetours.bat" -CALL "%THIRDPARTY_DIR%\BuildMinizipNG.bat" +CALL "%THIRDPARTY_DIR%\BuildZlib.bat" CALL "%THIRDPARTY_DIR%\BuildSporeModAPI.bat" msbuild "%CUR_DIR%\SporeModLoader" ^ diff --git a/Makefile b/Makefile index 07a4a06..4476d6f 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,17 @@ BINARY_DIR = bin SOURCE_DIR = SporeModManager PKG_CONFIG := pkg-config +CC := gcc CXX := g++ +CFLAGS := -O2 -flto \ + -I$(THIRDPARTY_DIR)/zlib \ + -I$(THIRDPARTY_DIR)/zlib/contrib/minizip CXXFLAGS := -std=c++17 \ -O2 -flto \ -I$(SOURCE_DIR) \ -I$(THIRDPARTY_DIR)/tinyxml2 \ - -I$(THIRDPARTY_DIR)/minizip-ng + -I$(THIRDPARTY_DIR)/zlib \ + -I$(THIRDPARTY_DIR)/zlib/contrib/minizip LDFLAGS := -s @@ -25,14 +30,18 @@ OBJECT_FILES = \ $(SOURCE_DIR)/SporeModManagerHelpers/String.o \ $(SOURCE_DIR)/SporeModManagerHelpers/UI.o \ $(SOURCE_DIR)/SporeModManagerHelpers/Zip.o \ - $(THIRDPARTY_DIR)/tinyxml2/tinyxml2.o + $(THIRDPARTY_DIR)/tinyxml2/tinyxml2.o \ + $(THIRDPARTY_DIR)/zlib/contrib/minizip/unzip.o \ + $(THIRDPARTY_DIR)/zlib/contrib/minizip/ioapi.o THIRDPARTY_LIBRARIES = \ - $(THIRDPARTY_DIR)/minizip-ng/build/libminizip.a \ - $(THIRDPARTY_DIR)/minizip-ng/build/_deps/zlib-build/libz.a + $(THIRDPARTY_DIR)/zlib/build/libz.a THIRDPARTY_BUILD_DIRS = \ - $(THIRDPARTY_DIR)/minizip-ng/build + $(THIRDPARTY_DIR)/zlib/build + +%.o: %.c + $(CC) -c $< -o $@ $(CFLAGS) %.o: %.cpp $(CXX) -c $< -o $@ $(CXXFLAGS) @@ -42,20 +51,12 @@ all: $(BINARY_DIR)/SporeModManager $(BINARY_DIR): mkdir -p $@ -$(THIRDPARTY_DIR)/minizip-ng/build/libminizip.a: - cmake -S $(THIRDPARTY_DIR)/minizip-ng -B $(THIRDPARTY_DIR)/minizip-ng/build \ - -DMZ_LZMA=OFF -DMZ_ZSTD=OFF \ - -DMZ_BZIP2=OFF -DMZ_PKCRYPT=OFF \ - -DMZ_WZAES=OFF -DMZ_SIGNING=OFF \ - -DMZ_DECOMPRESS_ONLY=ON -DMZ_ICONV=OFF \ - -DMZ_OPENSSL=OFF -DMZ_LIBBSD=OFF \ - -DMZ_FORCE_FETCH_LIBS=ON -DMZ_FETCH_LIBS=ON \ +$(THIRDPARTY_DIR)/zlib/build/libz.a: + cmake -S $(THIRDPARTY_DIR)/zlib -B $(THIRDPARTY_DIR)/zlib/build \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=$(CC) \ -G "Unix Makefiles" - $(MAKE) -C $(THIRDPARTY_DIR)/minizip-ng/build - -$(THIRDPARTY_DIR)/minizip-ng/build/_deps/zlib-build/libz.a: $(THIRDPARTY_DIR)/minizip-ng/build/libminizip.a + $(MAKE) -C $(THIRDPARTY_DIR)/zlib/build $(BINARY_DIR)/SporeModManager: $(THIRDPARTY_LIBRARIES) $(BINARY_DIR) $(OBJECT_FILES) $(CXX) $(OBJECT_FILES) -o $@ $(THIRDPARTY_LIBRARIES) $(LDFLAGS) diff --git a/SporeModManager/SporeModManager.vcxproj b/SporeModManager/SporeModManager.vcxproj index f99a612..78e37da 100644 --- a/SporeModManager/SporeModManager.vcxproj +++ b/SporeModManager/SporeModManager.vcxproj @@ -72,16 +72,16 @@ true - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\;$(MSBuildProjectDirectory)\..\3rdParty\tinyxml2\;$(IncludePath) - $(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\build\Release;$(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\build\_deps\zlib-build\Release;$(LibraryPath) + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\3rdParty\zlib\;$(MSBuildProjectDirectory)\..\3rdParty\zlib\build\;$(MSBuildProjectDirectory)\..\3rdParty\zlib\contrib\minizip;$(MSBuildProjectDirectory)\..\3rdParty\tinyxml2\;$(IncludePath) + $(MSBuildProjectDirectory)\..\3rdParty\zlib\build\Release;$(LibraryPath) $(MSBuildProjectDirectory)\Bin\$(Configuration)\ $(MSBuildProjectDirectory)\Obj\$(Configuration)\ false $(MSBuildProjectDirectory)\Bin\$(Configuration)\ - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\;$(MSBuildProjectDirectory)\..\3rdParty\tinyxml2\;$(IncludePath) - $(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\build\Release\;$(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\build\_deps\zlib-build\Release;$(LibraryPath) + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\3rdParty\zlib\;$(MSBuildProjectDirectory)\..\3rdParty\zlib\build\;$(MSBuildProjectDirectory)\..\3rdParty\zlib\contrib\minizip;$(MSBuildProjectDirectory)\..\3rdParty\tinyxml2\;$(IncludePath) + $(MSBuildProjectDirectory)\..\3rdParty\zlib\build\Release;$(LibraryPath) $(MSBuildProjectDirectory)\Obj\$(Configuration)\ @@ -102,11 +102,11 @@ Console true - zlibstatic.lib;libminizip.lib;%(AdditionalDependencies) + zlibstatic.lib;%(AdditionalDependencies) - if NOT EXIST "$(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\build\Release\libminizip.lib" ( - "$(MSBuildProjectDirectory)\..\3rdParty\BuildMinizipNG.bat" + if NOT EXIST "$(MSBuildProjectDirectory)\..\3rdParty\zlib\build\Release\zlibstatic.lib" ( + "$(MSBuildProjectDirectory)\..\3rdParty\BuildZlib.bat" ) @@ -126,11 +126,11 @@ true true true - zlibstatic.lib;libminizip.lib;%(AdditionalDependencies) + zlibstatic.lib;%(AdditionalDependencies) - if NOT EXIST "$(MSBuildProjectDirectory)\..\3rdParty\minizip-ng\build\Release\libminizip.lib" ( - "$(MSBuildProjectDirectory)\..\3rdParty\BuildMinizipNG.bat" + if NOT EXIST "$(MSBuildProjectDirectory)\..\3rdParty\zlib\build\Release\zlibstatic.lib" ( + "$(MSBuildProjectDirectory)\..\3rdParty\BuildZlib.bat" ) @@ -164,6 +164,8 @@ + + @@ -176,6 +178,7 @@ + diff --git a/SporeModManager/SporeModManager.vcxproj.filters b/SporeModManager/SporeModManager.vcxproj.filters index e8db373..bdd39fb 100644 --- a/SporeModManager/SporeModManager.vcxproj.filters +++ b/SporeModManager/SporeModManager.vcxproj.filters @@ -48,6 +48,12 @@ Source Files\SporeModManagerHelpers + + Source Files + + + Source Files + @@ -59,5 +65,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/SporeModManager/SporeModManagerHelpers/Zip.cpp b/SporeModManager/SporeModManagerHelpers/Zip.cpp index c526996..cf79258 100644 --- a/SporeModManager/SporeModManagerHelpers/Zip.cpp +++ b/SporeModManager/SporeModManagerHelpers/Zip.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include using namespace SporeModManagerHelpers; @@ -87,7 +87,7 @@ bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, std::filesyst std::ofstream outputFileStream; // try to find file in zip - if (unzLocateFile(zipFile, file.string().c_str(), nullptr) != UNZ_OK) + if (unzLocateFile(zipFile, file.string().c_str(), 2) != UNZ_OK) { std::cerr << "Failed to find \"" << file << "\" in zip file!" << std::endl; return false; @@ -145,7 +145,7 @@ bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, char** outBuf size_t bytesRead = 0; // try to find file in zip - if (unzLocateFile(zipFile, file.string().c_str(), nullptr) != UNZ_OK) + if (unzLocateFile(zipFile, file.string().c_str(), 2) != UNZ_OK) { std::cerr << "Failed to find \"" << file << "\" in zip file!" << std::endl; return false;