-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
44 lines (33 loc) · 884 Bytes
/
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
@echo off
setlocal
REM Platforms and architectures to build for
set platforms=windows linux darwin
set archs=amd64
REM Loop through platforms and architectures
for %%P in (%platforms%) do (
for %%A in (%archs%) do (
call :buildBinary %%P %%A
)
)
exit /b
:buildBinary
REM Build binary for given OS and architecture
REM Parameters:
REM %1 - GOOS (platform)
REM %2 - GOARCH (architecture)
set GOOS=%1
set GOARCH=%2
echo Building binary for %GOOS%/%GOARCH%...
REM Check if the target is Windows, and append .exe extension
set OUTPUT_BIN=bin\%GOARCH%-%GOOS%-gohostmon
if "%GOOS%"=="windows" (
set OUTPUT_BIN=%OUTPUT_BIN%.exe
)
go build -ldflags="-s -w" -o %OUTPUT_BIN%
if %errorlevel% neq 0 (
echo Failed to build %GOOS% %GOARCH% binary. Exiting.
exit /b 1
) else (
echo Successfully built %GOOS% %GOARCH% binary at %OUTPUT_BIN%.
)
exit /b 0