forked from ikkentim/SampSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cmd
More file actions
230 lines (205 loc) · 5.88 KB
/
Copy pathbuild.cmd
File metadata and controls
230 lines (205 loc) · 5.88 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
@echo off
setlocal enabledelayedexpansion
set "TARGET=%~1"
if "%TARGET%"=="" goto usage
shift
set "ACTION="
if /i "%~1"=="test" (
set "ACTION=test"
shift
) else if /i "%~1"=="publish" (
set "ACTION=publish"
shift
)
set "CI_VERSION="
set "NO_BUILD_ARG="
:parse_options
if "%~1"=="" goto options_done
if /i "%~1"=="--no-build" (
set "NO_BUILD_ARG=--no-build"
shift
goto parse_options
)
set "ARG=%~1"
if /i "!ARG:~0,10!"=="--version=" (
set "CI_VERSION=!ARG:~10!"
if "!CI_VERSION!"=="" goto missing_version
shift
goto parse_options
)
if /i "%~1"=="--version" (
if "%~2"=="" goto missing_version
set "CI_VERSION=%~2"
shift
shift
goto parse_options
)
echo Invalid option: %~1
goto usage
:missing_version
echo Missing value for --version
exit /b 1
:options_done
set "SCRIPTDIR=%~dp0"
if /i "%TARGET%"=="legacy-plugin" (
if "%ACTION%"=="" (
echo Building legacy plugin x86...
call "%SCRIPTDIR%src\legacy\SampSharp\build.cmd"
if errorlevel 1 exit /b 1
goto end
) else if /i "%ACTION%"=="publish" (
echo Building and publishing legacy plugin x86...
call "%SCRIPTDIR%src\legacy\SampSharp\build.cmd"
if errorlevel 1 exit /b 1
call "%SCRIPTDIR%src\legacy\SampSharp\publish.cmd"
if errorlevel 1 exit /b 1
goto end
) else (
goto usage
)
)
if /i "%TARGET%"=="legacy-libraries" (
if "%ACTION%"=="" (
echo Building legacy C# libraries...
call :build_legacy_libraries
if errorlevel 1 exit /b 1
goto end
) else if /i "%ACTION%"=="publish" (
echo Building and packing legacy C# libraries...
call :pack_legacy_libraries
if errorlevel 1 exit /b 1
goto end
) else (
goto usage
)
)
if /i "%TARGET%"=="component" (
if "%ACTION%"=="" (
echo Building open.mp component...
call "%SCRIPTDIR%src\sampsharp-component\build.cmd"
if errorlevel 1 exit /b 1
goto end
) else if /i "%ACTION%"=="publish" (
echo Building and publishing open.mp component...
call "%SCRIPTDIR%src\sampsharp-component\build.cmd"
if errorlevel 1 exit /b 1
call "%SCRIPTDIR%src\sampsharp-component\publish.cmd"
if errorlevel 1 exit /b 1
goto end
) else (
goto usage
)
)
if /i "%TARGET%"=="component-libraries" set "TARGET=libraries"
if /i "%TARGET%"=="libraries" (
if "%ACTION%"=="" (
echo Building C# libraries...
call :build_component_libraries
if errorlevel 1 exit /b 1
goto end
) else if /i "%ACTION%"=="test" (
echo Testing C# libraries...
call :test_component_libraries
if errorlevel 1 exit /b 1
goto end
) else if /i "%ACTION%"=="publish" (
echo Building and packing C# libraries...
call :pack_component_libraries
if errorlevel 1 exit /b 1
goto end
) else (
goto usage
)
)
if /i "%TARGET%"=="clean" (
echo Cleaning build directory...
if exist "%SCRIPTDIR%build" (
rmdir /s /q "%SCRIPTDIR%build"
mkdir "%SCRIPTDIR%build"
)
echo Build directory cleaned.
goto end
)
echo Invalid target: %TARGET%
goto usage
:usage
echo.
echo Usage:
echo build.cmd legacy-plugin - Build legacy x86 plugin
echo build.cmd legacy-plugin publish - Build and publish legacy x86 plugin
echo build.cmd legacy-libraries - Build legacy C# libraries
echo build.cmd legacy-libraries publish - Build and pack legacy C# libraries
echo build.cmd component - Build open.mp component
echo build.cmd component publish - Build and publish open.mp component
echo build.cmd libraries - Build C# libraries
echo build.cmd libraries test - Test C# libraries
echo build.cmd libraries publish - Build and pack C# libraries
echo build.cmd clean - Delete build directory contents
echo.
echo Options:
echo --no-build - Skip the build step for tests
echo --version^=<version^> - Set the CI package version
exit /b 1
:build_legacy_libraries
cd /d "%SCRIPTDIR%src\legacy"
echo.
echo Building C# libraries...
if defined CI_VERSION (
dotnet build SampSharp.Legacy.slnx -c Release "/p:CiVersion=%CI_VERSION%"
) else (
dotnet build SampSharp.Legacy.slnx -c Release
)
if errorlevel 1 exit /b 1
exit /b 0
:pack_legacy_libraries
cd /d "%SCRIPTDIR%src\legacy"
echo.
echo Packing C# libraries...
if defined CI_VERSION (
dotnet pack SampSharp.Legacy.slnx -c Release "/p:CiVersion=%CI_VERSION%"
) else (
dotnet pack SampSharp.Legacy.slnx -c Release
)
if errorlevel 1 exit /b 1
echo.
echo NuGet packages created in: %SCRIPTDIR%build\artifacts\packages
exit /b 0
:build_component_libraries
cd /d "%SCRIPTDIR%"
echo.
echo Building C# libraries...
if defined CI_VERSION (
dotnet build SampSharp.slnx -c Release "/p:CiVersion=%CI_VERSION%"
) else (
dotnet build SampSharp.slnx -c Release
)
if errorlevel 1 exit /b 1
exit /b 0
:test_component_libraries
cd /d "%SCRIPTDIR%"
set "RESULTSDIR=%SCRIPTDIR%build\test-results\libraries"
if not exist "%RESULTSDIR%" mkdir "%RESULTSDIR%"
echo.
echo Testing C# libraries...
if defined CI_VERSION (
dotnet test SampSharp.slnx -c Release %NO_BUILD_ARG% --results-directory "%RESULTSDIR%" --logger "trx;LogFilePrefix=libraries" "/p:CiVersion=%CI_VERSION%"
) else (
dotnet test SampSharp.slnx -c Release %NO_BUILD_ARG% --results-directory "%RESULTSDIR%" --logger "trx;LogFilePrefix=libraries"
)
if errorlevel 1 exit /b 1
exit /b 0
:pack_component_libraries
cd /d "%SCRIPTDIR%"
echo.
echo Packing C# libraries...
if defined CI_VERSION (
dotnet pack SampSharp.slnx -c Release "/p:CiVersion=%CI_VERSION%"
) else (
dotnet pack SampSharp.slnx -c Release
)
if errorlevel 1 exit /b 1
echo.
echo NuGet packages created in: %SCRIPTDIR%build\artifacts\packages
exit /b 0
:end
echo Build complete.