-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
52 lines (43 loc) · 1.1 KB
/
build.sh
File metadata and controls
52 lines (43 loc) · 1.1 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
#!/bin/bash
set -e
echo "Building CodeStatistics..."
# Check if Go is installed
if ! command -v go &> /dev/null; then
echo "Error: Go is not installed or not in PATH"
exit 1
fi
# Clean previous builds
if [ -d "bin" ]; then
rm -rf bin
fi
mkdir -p bin
# Get dependencies
echo "Getting dependencies..."
go mod tidy
if [ $? -ne 0 ]; then
echo "Error: Failed to get dependencies"
exit 1
fi
# Set common build flags
export CGO_ENABLED=0
BUILD_FLAGS='-ldflags "-s -w -X main.version=1.0.0 -X main.buildTime= -X main.gitCommit="'
# Build for Linux x64
echo "Building for Linux x64..."
GOOS=linux GOARCH=amd64 go build $BUILD_FLAGS -o bin/CodeStatistics_linux main.go
if [ $? -ne 0 ]; then
echo "Error: Failed to build for Linux x64"
exit 1
fi
# Build for Windows x64
echo "Building for Windows x64..."
GOOS=windows GOARCH=amd64 go build $BUILD_FLAGS -o bin/CodeStatistics.exe main.go
if [ $? -ne 0 ]; then
echo "Error: Failed to build for Windows x64"
exit 1
fi
echo ""
echo "Build completed successfully!"
echo "Output files:"
ls -la bin/
echo ""
echo "Usage: ./bin/CodeStatistics_linux -h"