forked from OwO-Network/DeepLX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.cross_compile.sh
38 lines (33 loc) · 1.12 KB
/
.cross_compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
###
# @Author: Vincent Young
# @Date: 2022-10-20 02:19:06
# @LastEditors: Vincent Young
# @LastEditTime: 2023-02-18 20:45:52
# @FilePath: /DeepLX/.cross_compile.sh
# @Telegram: https://t.me/missuo
#
# Copyright © 2022 by Vincent, All Rights Reserved.
###
set -e
DIST_PREFIX="deeplx"
DEBUG_MODE=${2}
TARGET_DIR="dist"
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"
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
CGO_ENABLED=0 go build -trimpath -gcflags "all=-N -l" -o ${TARGET} \
-ldflags "-w -s" main.go
else
CGO_ENABLED=0 go build -trimpath -o ${TARGET} \
-ldflags "-w -s" main.go
fi
done