From 23dae9ce5afabd73702e3bc52f3b6682da3fb44f Mon Sep 17 00:00:00 2001 From: Teddysun Date: Sat, 2 Sep 2023 15:06:22 +0900 Subject: [PATCH] Update build_hysteria.sh --- docker/hysteria/build_hysteria.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/hysteria/build_hysteria.sh b/docker/hysteria/build_hysteria.sh index ad3fd9e..216600b 100644 --- a/docker/hysteria/build_hysteria.sh +++ b/docker/hysteria/build_hysteria.sh @@ -4,7 +4,7 @@ # # Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x # -# Copyright (C) 2022 Teddysun +# Copyright (C) 2022 - 2023 Teddysun # # Reference URL: # https://github.com/apernet/hysteria @@ -23,11 +23,12 @@ echo "git clone https://github.com/apernet/hysteria.git" git clone https://github.com/apernet/hysteria.git cd hysteria || exit 2 +APP_SRC_CMD_PKG="github.com/apernet/hysteria/app/cmd" VERSION="$(git describe)" COMMIT="$(git rev-parse HEAD)" TIMESTAMP="$(date "+%F")" -LDFLAGS="-s -w -X 'main.appVersion=${VERSION}' -X 'main.appCommit=${COMMIT}' -X 'main.appDate=${TIMESTAMP}' -buildid=" +LDFLAGS="-s -w -X '${APP_SRC_CMD_PKG}.appVersion=${VERSION}' -X '${APP_SRC_CMD_PKG}.appCommit=${COMMIT}' -X '${APP_SRC_CMD_PKG}.appDate=${TIMESTAMP}' -X '${APP_SRC_CMD_PKG}.appType=release' -buildid=" ARCHS=( 386 amd64 arm arm64 ppc64le s390x ) ARMS=( 6 7 ) @@ -35,18 +36,18 @@ for ARCH in ${ARCHS[@]}; do if [ "${ARCH}" = "arm" ]; then for V in ${ARMS[@]}; do echo "Building hysteria_linux_${ARCH}${V}" - env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/hysteria_linux_${ARCH}${V} ./app/cmd || exit 1 + env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -trimpath -ldflags "${LDFLAGS} -X '${APP_SRC_CMD_PKG}.appPlatform=linux' -X '${APP_SRC_CMD_PKG}.appArch=${ARCH}'" -o ${cur_dir}/hysteria_linux_${ARCH}${V} ./app || exit 1 done else echo "Building hysteria_linux_${ARCH}" - env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/hysteria_linux_${ARCH} ./app/cmd || exit 1 + env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS} -X '${APP_SRC_CMD_PKG}.appPlatform=linux' -X '${APP_SRC_CMD_PKG}.appArch=${ARCH}'" -o ${cur_dir}/hysteria_linux_${ARCH} ./app || exit 1 fi done ARCHS=( 386 amd64 ) for ARCH in ${ARCHS[@]}; do echo "Building hysteria_windows_${ARCH}.exe" - env CGO_ENABLED=0 GOOS=windows GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/hysteria_windows_${ARCH}.exe ./app/cmd + env CGO_ENABLED=0 GOOS=windows GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS} -X '${APP_SRC_CMD_PKG}.appPlatform=windows' -X '${APP_SRC_CMD_PKG}.appArch=${ARCH}'" -o ${cur_dir}/hysteria_windows_${ARCH}.exe ./app done chmod +x ${cur_dir}/hysteria_*