forked from foodak/clumsy
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Windows build script, harden get_genie.ps1, update README and .gitignore #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
burning-calamity
wants to merge
1
commit into
master
Choose a base branch
from
codex/check-the-script-acpblt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| bin/ | ||
| build/ | ||
| .build/ | ||
| projects/* | ||
| !projects/*.sln | ||
| !projects/*.vcxproj | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| @echo off | ||
| setlocal EnableExtensions | ||
|
|
||
| rem Build clumsy with Visual Studio 2022. Arguments are optional: | ||
| rem build.bat [Release^|Debug] [x64^|x32] | ||
|
|
||
| set "CONFIGURATION=%~1" | ||
| set "PLATFORM=%~2" | ||
| if not defined CONFIGURATION set "CONFIGURATION=Release" | ||
| if not defined PLATFORM set "PLATFORM=x64" | ||
|
|
||
| if /i not "%CONFIGURATION%"=="Release" if /i not "%CONFIGURATION%"=="Debug" goto :usage | ||
| if /i not "%PLATFORM%"=="x64" if /i not "%PLATFORM%"=="x32" goto :usage | ||
| set "MSBUILD_PLATFORM=%PLATFORM%" | ||
| if /i "%PLATFORM%"=="x32" set "MSBUILD_PLATFORM=Win32" | ||
|
|
||
| set "ROOT=%~dp0" | ||
| set "SOLUTION=%ROOT%projects\clumsy.sln" | ||
| set "OUTPUT=%ROOT%bin\vs\%CONFIGURATION%\%PLATFORM%\clumsy.exe" | ||
| set "LOGDIR=%ROOT%.build" | ||
| set "BUILDLOG=%LOGDIR%\msbuild-%CONFIGURATION%-%PLATFORM%.log" | ||
| set "BOOTLOG=%LOGDIR%\build-%CONFIGURATION%-%PLATFORM%.log" | ||
|
|
||
| if not exist "%LOGDIR%" mkdir "%LOGDIR%" 2>nul | ||
| if errorlevel 1 ( | ||
| call :fail 1 "Could not create the build-log directory: %LOGDIR%" | ||
| exit /b 1 | ||
| ) | ||
| >"%BOOTLOG%" echo Build started %DATE% %TIME% | ||
| >>"%BOOTLOG%" echo Configuration: %CONFIGURATION% | ||
| >>"%BOOTLOG%" echo Platform: %MSBUILD_PLATFORM% | ||
| >>"%BOOTLOG%" echo Solution: %SOLUTION% | ||
|
|
||
| if not exist "%SOLUTION%" ( | ||
| call :fail 1 "Visual Studio solution not found: %SOLUTION%" | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| if /i "%PLATFORM%"=="x64" ( | ||
| set "WINDIVERTDIR=%ROOT%external\WinDivert-2.2.0-A\x64" | ||
| set "IUPDIR=%ROOT%external\iup-3.30_Win64_dll16_lib" | ||
| ) else ( | ||
| set "WINDIVERTDIR=%ROOT%external\WinDivert-2.2.0-A\x86" | ||
| set "IUPDIR=%ROOT%external\iup-3.30_Win32_dll16_lib" | ||
| ) | ||
|
|
||
| rem Fail before starting an expensive compile if the runtime package is incomplete. | ||
| if not exist "%WINDIVERTDIR%\WinDivert.dll" ( | ||
| call :fail 1 "Missing runtime dependency: %WINDIVERTDIR%\WinDivert.dll" | ||
| exit /b 1 | ||
| ) | ||
| if not exist "%WINDIVERTDIR%\WinDivert*.sys" ( | ||
| call :fail 1 "Missing WinDivert driver under: %WINDIVERTDIR%" | ||
| exit /b 1 | ||
| ) | ||
| if not exist "%IUPDIR%\iup.dll" ( | ||
| call :fail 1 "Missing runtime dependency: %IUPDIR%\iup.dll" | ||
| exit /b 1 | ||
| ) | ||
| if not exist "%ROOT%etc\config.txt" ( | ||
| call :fail 1 "Missing runtime dependency: %ROOT%etc\config.txt" | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| set "MSBUILD=" | ||
| set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" | ||
| for /f "delims=" %%I in ('where MSBuild.exe 2^>nul') do if not defined MSBUILD set "MSBUILD=%%I" | ||
| if not defined MSBUILD ( | ||
| if exist "%VSWHERE%" ( | ||
| for /f "usebackq delims=" %%I in (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do if not defined MSBUILD set "MSBUILD=%%I" | ||
| ) | ||
| ) | ||
|
|
||
| if not defined MSBUILD ( | ||
| >>"%BOOTLOG%" echo MSBuild discovery failed. | ||
| call :fail 1 "MSBuild was not found. Install Visual Studio 2022 or Build Tools with the Desktop development with C++ workload." | ||
| exit /b 1 | ||
| ) | ||
| >>"%BOOTLOG%" echo MSBuild: %MSBUILD% | ||
|
|
||
| echo Building %CONFIGURATION%^|%MSBUILD_PLATFORM% with "%MSBUILD%"... | ||
| del /q "%BUILDLOG%" 2>nul | ||
| rem Disable the generated project's legacy absolute-path post-build commands. | ||
| rem This script performs the same copies below using paths relative to the checkout. | ||
| "%MSBUILD%" "%SOLUTION%" /m /nologo /verbosity:minimal /t:Build /p:Configuration=%CONFIGURATION% /p:Platform=%MSBUILD_PLATFORM% /p:PostBuildEventUseInBuild=false /fl /flp:"logfile=%BUILDLOG%;verbosity=normal" | ||
| set "RESULT=%ERRORLEVEL%" | ||
| >>"%BOOTLOG%" echo MSBuild exit code: %RESULT% | ||
|
|
||
| if not "%RESULT%"=="0" ( | ||
| echo. | ||
| echo BUILD FAILED with exit code %RESULT%. | ||
| echo -------------------- detected issues -------------------- | ||
| findstr /i /c:": error " /c:"fatal error" /c:"error MSB" "%BUILDLOG%" | ||
| if errorlevel 1 echo No individual error line was detected; inspect the complete log. | ||
| echo --------------------------------------------------------- | ||
| echo Complete build log: "%BUILDLOG%" | ||
| call :wait_on_error | ||
| exit /b %RESULT% | ||
| ) | ||
|
|
||
| if not exist "%OUTPUT%" ( | ||
| echo ERROR: MSBuild reported success, but the executable was not found: | ||
| echo "%OUTPUT%" | ||
| echo Complete build log: "%BUILDLOG%" | ||
| call :wait_on_error | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| set "OUTPUTDIR=%ROOT%bin\vs\%CONFIGURATION%\%PLATFORM%" | ||
| copy /y "%WINDIVERTDIR%\WinDivert.dll" "%OUTPUTDIR%\" >nul | ||
| if errorlevel 1 goto :copy_failed | ||
| copy /y "%WINDIVERTDIR%\WinDivert*.sys" "%OUTPUTDIR%\" >nul | ||
| if errorlevel 1 goto :copy_failed | ||
| copy /y "%IUPDIR%\iup.dll" "%OUTPUTDIR%\" >nul | ||
| if errorlevel 1 goto :copy_failed | ||
| copy /y "%ROOT%etc\config.txt" "%OUTPUTDIR%\" >nul | ||
| if errorlevel 1 goto :copy_failed | ||
|
|
||
| echo. | ||
| echo BUILD SUCCEEDED | ||
| echo Executable: "%OUTPUT%" | ||
| echo Build log: "%BUILDLOG%" | ||
| exit /b 0 | ||
|
|
||
| :usage | ||
| echo Usage: %~nx0 [Release^|Debug] [x64^|x32] | ||
| echo Set BUILD_NO_PAUSE=1 to prevent pausing after an error. | ||
| call :wait_on_error | ||
| exit /b 2 | ||
|
|
||
| :copy_failed | ||
| echo ERROR: The executable was built, but a required runtime file could not be copied. | ||
| echo Verify the dependency files under "%ROOT%external" and review "%BUILDLOG%". | ||
| >>"%BOOTLOG%" echo Runtime dependency copy failed. | ||
| call :wait_on_error | ||
| exit /b 1 | ||
|
|
||
| :fail | ||
| echo. | ||
| echo ERROR: %~2 | ||
| if defined BOOTLOG >>"%BOOTLOG%" echo ERROR: %~2 | ||
| if defined BOOTLOG echo Diagnostic log: "%BOOTLOG%" | ||
| call :wait_on_error | ||
| exit /b %~1 | ||
|
|
||
| :wait_on_error | ||
| if defined CI exit /b 0 | ||
| if defined BUILD_NO_PAUSE exit /b 0 | ||
| echo. | ||
| echo Press any key to close this window... | ||
| pause >nul | ||
| exit /b 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the script is run from an older Visual Studio developer prompt,
wherecan select that prompt's MSBuild and prevent thevswherefallback from running, even if VS 2022 is installed. In the checkedprojects/clumsy.vcxproj, every configuration requires thev143toolset, so an older MSBuild can fail with an unavailable-toolset error despite a compatible installation being present; prefervswhereor validate the PATH candidate before accepting it.Useful? React with 👍 / 👎.