-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
54 lines (46 loc) · 1.12 KB
/
build.bat
File metadata and controls
54 lines (46 loc) · 1.12 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
@echo off
setlocal enabledelayedexpansion
echo Building CodeStatistics...
REM Check if Go is installed
go version >nul 2>&1
if errorlevel 1 (
echo Error: Go is not installed or not in PATH
exit /b 1
)
REM Clean previous builds
if exist "bin" rmdir /s /q bin
mkdir bin
REM Get dependencies
echo Getting dependencies...
go mod tidy
if errorlevel 1 (
echo Error: Failed to get dependencies
exit /b 1
)
REM Set common build flags
set CGO_ENABLED=0
set BUILD_FLAGS=-ldflags "-s -w -X 'main.version=1.0.0' -X 'main.buildTime=' -X 'main.gitCommit='"
REM Build for Windows x64
echo Building for Windows x64...
set GOOS=windows
set GOARCH=amd64
go build %BUILD_FLAGS% -o bin\CodeStatistics.exe main.go
if errorlevel 1 (
echo Error: Failed to build for Windows x64
exit /b 1
)
REM Build for Linux x64
echo Building for Linux x64...
set GOOS=linux
set GOARCH=amd64
go build %BUILD_FLAGS% -o bin\CodeStatistics_linux main.go
if errorlevel 1 (
echo Error: Failed to build for Linux x64
exit /b 1
)
echo.
echo Build completed successfully!
echo Output files:
dir /b bin\*
echo.
echo Usage: bin\CodeStatistics.exe -h