-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
41 lines (32 loc) · 1.01 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
#!/bin/bash
# Define the bin directory and an array of target platforms and architectures
BIN_DIR="bin"
PLATFORMS=("linux" "linux" "windows" "windows" "darwin" "darwin")
ARCHS=("amd64" "arm64" "amd64" "arm64" "amd64" "arm64")
EXTENSIONS=("" "" ".exe" ".exe" "" "")
# Create bin directory if it doesn't exist
mkdir -p $BIN_DIR
# Function to build for a specific platform and architecture
build() {
local os=$1
local arch=$2
local ext=$3
local output="$BIN_DIR/wol-$os-$arch$ext"
if [ -f ${output} ]; then
rm -f ${output}
fi
echo "building $os/$arch binary file..."
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -o=$output main.go
if [ $? -ne 0 ]; then
echo "failed to build for $os/$arch"
else
echo "successfully build for $os/$arch"
fi
}
# Loop over all platforms and architectures
for i in ${!PLATFORMS[@]}; do
build ${PLATFORMS[$i]} ${ARCHS[$i]} ${EXTENSIONS[$i]} &
done
# Wait for all background processes to finish
wait
echo "build process completed."