diff --git a/super_build.sh b/super_build.sh index ca07a59..020b49d 100644 --- a/super_build.sh +++ b/super_build.sh @@ -1,30 +1,28 @@ #!/bin/sh -export GOARCH=amd64 OUTPUT_DIR=./bin - GO_FILE_PATH="./main/main.go" PROGRAM_NAME=GoCMS -# Compile for Windows -GOOS=windows go build -o "$OUTPUT_DIR/${PROGRAM_NAME}_windows.exe" "$GO_FILE_PATH" -if [ $? -ne 0 ]; then - echo "Compilation for Windows failed." - exit $? -fi +platforms=("windows/amd64" "windows/arm64" "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64") -# Compile for Linux -GOOS=linux go build -o "$OUTPUT_DIR/${PROGRAM_NAME}_linux" "$GO_FILE_PATH" -if [ $? -ne 0 ]; then - echo "Compilation for Linux failed." - exit $? -fi +for platform in "${platforms[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + output_name="$OUTPUT_DIR/${PROGRAM_NAME}_${GOOS}_${GOARCH}" + + if [ "$GOOS" = "windows" ]; then + output_name+='.exe' + fi -# Compile for macOS -GOOS=darwin go build -o "$OUTPUT_DIR/${PROGRAM_NAME}_darwin" "$GO_FILE_PATH" -if [ $? -ne 0 ]; then - echo "Compilation for macOS failed." - exit $? -fi + echo "Building for $GOOS/$GOARCH..." + env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name" "$GO_FILE_PATH" + if [ $? -ne 0 ]; then + echo "Compilation for $GOOS/$GOARCH failed." + exit $? + fi +done echo "Compilation successful for all platforms."