-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbuild.bat
147 lines (122 loc) · 4.82 KB
/
build.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@ECHO OFF
REM Copyright (C) 2011-2015, 2017, 2019-2022 XhmikosR
REM
REM This program is free software: you can redistribute it and/or modify
REM it under the terms of the GNU General Public License as published by
REM the Free Software Foundation, either version 3 of the License, or
REM (at your option) any later version.
REM
REM This program is distributed in the hope that it will be useful,
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
REM GNU General Public License for more details.
REM
REM You should have received a copy of the GNU General Public License
REM along with this program. If not, see <http://www.gnu.org/licenses/>.
SETLOCAL ENABLEEXTENSIONS
CD /D %~dp0
rem Check for the help switches
IF /I "%~1" == "help" GOTO SHOWHELP
IF /I "%~1" == "/help" GOTO SHOWHELP
IF /I "%~1" == "-help" GOTO SHOWHELP
IF /I "%~1" == "--help" GOTO SHOWHELP
IF /I "%~1" == "/?" GOTO SHOWHELP
rem Check for the first switch
IF "%~1" == "" (
SET "BUILDTYPE=Build"
) ELSE (
IF /I "%~1" == "Build" SET "BUILDTYPE=Build" & GOTO CHECKSECONDARG
IF /I "%~1" == "/Build" SET "BUILDTYPE=Build" & GOTO CHECKSECONDARG
IF /I "%~1" == "-Build" SET "BUILDTYPE=Build" & GOTO CHECKSECONDARG
IF /I "%~1" == "--Build" SET "BUILDTYPE=Build" & GOTO CHECKSECONDARG
IF /I "%~1" == "Clean" SET "BUILDTYPE=Clean" & GOTO CHECKSECONDARG
IF /I "%~1" == "/Clean" SET "BUILDTYPE=Clean" & GOTO CHECKSECONDARG
IF /I "%~1" == "-Clean" SET "BUILDTYPE=Clean" & GOTO CHECKSECONDARG
IF /I "%~1" == "--Clean" SET "BUILDTYPE=Clean" & GOTO CHECKSECONDARG
IF /I "%~1" == "Rebuild" SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
IF /I "%~1" == "/Rebuild" SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
IF /I "%~1" == "-Rebuild" SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
IF /I "%~1" == "--Rebuild" SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
ECHO.
ECHO Unsupported commandline switch!
ECHO Run "%~nx0 help" for details about the commandline switches.
CALL :SUBMSG "ERROR" "Compilation failed!"
)
:CHECKSECONDARG
rem Check for the second switch
IF "%~2" == "" (
SET "ARCH=all"
) ELSE (
IF /I "%~2" == "x86" SET "ARCH=x86" & GOTO START
IF /I "%~2" == "/x86" SET "ARCH=x86" & GOTO START
IF /I "%~2" == "-x86" SET "ARCH=x86" & GOTO START
IF /I "%~2" == "--x86" SET "ARCH=x86" & GOTO START
IF /I "%~2" == "x64" SET "ARCH=x64" & GOTO START
IF /I "%~2" == "/x64" SET "ARCH=x64" & GOTO START
IF /I "%~2" == "-x64" SET "ARCH=x64" & GOTO START
IF /I "%~2" == "--x64" SET "ARCH=x64" & GOTO START
IF /I "%~2" == "all" SET "ARCH=all" & GOTO START
IF /I "%~2" == "/all" SET "ARCH=all" & GOTO START
IF /I "%~2" == "-all" SET "ARCH=all" & GOTO START
IF /I "%~2" == "--all" SET "ARCH=all" & GOTO START
ECHO.
ECHO Unsupported commandline switch!
ECHO Run "%~nx0 help" for details about the commandline switches.
CALL :SUBMSG "ERROR" "Compilation failed!"
)
:START
CALL :SubVSPath
IF NOT EXIST "%VS_PATH%" CALL :SUBMSG "ERROR" "Visual Studio NOT FOUND!"
IF "%ARCH%" == "x64" GOTO x64
IF "%ARCH%" == "x86" GOTO x86
:x86
CALL "%VS_PATH%\Common7\Tools\VsDevCmd.bat" -arch=x86
CALL :SUBMSVC %BUILDTYPE% Win32
IF "%ARCH%" == "x86" GOTO END
:x64
CALL "%VS_PATH%\Common7\Tools\VsDevCmd.bat" -arch=amd64
CALL :SUBMSVC %BUILDTYPE% x64
IF /I "%BUILDTYPE%" == "Clean" GOTO END
CALL "setup\build_installer.bat"
:END
TITLE Building PerfmonBar - Finished!
ENDLOCAL
EXIT /B
:SUBMSVC
ECHO.
TITLE Building PerfmonBar - %~1 "Release|%~2"...
SET "MSBUILD_SWITCHES=/nologo /consoleloggerparameters:Verbosity=minimal /maxcpucount /nodeReuse:true"
MSBuild.exe PerfmonBar.sln %MSBUILD_SWITCHES% /target:%~1 /property:Configuration=Release;Platform=%2
IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!"
EXIT /B
:SHOWHELP
TITLE "%~nx0 %1"
ECHO. & ECHO.
ECHO Usage: %~nx0 [Clean^|Build^|Rebuild] [x86^|x64^|all]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO The arguments are not case sensitive.
ECHO. & ECHO.
ECHO Executing "%~nx0" will use the defaults: "%~nx0 build all"
ECHO.
ECHO If you skip the second argument the default one will be used.
ECHO The same goes for the third argument. Examples:
ECHO "%~nx0 rebuild" is the same as "%~nx0 rebuild all"
ECHO.
ECHO WARNING: "%~nx0 x86" won't work.
ECHO.
ENDLOCAL
EXIT /B
:SubVSPath
FOR /f "delims=" %%A IN ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath -latest -requires Microsoft.Component.MSBuild Microsoft.VisualStudio.Component.VC.ATL Microsoft.VisualStudio.Component.VC.Tools.x86.x64') DO SET "VS_PATH=%%A"
EXIT /B
:SUBMSG
ECHO. & ECHO ______________________________
ECHO [%~1] %~2
ECHO ______________________________ & ECHO.
IF /I "%~1" == "ERROR" (
IF NOT DEFINED CI PAUSE
EXIT
) ELSE (
EXIT /B
)