1 Star 0 Fork 28

Thouen/go-iot

forked from 有理想的鸭子/go-iot 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.sh 1.59 KB
一键复制 编辑 原始数据 按行查看 历史
有理想的鸭子 提交于 2024-07-05 17:41 +08:00 . fix: 支持mac m1芯片构建
#!/usr/bin/env bash
##### build.sh
RELEASE="1.1.3"
REPO=$(git config --get remote.origin.url)
GIT_COMMIT=$(git rev-parse --short HEAD)
# Build Flags
GO_LD_FLAGS="-s -w -X go-iot/pkg/option.RELEASE=${RELEASE} -X go-iot/pkg/option.COMMIT=${GIT_COMMIT} -X go-iot/pkg/option.REPO=$REPO -X go-iot/pkg/option.BUILD_TIME=$(date "+%Y-%m-%d_%H:%M:%S")"
# echo $GO_LD_FLAGS
BUILD_FILE_NAME="go-iot"
if [[ "$OS" == Windows* ]];then
if [[ "$1" == linux || "$2" == linux ]];then
echo "cross build linux"
echo CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -trimpath -ldflags \"${GO_LD_FLAGS}\" -o go-iot main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -trimpath -ldflags "${GO_LD_FLAGS}" -o go-iot main.go
elif [[ "$1" == mac || "$2" == mac ]];then
echo CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -trimpath -ldflags "${GO_LD_FLAGS}" -o go-iot-mac main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -trimpath -ldflags "${GO_LD_FLAGS}" -o go-iot-mac main.go
elif [[ "$1" == macm || "$2" == macm ]];then
echo CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -v -trimpath -ldflags "${GO_LD_FLAGS}" -o go-iot-mac_arm main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -v -trimpath -ldflags "${GO_LD_FLAGS}" -o go-iot-mac_arm main.go
else
echo go build -v -trimpath -ldflags \"${GO_LD_FLAGS}\" -o go-iot.exe main.go
go build -v -trimpath -ldflags "${GO_LD_FLAGS}" -o go-iot.exe main.go
BUILD_FILE_NAME="go-iot.exe"
fi
else
echo go build -v -trimpath -ldflags \"${GO_LD_FLAGS}\" -o go-iot main.go
go build -v -trimpath -ldflags "${GO_LD_FLAGS}" -o go-iot main.go
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/anviod/go-iot.git
git@gitee.com:anviod/go-iot.git
anviod
go-iot
go-iot
master

搜索帮助