-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
142 lines (127 loc) · 3.76 KB
/
Copy pathbuild.bat
File metadata and controls
142 lines (127 loc) · 3.76 KB
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
@echo off
setlocal
set REKEY=0
set PACK=0
set MINBUILD=0
set CLEAN=0
set HELP=0
:parse_args
if "%1"=="" goto :done_parse
if /i "%1"=="/rekey" set REKEY=1
if /i "%1"=="/pack" set PACK=1
if /i "%1"=="/minbuild" set MINBUILD=1
if /i "%1"=="/clean" set CLEAN=1
if /i "%1"=="/help" set help=1
shift
goto :parse_args
:done_parse
if %HELP%==1 (
echo QuickChat Build Environment
echo This script is used to build QuickChat with different configurations.
echo.
echo Supported arguments:
echo build.bat [/help] [/clean] [/minbuild] [/rekey] [/pack]
echo.
echo /help - Show this help.
echo /clean - Delete existing compiled files.
echo /minbuild - Compile QuickChat with minimal configuration.
echo /rekey - Regenerate XOR key.
echo /pack - Pack compiled binary into ZIP archive.
goto end
)
echo ==== Build parameters =====
echo Clean: %CLEAN%
echo MinBuild: %MINBUILD%
echo ReKey: %REKEY%
echo Pack: %PACK%
echo ===========================
echo.
if %CLEAN%==1 (
echo Deleting previous build files...
if exist quickchat.exe del quickchat.exe
if exist quickchat.zip del quickchat.zip
if exist resource.o del resource.o
if exist servconn.o del servconn.o
if exist chatlog.txt del chatlog.txt
if exist key.h del key.h
echo [OK] Done cleaning
goto end
)
if %MINBUILD%==1 (
if not exist minbuildconn.o (
echo [ERROR] minbuildconn.o is not found.
goto end
)
echo Generating key...
if not exist key.h python keygen.py
echo Compiling QuickChat...
gcc quickchat.c minbuildconn.o -o quickchat.exe -m32 -lgdi32 -lwinmm -lws2_32 -lcomctl32 -lshell32 -Wall -Wextra -municode
echo Done.
goto end
)
if exist .\quickchat.exe set PREVBLD=1
if exist .\QuickChat.zip set PREVBLD=1
if exist .\key.h set PREVBLD=1
if exist .\servconn.o set PREVBLD=1
if exist .\resource.o set PREVBLD=1
if exist .\chatlog.txt set PREVBLD=1
if "%PREVBLD%"=="1" (
echo.
echo Warning! One or several previous build files have been detected.
echo It is recommended to run "build.bat /clean" before building.
echo.
)
if %REKEY%==1 (
echo Rekeying: removing old key.h...
if exist key.h del key.h
)
if not exist key.h (
echo Generating key.h...
python keygen.py
if %errorlevel% neq 0 (
echo [ERROR] Key generation FAILED
exit /b 1
)
echo [OK] Key generated
) else (
echo [OK] key.h exists, skipping generation ^(use build /rekey to generate new^)
)
echo Building dialog...
windres --target=pe-i386 servconn.rc -o servconn.o
if %errorlevel% neq 0 (
echo [ERROR] Dialog FAILED
exit /b 1
)
echo [OK] Dialog built
echo Building resources...
windres --target=pe-i386 resource.rc -o resource.o
if %errorlevel% neq 0 (
echo [ERROR] Resources FAILED
exit /b 1
)
echo [OK] Resources built
echo Compiling QuickChat...
gcc quickchat.c servconn.o resource.o -o quickchat.exe -m32 -lgdi32 -lwinmm -lws2_32 -lcomctl32 -lshell32 -mwindows -s -Wl,--gc-sections -Wl,--subsystem,windows:5.0 -Wall -Wextra -municode
if %errorlevel% neq 0 (
echo [ERROR] Build FAILED
exit /b 1
)
echo [OK] Build successful: quickchat.exe
if %PACK%==1 (
echo Packing final package...
7z a QuickChat.zip readme.txt > nul
7z a QuickChat.zip join.wav > nul
7z a QuickChat.zip leave.wav > nul
7z a QuickChat.zip newmsg.wav > nul
7z a QuickChat.zip quickchat.exe > nul
if %errorlevel% neq 0 (
echo [ERROR] Packing FAILED
exit /b 1
)
echo [OK] Package created: QuickChat.zip
powershell Get-FileHash .\QuickChat.zip
) else (
echo [INFO] Skipping pack (use build /pack to create archive)
)
:end
endlocal