While rewritting a few of my personal tools from Rust back to C++, I found myself willing to automate the build process. At first, I tried to invoke MSVC’s cl compiler directly, but it has proven to be absolute hell to do.
Eventually I stumbled upon the marvellous MSBuild tool, which is capable of understanding the .sln file and take all compiler and linker options from it:
msbuild foo.sln /p:Configuration=Release /p:Platform=x64
With that, I finally had the script to automate one build:
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" set APP="vscode-font-patch" msbuild %APP%.sln /p:Configuration=Release /p:Platform=x64 move /Y x64_Release\%APP%.exe "D:\Stuff\apps\_audio tools\" rmdir /S /Q x64_Release pause
Then it was time to automate the release build of all my listed projects:
@echo off call "C:\Program Files\Microsoft Visual Studio\18\Professional\VC\Auxiliary\Build\vcvars64.bat" call :Deploy "id3-fit" call :Deploy "sync-folders" call :Deploy "yt-dl" pause :Deploy cd .\%~1 msbuild %~1.slnx /p:Configuration=Release /p:Platform=x64 move /Y x64_Release\%~1.exe .\ rmdir /S /Q x64_Release cd .. goto :eof
The main point is that :Deploy is a function, with %~1 being the first argument, and goto :eof being the return statement. All functions must appear after the code itself.
No comments:
Post a Comment