Repository navigation
Expand file tree
/
Copy pathmake.bat
More file actions
108 lines (87 loc) · 2.9 KB
/
Copy pathmake.bat
File metadata and controls
108 lines (87 loc) · 2.9 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
@echo off
setlocal EnableDelayedExpansion
REM Default version if not provided
if "%VERSION%"=="" set VERSION=1.0.0
REM Build metadata
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd_HH:mm:ss"') do set BUILD_TIME=%%i
for /f %%i in ('git rev-parse --short HEAD 2^>nul') do set GIT_COMMIT=%%i
if "%GIT_COMMIT%"=="" set GIT_COMMIT=unknown
for /f %%i in ('go env GOOS') do set GOOS_VAL=%%i
for /f %%i in ('go env GOARCH') do set GOARCH_VAL=%%i
set BUILD_ARCH=%GOOS_VAL%/%GOARCH_VAL%
for /f "tokens=3" %%i in ('go version') do set GO_VERSION=%%i
REM LDFLAGS
set LDFLAGS=-X github.com/sqpp/flex-golang.Version=%VERSION% ^
-X github.com/sqpp/flex-golang.BuildTime=%BUILD_TIME% ^
-X github.com/sqpp/flex-golang.GitCommit=%GIT_COMMIT% ^
-X github.com/sqpp/flex-golang.Author=marcell ^
-X github.com/sqpp/flex-golang.ProjectURL=https://pagercast.com ^
-X github.com/sqpp/flex-golang.BuildArch=%BUILD_ARCH% ^
-X github.com/sqpp/flex-golang.BuildGoVer=%GO_VERSION%
REM Create bin folder
if not exist bin mkdir bin
if "%1"=="" goto build
if "%1"=="build" goto build
if "%1"=="install" goto install
if "%1"=="test" goto test
if "%1"=="clean" goto clean
if "%1"=="version" goto version
if "%1"=="cross-compile" goto cross
if "%1"=="help" goto help
:build
echo Building FLEX-GO v%VERSION%...
go build -ldflags "%LDFLAGS%" -o bin\flex-encode.exe ./cmd/flex-encode
go build -ldflags "%LDFLAGS%" -o bin\flex-decode.exe ./cmd/flex-decode
echo Build complete!
goto end
:install
go install -ldflags "%LDFLAGS%" ./cmd/flex-encode
go install -ldflags "%LDFLAGS%" ./cmd/flex-decode
goto end
:test
go test -v ./...
goto end
:clean
rmdir /s /q bin
goto end
:version
echo Version: %VERSION%
echo Build Time: %BUILD_TIME%
echo Git Commit: %GIT_COMMIT%
goto end
:cross
echo Cross-compiling...
set GOOS=linux
set GOARCH=amd64
go build -ldflags "%LDFLAGS%" -o bin\flex-encode-linux-amd64 ./cmd/flex-encode
go build -ldflags "%LDFLAGS%" -o bin\flex-decode-linux-amd64 ./cmd/flex-decode
set GOOS=linux
set GOARCH=arm64
go build -ldflags "%LDFLAGS%" -o bin\flex-encode-linux-arm64 ./cmd/flex-encode
go build -ldflags "%LDFLAGS%" -o bin\flex-decode-linux-arm64 ./cmd/flex-decode
set GOOS=windows
set GOARCH=amd64
go build -ldflags "%LDFLAGS%" -o bin\flex-encode-windows-amd64.exe ./cmd/flex-encode
go build -ldflags "%LDFLAGS%" -o bin\flex-decode-windows-amd64.exe ./cmd/flex-decode
set GOOS=darwin
set GOARCH=amd64
go build -ldflags "%LDFLAGS%" -o bin\flex-encode-darwin-amd64 ./cmd/flex-encode
go build -ldflags "%LDFLAGS%" -o bin\flex-decode-darwin-amd64 ./cmd/flex-decode
set GOOS=darwin
set GOARCH=arm64
go build -ldflags "%LDFLAGS%" -o bin\flex-encode-darwin-arm64 ./cmd/flex-encode
go build -ldflags "%LDFLAGS%" -o bin\flex-decode-darwin-arm64 ./cmd/flex-decode
echo Cross-compilation complete!
goto end
:help
echo Available targets:
echo build
echo install
echo test
echo clean
echo version
echo cross-compile
echo help
goto end
:end
endlocal