From 0a2682dde21a80a41229dcd6f66efe31c5847ec1 Mon Sep 17 00:00:00 2001 From: AdrUlb Date: Tue, 29 Jan 2019 14:35:36 +0100 Subject: If unable to find gcc uses MSBuild instead --- build.cmd | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- xeon.vcxproj | 22 +++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 xeon.vcxproj diff --git a/build.cmd b/build.cmd index 5595995..19af3b8 100644 --- a/build.cmd +++ b/build.cmd @@ -10,8 +10,10 @@ if exist "C:\MinGW" ( if "%mingwPath%"=="0" ( title Building C++ Program - Failed echo MinGW could not be found. Please make sure that MinGW is installed. + echo If you want to use MSBuild instead press enter. Otherwise close this window. pause>nul - exit + cls + goto msBuild ) if exist out ( echo Skipping making the "out" folder... @@ -22,4 +24,88 @@ echo Created the "out" folder.. g++ --version g++ -g main.cpp -o out/game.exe echo Building Complete! -pause>nul \ No newline at end of file +pause>nul +exit + + +:msBuild +title Building C++ Program - MSBuild +echo Building using MSBuild +:findMsBuild +set msBuildPath=0 +if exist "C:\Program Files\MSBuild" ( + set "msBuildPath=C:\Program Files\MSBuild" +) +if exist "C:\Program Files (x86)\MSBuild" ( + set "msBuildPath=C:\Program Files (x86)\MSBuild" +) +if "%msBuildPath%"=="0" ( + echo MSBuild could not be found. Please make sure that MSBuild is installed. + pause>nul + exit +) + +:findMsBuildVersion +set msBuildVersion=0 +if exist "%msBuildPath%\12.0" ( + set msBuildVersion=12.0 +) +if %msBuildVersion%==0 goto manualMsBuildVersionOverride + +:findTools +echo ---------------------------------------- +echo Found MSBuild version %msBuildVersion% +echo ---------------------------------------- + +set toolVersion=0 +if exist "%msBuildPath%\Microsoft.Cpp\v4.0\V110" ( + set toolVersion=v110 +) +if exist "%msBuildPath%\Microsoft.Cpp\v4.0\V120" ( + set toolVersion=v120 +) +if "%toolVersion%"=="0" goto manualToolVersionOverride + +:setVCTargets +echo ---------------------------------------- +echo Found VCTools version %toolVersion% +echo ---------------------------------------- + +set "VCTargetsPath=%msBuildPath%\Microsoft.Cpp\v4.0\%toolVersion%" + +:build +echo Building Program... +"%msBuildPath%\%msBuildVersion%\Bin\msbuild.exe" xeon.vcxproj /p:outdir=out /p:assemblyname=game /p:configuration=release > msbuild.log +echo Building Complete! +pause>nul +exit + + + +:manualMsBuildVersionOverride +echo Could not find MSBuild 12.0 +echo Please specify the installed version manually or close this window, +echo install either of these versions and try again. +set /p manualMsBuildVersion=MSBuild version number: +set msBuildVersion=%manualmsBuildVersion% +if exist "%msBuildPath%\%manualMsBuildVersion%" ( + goto findTools +) else ( + echo Could not find MSBuild version! + pause>nul + exit +) + +:manualToolVersionOverride +echo Could not find MSBuild tools V120 or V110. +echo Please specify the version of installed tools manually +echo or close this window, install either of these versions and try again. +set /p manualToolVersion=Tool version number: +set toolVersion=v%manualToolVersion% +if exist "%msBuildPath%\Microsoft.Cpp\v4.0\%toolVersion%" ( + goto setVCTargets +) else ( + echo Could not find tool version! + pause>nul + exit +) diff --git a/xeon.vcxproj b/xeon.vcxproj new file mode 100644 index 0000000..eae4ea7 --- /dev/null +++ b/xeon.vcxproj @@ -0,0 +1,22 @@ + + + + Debug + Win32 + + + Release + Win32 + + + + + Application + $(toolVersion) + + + + + + + \ No newline at end of file -- cgit v1.2.3