Code clean-up and refactoring.
[tee-win32.git] / make.cmd
blobc9874b442338c6ab647a0cd54b4b71e5503f40e8
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 if "%PANDOC_EXE%"=="" (
9 set "PANDOC_EXE=C:\Program Files\Pandoc\pandoc.exe"
12 set "SOLUTION_FILE=tee.sln"
14 if exist "%MSVC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" (
15 call "%MSVC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x86
16 ) else (
17 echo vcvarsall.bat not found. Please check your MSVC_PATH variable!
18 goto BuildError
21 REM ------------------------------------------------------------
22 REM CLEAN UP
23 REM ------------------------------------------------------------
25 if exist "%CD%\bin\" rmdir /S /Q "%CD%\bin"
26 if exist "%CD%\bin\" (
27 echo Failed to clean up intermediate files!
28 goto BuildError
31 if exist "%CD%\obj\" rmdir /S /Q "%CD%\obj"
32 if exist "%CD%\obj\" (
33 echo Failed to clean up intermediate files!
34 goto BuildError
37 REM ------------------------------------------------------------
38 REM BUILD EXECUTABLES
39 REM ------------------------------------------------------------
41 MSBuild.exe /property:Platform=x86 /property:Configuration=Release /target:rebuild "%CD%\%SOLUTION_FILE%"
42 if not "%ERRORLEVEL%"=="0" goto BuildError
44 MSBuild.exe /property:Platform=x64 /property:Configuration=Release /target:rebuild "%CD%\%SOLUTION_FILE%"
45 if not "%ERRORLEVEL%"=="0" goto BuildError
47 MSBuild.exe /property:Platform=a64 /property:Configuration=Release /target:rebuild "%CD%\%SOLUTION_FILE%"
48 if not "%ERRORLEVEL%"=="0" goto BuildError
50 REM ------------------------------------------------------------
51 REM COPY FILES
52 REM ------------------------------------------------------------
54 if not exist "%CD%\out\" mkdir "%CD%\out"
56 if exist "%CD%\out\tee-x86.exe" del /F "%CD%\out\tee-x86.exe"
57 if exist "%CD%\out\tee-x64.exe" del /F "%CD%\out\tee-x64.exe"
58 if exist "%CD%\out\tee-a64.exe" del /F "%CD%\out\tee-a64.exe"
60 copy /Y /B "%CD%\bin\Win32\Release\tee.exe" "%CD%\out\tee-x86.exe"
61 copy /Y /B "%CD%\bin\x64\.\Release\tee.exe" "%CD%\out\tee-x64.exe"
62 copy /Y /B "%CD%\bin\ARM64\Release\tee.exe" "%CD%\out\tee-a64.exe"
64 attrib +R "%CD%\out\tee-x86.exe"
65 attrib +R "%CD%\out\tee-x64.exe"
66 attrib +R "%CD%\out\tee-a64.exe"
68 REM ------------------------------------------------------------
69 REM CREATE DOCS
70 REM ------------------------------------------------------------
72 if exist "%CD%\out\README.html" del /F "%CD%\out\README.html"
74 "%PANDOC_EXE%" -f markdown -t html5 --metadata pagetitle="tee for Windows" --embed-resources --standalone --css "%CD%\etc\style\github-markdown.css" -o "%CD%\out\README.html" "%CD%\README.md"
76 attrib +R "%CD%\out\README.html"
78 REM ------------------------------------------------------------
79 REM COMPLETED
80 REM ------------------------------------------------------------
82 echo.
83 echo Build completed.
84 echo.
85 pause
86 goto:eof
88 REM ------------------------------------------------------------
89 REM BUILD ERROR
90 REM ------------------------------------------------------------
92 :BuildError
93 echo.
94 echo Build has failed !!!
95 echo.
96 pause