This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks-controller.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 2649b8f  Remove the detection of GOARCH and GOOS when building (#218)
2649b8f is described below

commit 2649b8f08c1bbc851509a4f182970d3294216def
Author: hulk <[email protected]>
AuthorDate: Sat Nov 16 15:10:58 2024 +0800

    Remove the detection of GOARCH and GOOS when building (#218)
    
    Most users don't need to have the cross-compilation, and
    the script for detecting the OS and ARCH might be wrong in some niche
    operation systems. So let's remove this and users can specify the
    GOOS/GOARCH environment explicitly if they want.
---
 Makefile         |  4 +---
 scripts/build.sh | 70 ++++----------------------------------------------------
 2 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/Makefile b/Makefile
index e58d681..ac15bee 100644
--- a/Makefile
+++ b/Makefile
@@ -21,15 +21,13 @@ CCCOLOR="\033[37;1m"
 MAKECOLOR="\033[32;1m"
 ENDCOLOR="\033[0m"
 
-BUILDER_IMAGE="none"
-
 all: $(PROGRAM)
 
 .PHONY: all
 
 
 $(PROGRAM):
-       @bash scripts/build.sh $(BUILDER_IMAGE)
+       @bash scripts/build.sh
        @echo ""
        @printf $(MAKECOLOR)"Hint: It's a good idea to run 'make test' 
;)"$(ENDCOLOR)
        @echo ""
diff --git a/scripts/build.sh b/scripts/build.sh
index 549531c..af16c96 100644
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -17,60 +17,6 @@
 #
 
 set -e
-BUILDER_IMAGE=${1:-none}
-if test -z "$TARGET_OS"; then
-    uname_S=`uname -s`
-    case "$uname_S" in
-        Darwin)
-            TARGET_OS=darwin
-            ;;
-        OpenBSD)
-            TARGET_OS=openbsd
-            ;;
-        DragonFly)
-            TARGET_OS=dragonfly
-            ;;
-        FreeBSD)
-            TARGET_OS=freebsd
-            ;;
-        NetBSD)
-            TARGET_OS=netbsd
-            ;;
-        SunOS)
-            TARGET_OS=solaris
-            ;;
-        *)
-            TARGET_OS=linux
-            ;;
-    esac
-fi
-
-if test -z "$TARGET_ARCH"; then
-    uname_M=`uname -m`
-    case "$uname_M" in
-        x86_64)
-            TARGET_ARCH=amd64
-            ;;
-        arm32)
-            TARGET_ARCH=arm32
-            ;;
-        arm64)
-            TARGET_ARCH=arm64
-            ;;
-        ppc64*)
-            TARGET_ARCH=ppc64
-            ;;
-        aarch64)
-            TARGET_ARCH=arm
-            ;;
-        i386)
-            TARGET_ARCH=386
-            ;;
-        *)
-            TARGET_ARCH=amd64
-            ;;
-    esac
-fi
 
 GO_PROJECT=github.com/apache/kvrocks-controller
 BUILD_DIR=./_build
@@ -86,24 +32,16 @@ for TARGET_NAME in "$SERVER_TARGET_NAME" 
"$CLIENT_TARGET_NAME"; do
         CMD_PATH="${GO_PROJECT}/cmd/client"
     fi
 
-    if [[ "$BUILDER_IMAGE" == "none" ]]; then
-        GOOS="$TARGET_OS" GOARCH="$TARGET_ARCH" CGO_ENABLED=0 go build -v 
-ldflags \
-            "-X $GO_PROJECT/version.Version=$VERSION" \
-            -o ${TARGET_NAME} ${CMD_PATH}
-    else
-        docker run --rm --privileged -it -v $(pwd):/${TARGET_NAME} -w 
/${TARGET_NAME} \
-            -e GOOS="$TARGET_OS" -e GOARCH="$TARGET_ARCH" -e CGO_ENABLED=0 \
-            $BUILDER_IMAGE go build -v -ldflags \
-            "-X $GO_PROJECT/version.Version=$VERSION" \
-            -o /${TARGET_NAME}/${TARGET_NAME} ${CMD_PATH}
-    fi
+    CGO_ENABLED=0 go build -v -ldflags \
+        "-X $GO_PROJECT/version.Version=$VERSION" \
+        -o ${TARGET_NAME} ${CMD_PATH}
 
     if [[ $? -ne 0 ]]; then
         echo "Failed to build $TARGET_NAME"
         exit 1
     fi
 
-    echo "Build $TARGET_NAME, OS is $TARGET_OS, Arch is $TARGET_ARCH"
+    echo "Build $TARGET_NAME successfully"
 done
 
 rm -rf ${BUILD_DIR}

Reply via email to