Skip to content

Commit

Permalink
Do not recompress 7zs on every build
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaProductions committed Jan 5, 2024
1 parent 2d10493 commit a46b9cf
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ x64/
Rectify11Installer/Resources/*.7z
*.tmp

!Resources
!Resources
Resources/DoNotBuild.txt
10 changes: 1 addition & 9 deletions Rectify11Installer/Rectify11Installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,6 @@
</PropertyGroup>
</Target>
<PropertyGroup>
<PreBuildEvent>echo building archives..
cd /D "$(SolutionDir)Resources\Files\"
$(SolutionDir)Resources\Tools\7z.exe a "$(ProjectDir)Resources\files.7z" * -mx9 -ssp

cd /D "$(SolutionDir)Resources\Extras\"
$(SolutionDir)Resources\Tools\7z.exe a "$(ProjectDir)Resources\extras.7z" * -mx9 -ssp

cd /D "$(SolutionDir)Resources\Themes\"
$(SolutionDir)Resources\Tools\7z.exe a "$(ProjectDir)Resources\themes.7z" * -mx9 -ssp</PreBuildEvent>
<PreBuildEvent>call $(SolutionDir)Resources\Tools\rebuild_archives.bat "$(SolutionDir)" "$(ProjectDir)"</PreBuildEvent>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions Resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Resources
This directory contains all of Rectify11's assets.

The icons are located in the Files folder, stored in .res files. .res files can be open in Resource Hacker.
> [!CAUTION]
> Make sure to delete DoNotBuild.txt in the resources folder so that the changes would be built.
59 changes: 59 additions & 0 deletions Resources/Tools/rebuild_archives.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@echo off
REM This script generates the files.7z, extras.7z, and themes.7z needed for the Rectify11 installer

REM load command line arguments
set SolutionDir=%1
set ProjectDir=%2

REM Validate command line
if not exist %SolutionDir% (
echo bad solution directory argument
exit /b 1
)

if not exist %ProjectDir% (
echo bad project directory argument
exit /b 1
goto exit
)

REM Check if we already built them
if not exist "%ProjectDir%Resources\files.7z" (
goto build_archives
)
if not exist "%ProjectDir%Resources\extras.7z" (
goto build_archives
)
if not exist "%ProjectDir%Resources\themes.7z" (
goto build_archives
)
if exist "%SolutionDir%Resources\DoNotBuild.txt" (
echo Skipping building archives as DoNotBuild.txt exists
goto exit
)

REM build the archives
:build_archives
echo building archives as DoNotBuild.txt doesn't exist
cd /D "%SolutionDir%Resources\Files\"
%SolutionDir%Resources\Tools\7z.exe a "%ProjectDir%Resources\files.7z" * -mx9 -ssp
if not %ERRORLEVEL% == 0 (
echo Failed to compress files.7z
exit /b
)
cd /D "%SolutionDir%Resources\Extras\"
%SolutionDir%Resources\Tools\7z.exe a "%ProjectDir%Resources\extras.7z" * -mx9 -ssp
if not %ERRORLEVEL% == 0 (
echo Failed to compress extras.7z
exit /b
)
cd /D "%SolutionDir%Resources\Themes\"
%SolutionDir%Resources\Tools\7z.exe a "%ProjectDir%Resources\themes.7z" * -mx9 -ssp
if not %ERRORLEVEL% == 0 (
echo Failed to compress themes.7z
exit /b
)

echo "Delete this file to recompress the archives" > %SolutionDir%Resources\DoNotBuild.txt

:exit

0 comments on commit a46b9cf

Please sign in to comment.