forked from virtuallynathan/qpep
-
Notifications
You must be signed in to change notification settings - Fork 2
/
installer.bat
170 lines (137 loc) · 3.54 KB
/
installer.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
@echo off
rem "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
echo ********************************
echo **** QPEP INSTALLER BUILDER ****
echo ********************************
echo.
set /A BUILD64=0
set /A BUILD32=0
if "%1" EQU "--build32" (
set /A BUILD32=1
)
if "%1" EQU "--build64" (
set /A BUILD64=1
)
if "%2" EQU "--build32" (
set /A BUILD32=1
)
if "%2" EQU "--build64" (
set /A BUILD64=1
)
if "%2" EQU "--rebuild" (
goto installer
)
if %BUILD64% EQU 0 (
if %BUILD32% EQU 0 (
echo Usage: installer.bat [--build32] [--build64]
echo.
goto fail
)
)
if %BUILD32% EQU 0 (
if %BUILD64% EQU 0 (
echo Usage: installer.bat [--build32] [--build64]
echo.
goto fail
)
)
ECHO [Requirements check: GO]
go version
if %ERRORLEVEL% GEQ 1 goto fail
ECHO [Requirements check: CMake]
cmake --version
if %ERRORLEVEL% GEQ 1 goto fail
ECHO [Requirements check: MSBuild]
msbuild --version
if %ERRORLEVEL% GEQ 1 goto fail
ECHO [Requirements check: Wix Toolkit]
heat -help
if %ERRORLEVEL% GEQ 1 goto fail
ECHO [Cleanup]
DEL /S /Q build 2> NUL
RMDIR build\64bits 2> NUL
RMDIR build\32bits 2> NUL
RMDIR build\installer 2> NUL
RMDIR build 2> NUL
echo OK
ECHO [Preparation]
MKDIR build\ 2> NUL
if %ERRORLEVEL% GEQ 1 goto fail
MKDIR build\64bits\ 2> NUL
if %ERRORLEVEL% GEQ 1 goto fail
MKDIR build\32bits\ 2> NUL
if %ERRORLEVEL% GEQ 1 goto fail
go clean
if %ERRORLEVEL% GEQ 1 goto fail
COPY /Y windivert\LICENSE build\LICENSE.windivert
if %ERRORLEVEL% GEQ 1 goto fail
COPY /Y LICENSE build\LICENSE
if %ERRORLEVEL% GEQ 1 goto fail
echo OK
set GOOS=windows
if %BUILD64% NEQ 0 (
set GOARCH=amd64
go clean -cache
ECHO [Copy dependencies 64bits]
COPY /Y windivert\x64\* build\64bits\
if %ERRORLEVEL% GEQ 1 goto fail
echo OK
ECHO [Build 64bits server/client]
set CGO_ENABLED=1
ECHO [Build backends 64bits]
pushd backend
go generate
if %ERRORLEVEL% GEQ 1 goto fail
popd
ECHO [Build 64bits server/client]
go build -o build\64bits\qpep.exe
if %ERRORLEVEL% GEQ 1 goto fail
echo OK
ECHO [Build 64bits tray icon]
pushd qpep-tray
if %ERRORLEVEL% GEQ 1 goto fail
set CGO_ENABLED=0
go build -ldflags -H=windowsgui -o ..\build\64bits\qpep-tray.exe
if %ERRORLEVEL% GEQ 1 goto fail
popd
echo OK
)
if %BUILD32% NEQ 0 (
set GOARCH=386
go clean -cache
ECHO [Copy dependencies 32bits]
COPY /Y windivert\x86\* build\32bits\
if %ERRORLEVEL% GEQ 1 goto fail
echo OK
set CGO_ENABLED=1
ECHO [Build backends 32bits]
pushd backend
go generate
if %ERRORLEVEL% GEQ 1 goto fail
popd
ECHO [Build 32bits server/client]
go build -x -o build\32bits\qpep.exe
if %ERRORLEVEL% GEQ 1 goto fail
echo OK
ECHO [Build 32bits tray icon]
pushd qpep-tray
if %ERRORLEVEL% GEQ 1 goto fail
set CGO_ENABLED=0
go build -ldflags -H=windowsgui -o ..\build\32bits\qpep-tray.exe
if %ERRORLEVEL% GEQ 1 goto fail
popd
echo OK
)
:installer
echo [Build of installer]
msbuild installer\installer.sln
if %ERRORLEVEL% GEQ 1 goto fail
echo ********************************
echo **** RESULT: SUCCESS ****
echo ********************************
exit /B 0
:fail
echo ********************************
echo **** RESULT: FAILURE ****
echo ********************************
exit /B 1