forked from 41Baloo/balooProxy
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.bat
More file actions
104 lines (85 loc) · 2.09 KB
/
build.bat
File metadata and controls
104 lines (85 loc) · 2.09 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
@echo off
setlocal enabledelayedexpansion
REM Variables
set BINARY_NAME=main
set SRC_DIR=.
set OUT_DIR=out
set FINGERPRINTS_DIR=.\global\fingerprints
set TEMPLATES_DIR=.\assets\html
REM Define OS and architectures
set "OS_LIST=linux windows freebsd openbsd"
set "ARCH_LIST=386 amd64 arm64"
REM Check the input argument
if "%1" == "clean" goto clean
if "%1" == "all" goto build_all
REM Find the index of the platform in the OS and ARCH lists
for %%O in (%OS_LIST%) do (
for %%A in (%ARCH_LIST%) do (
if "%1" == "%%O-%%A" (
call :build_platform %%O %%A
goto :eof
)
)
)
goto usage
REM Clean up the build
:clean
echo Cleaning up...
if exist "%OUT_DIR%" rd /S /Q "%OUT_DIR%"
goto :eof
REM Build for a specific platform
:build_platform
setlocal
set "OS=%1"
set "ARCH=%2"
set "EXT=.exe"
REM Ensure the output directory exists
if not exist "%OUT_DIR%" (
mkdir "%OUT_DIR%"
)
REM Determine the file extension based on OS
if "%OS%" == "windows" set "EXT=.exe"
if "%OS%" == "darwin" set "EXT="
if "%OS%" == "linux" set "EXT="
if "%OS%" == "freebsd" set "EXT="
if "%OS%" == "openbsd" set "EXT="
set "OUT_FILE=%OUT_DIR%\%BINARY_NAME%.%OS%-%ARCH%%EXT%"
echo Building for %OS% %ARCH%...
set GOOS=%OS%
set GOARCH=%ARCH%
go build -o "%OUT_FILE%" "%SRC_DIR%"
if errorlevel 1 goto :error
REM Copy static files
xcopy /Y /E "%FINGERPRINTS_DIR%\*" "%OUT_DIR%\fingerprints\" >nul
xcopy /Y /E "%TEMPLATES_DIR%\*" "%OUT_DIR%\html\" >nul
if errorlevel 1 goto :error
endlocal
goto :eof
REM Build all platforms
:build_all
echo Building for all platforms...
for %%O in (%OS_LIST%) do (
for %%A in (%ARCH_LIST%) do (
call :build_platform %%O %%A
)
)
goto :eof
REM Error handling
:error
echo An error occurred during the build process.
exit /b 1
REM Usage information
:usage
echo Usage: %0 ^<command^>
echo Commands:
REM Print commands dynamically
for %%O in (%OS_LIST%) do (
for %%A in (%ARCH_LIST%) do (
echo %%O-%%A Build for %%O %%A
)
)
echo all Build for all platforms
echo clean Clean the output directory
exit /b 1
:eof
endlocal