27 lines
598 B
Bash
Executable File
27 lines
598 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Main build process
|
|
build() {
|
|
local os=$1
|
|
local arch=$2
|
|
local output=$3
|
|
|
|
# Set GOOS and GOARCH for cross-compilation
|
|
export GOOS=$os
|
|
export GOARCH=$arch
|
|
|
|
# Disable CGO only for cross-compilation
|
|
if [ "$os" != "$(go env GOOS)" ] || [ "$arch" != "$(go env GOARCH)" ]; then
|
|
export CGO_ENABLED=0
|
|
fi
|
|
|
|
if [ "$os" = "windows" ]; then
|
|
export CC=x86_64-w64-mingw32-gcc
|
|
export CXX=x86_64-w64-mingw32-g++
|
|
fi
|
|
|
|
go build -buildvcs=false -ldflags="-s -w" -o $output
|
|
}
|
|
|
|
# Call build with provided arguments
|
|
build "$1" "$2" "$3" |