DeepLX/.cross_compile.sh

39 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2022-10-20 01:12:15 +08:00
2022-10-20 09:53:19 +08:00
###
# @Author: Vincent Young
# @Date: 2022-10-20 02:19:06
2024-03-21 04:52:54 +08:00
# @LastEditors: Vincent Yang
# @LastEditTime: 2024-03-20 16:52:40
2022-10-20 09:53:19 +08:00
# @FilePath: /DeepLX/.cross_compile.sh
# @Telegram: https://t.me/missuo
#
# Copyright © 2022 by Vincent, All Rights Reserved.
###
2022-10-20 01:12:15 +08:00
set -e
DIST_PREFIX="deeplx"
DEBUG_MODE=${2}
TARGET_DIR="dist"
2022-10-20 09:53:19 +08:00
PLATFORMS="darwin/amd64 darwin/arm64 linux/386 linux/amd64 linux/arm64 linux/mips openbsd/amd64 openbsd/arm64 freebsd/amd64 freebsd/arm64 windows/386 windows/amd64"
2022-10-20 01:12:15 +08:00
rm -rf ${TARGET_DIR}
mkdir ${TARGET_DIR}
for pl in ${PLATFORMS}; do
export GOOS=$(echo ${pl} | cut -d'/' -f1)
export GOARCH=$(echo ${pl} | cut -d'/' -f2)
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}
if [ "${GOOS}" == "windows" ]; then
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}.exe
fi
echo "build => ${TARGET}"
if [ "${DEBUG_MODE}" == "debug" ]; then
2023-02-18 20:46:16 +08:00
CGO_ENABLED=0 go build -trimpath -gcflags "all=-N -l" -o ${TARGET} \
2024-03-21 04:52:54 +08:00
-ldflags "-w -s" .
2022-10-20 01:12:15 +08:00
else
2023-02-18 20:46:16 +08:00
CGO_ENABLED=0 go build -trimpath -o ${TARGET} \
2024-03-21 04:52:54 +08:00
-ldflags "-w -s" .
2022-10-20 01:12:15 +08:00
fi
done