forked from ladislav-zezula/FileTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-msvc.bat
91 lines (79 loc) · 4.94 KB
/
make-msvc.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
:: Build file for Visual Studio 2008 and 2017
@echo off
:: Save the values of INCLUDE, LIB and PATH
set PROJECT_DIR=%~dp0
set SAVE_INCLUDE=%INCLUDE%
set SAVE_PATH=%PATH%
set SAVE_LIB=%LIB%
set PROJECT_NAME=FileTest
set PROJECT_ZIP_NAME=filetest
:: Remember whether we shall publish the project
if "x%1" == "x/web" set PUBLISH_PROJECT=1
:: Determine where the program files are, both for 64-bit and 32-bit Windows
if exist "%ProgramW6432%" set PROGRAM_FILES_X64=%ProgramW6432%
if exist "%ProgramFiles%" set PROGRAM_FILES_DIR=%ProgramFiles%
if exist "%ProgramFiles(x86)%" set PROGRAM_FILES_DIR=%ProgramFiles(x86)%
:: Determine the installed version of Visual Studio (Prioritize Enterprise over Professional)
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" set VCVARS_2008=%PROGRAM_FILES_DIR%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_X64%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_X64%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_X64%\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_X64%\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat
if exist "%PROGRAM_FILES_X64%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_20xx=%PROGRAM_FILES_X64%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat
:: Build the project using Visual Studio 2008 and 2017+
rem if not "x%VCVARS_2008%" == "x" call :BuildProject "%VCVARS_2008%" %PROJECT_NAME%_vs08.sln En en x86 Win32
rem if not "x%VCVARS_2008%" == "x" call :BuildProject "%VCVARS_2008%" %PROJECT_NAME%_vs08.sln En en x64 x64
if not "x%VCVARS_20xx%" == "x" call :BuildProject "%VCVARS_20xx%" %PROJECT_NAME%.sln En en x86 Win32
if not "x%VCVARS_20xx%" == "x" call :BuildProject "%VCVARS_20xx%" %PROJECT_NAME%.sln En en x64 x64
echo [*] Build complete.
:: Update web pages
if not "x%PUBLISH_PROJECT%" == "x1" goto:eof
echo [*] Updating web pages ...
pushd ..\..\WWW
MakeWeb.exe /nologo
popd
goto:eof
::-----------------------------------------------------------------------------
:: Build the project
::
:: Parameters:
::
:: %1 Full path to the VCVARS.BAT file
:: %2 Plain name of the .sln solution file
:: %3 Language version (Cn, En, Ko, Pl, Ru)
:: %4 Language version lowercase (cn, en, ko, pl, ru)
:: %5 x86, x64, amd64_arm64
:: %6 Win32, x64, ARM64
::
:BuildProject
echo [*] Building %PROJECT_NAME% (%3, %6) ...
call %1 %5 >nul
devenv.com %2 /project "%PROJECT_NAME%" /rebuild "Release|%6" >nul
::if "%5" == "x64" PostBuild.exe %PROJECT_NAME%.rc /nologo
:PublishProject
if not "x%PUBLISH_PROJECT%" == "x1" goto RestoreEnvironment
if not exist .\bin\%6\Release\%PROJECT_NAME%.exe goto RestoreEnvironment
echo [*] Updating %PROJECT_NAME% in ZIP ...
pushd .\bin
copy .\%6\Release\%PROJECT_NAME%.exe .\%6\%PROJECT_NAME%.exe >nul
zip.exe -u9 ..\..\..\WWW\web\download\%PROJECT_ZIP_NAME%.zip .\%6\%PROJECT_NAME%.exe >nul
zip.exe -ju9 ..\..\..\WWW\web\download\%PROJECT_ZIP_NAME%.zip ..\doc\History.txt >nul
zip.exe -ju9 ..\..\..\WWW\web\download\%PROJECT_ZIP_NAME%.zip ..\doc\ReadMe.txt >nul
del .\%6\%PROJECT_NAME%.exe
popd
:: Restore environment variables to the old level
:RestoreEnvironment
set INCLUDE=%SAVE_INCLUDE%
set PATH=%SAVE_PATH%
set LIB=%SAVE_LIB%
:: Delete environment variables that are set by Visual Studio
set __VSCMD_PREINIT_PATH=
set EXTERNAL_INCLUDE=
set VSINSTALLDIR=
set VCINSTALLDIR=
set DevEnvDir=
set LIBPATH=