Some code clean-up + added simple build script.
[tee-win32.git] / make.cmd
blob74b28b3dc8c75084c3bd1e88d8e64a79808240a2
1 @echo off
2 cd /d "%~dp0"
4 if "%MSVC_PATH%"=="" (
5 set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
8 set "SOLUTION_FILE=tee.sln"
10 if exist "%MSVC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" (
11 call "%MSVC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x86
12 ) else (
13 echo vcvarsall.bat not found. Please check your MSVC_PATH variable!
14 goto BuildError
17 REM ------------------------------------------------------------
18 REM CLEAN UP
19 REM ------------------------------------------------------------
21 if exist "%CD%\bin\" rmdir /S /Q "%CD%\bin"
22 if exist "%CD%\bin\" (
23 echo Failed to clean up intermediate files!
24 goto BuildError
27 if exist "%CD%\obj\" rmdir /S /Q "%CD%\obj"
28 if exist "%CD%\obj\" (
29 echo Failed to clean up intermediate files!
30 goto BuildError
33 REM ------------------------------------------------------------
34 REM BUILD EXECUTABLES
35 REM ------------------------------------------------------------
37 MSBuild.exe /property:Platform=x86 /property:Configuration=Release /target:rebuild "%CD%\%SOLUTION_FILE%"
38 if not "%ERRORLEVEL%"=="0" goto BuildError
40 MSBuild.exe /property:Platform=x64 /property:Configuration=Release /target:rebuild "%CD%\%SOLUTION_FILE%"
41 if not "%ERRORLEVEL%"=="0" goto BuildError
43 REM ------------------------------------------------------------
44 REM COPY FILES
45 REM ------------------------------------------------------------
47 if not exist "%CD%\out\" mkdir "%CD%\out"
49 if exist "%CD%\out\tee-x86.exe" del /F "%CD%\out\tee-x86.exe"
50 if exist "%CD%\out\tee-x64.exe" del /F "%CD%\out\tee-x64.exe"
52 copy /Y /B "%CD%\bin\Win32\Release\tee.exe" "%CD%\out\tee-x86.exe"
53 copy /Y /B "%CD%\bin\x64\.\Release\tee.exe" "%CD%\out\tee-x64.exe"
55 attrib +R "%CD%\out\tee-x86.exe"
56 attrib +R "%CD%\out\tee-x64.exe"
58 REM ------------------------------------------------------------
59 REM COMPLETED
60 REM ------------------------------------------------------------
62 echo.
63 echo Build completed.
64 echo.
65 pause
66 goto:eof
68 REM ------------------------------------------------------------
69 REM BUILD ERROR
70 REM ------------------------------------------------------------
72 :BuildError
73 echo.
74 echo Build has failed !!!
75 echo.
76 pause