-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
51 lines (44 loc) · 1.25 KB
/
build.sh
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
#!/bin/bash
# Enable Go modules
export GO111MODULE=on
# Set output directory
OUTPUT_DIR="build"
mkdir -p "$OUTPUT_DIR"
# Build for Windows
build_windows() {
echo "Building for Windows..."
GOOS=windows GOARCH=amd64 go build -ldflags "-H=windowsgui" -o "$OUTPUT_DIR/gorandomcaps.exe"
if [ $? -eq 0 ]; then
echo "Successfully built Windows executable: $OUTPUT_DIR/gorandomcaps.exe"
else
echo "Failed to build Windows executable."
exit 1
fi
}
# Build for macOS
build_macos() {
echo "Building for macOS..."
GOOS=darwin GOARCH=amd64 go build -o "$OUTPUT_DIR/gorandomcaps"
if [ $? -eq 0 ]; then
echo "Successfully built macOS executable: $OUTPUT_DIR/gorandomcaps"
else
echo "Failed to build macOS executable."
exit 1
fi
}
# Build for Linux
build_linux() {
echo "Building for Linux..."
GOOS=linux GOARCH=amd64 go build -o "$OUTPUT_DIR/gorandomcaps-linux"
if [ $? -eq 0 ]; then
echo "Successfully built Linux executable: $OUTPUT_DIR/gorandomcaps-linux"
else
echo "Failed to build Linux executable."
exit 1
fi
}
# Build for all platforms
build_windows
build_macos
build_linux
echo "All builds completed. Check the $OUTPUT_DIR directory for output files."