lsxd coupon
This commit is contained in:
parent
212482bb88
commit
8c42dc8ec5
43
Makefile
43
Makefile
|
|
@ -1,61 +1,29 @@
|
|||
# 强制指定 Go 版本(需与主程序编译环境一致)
|
||||
REQUIRED_GO_VERSION := 1.23.6
|
||||
# 目标平台配置(根据运行环境调整,如 arm64)
|
||||
TARGET_GOOS := linux
|
||||
TARGET_GOARCH := amd64
|
||||
# 交叉编译工具链(Mac 编译 Linux amd64 必需)
|
||||
TARGET_CC := x86_64-linux-musl-gcc
|
||||
|
||||
build-linux1:
|
||||
build-linux:
|
||||
@echo "===== 开始编译 Linux 插件 ====="
|
||||
@echo "要求 Go 版本: $(REQUIRED_GO_VERSION)"
|
||||
@echo "目标平台: $(TARGET_GOOS)/$(TARGET_GOARCH)"
|
||||
|
||||
# 1. 检查 Go 版本
|
||||
@go version | grep -q $(REQUIRED_GO_VERSION) || ( \
|
||||
echo "错误:需要 Go $(REQUIRED_GO_VERSION),当前版本:$(shell go version)"; \
|
||||
exit 1 \
|
||||
)
|
||||
|
||||
# 2. 检查插件目录
|
||||
@[ -d "plugins/${name}" ] || ( \
|
||||
echo "错误:插件目录 plugins/${name} 不存在"; \
|
||||
exit 1 \
|
||||
)
|
||||
|
||||
# 3. 核心:所有命令写在同一行,确保环境变量作用域生效
|
||||
# 注意:&& 连接,且环境变量紧跟 cd 后,与 go build 同进程
|
||||
cd plugins/${name} && \
|
||||
CGO_ENABLED=1 \
|
||||
CC=$(TARGET_CC) \
|
||||
GOOS=$(TARGET_GOOS) \
|
||||
GOARCH=$(TARGET_GOARCH) \
|
||||
GOPROXY=https://goproxy.cn,direct \
|
||||
go build -buildmode=plugin -trimpath -o ../../pkg/linux/${name}.so .
|
||||
|
||||
# 4. 验证编译结果
|
||||
@echo "===== 编译完成 ====="
|
||||
@echo "插件路径: pkg/linux/${name}.so"
|
||||
@echo "插件格式检测:"
|
||||
@file pkg/linux/${name}.so
|
||||
|
||||
build-linux:
|
||||
cd plugins; \
|
||||
export GOOS=linux; \
|
||||
export GOARCH=amd64; \
|
||||
export CGO_ENABLED=0; \
|
||||
export GOPROXY=https://goproxy.cn,direct; \
|
||||
cd ${name} && go build -o ../../pkg/linux/${name}.so .
|
||||
@echo "===== 编译完成 ====="
|
||||
|
||||
build-mac:
|
||||
@echo "===== 开始编译 mac 插件 ====="
|
||||
cd plugins; \
|
||||
export GOOS=darwin; \
|
||||
export GO111MODULE=on; \
|
||||
export CGO_ENABLED=0; \
|
||||
export GOPROXY=https://goproxy.cn,direct; \
|
||||
cd ${name} && go build -o ../../pkg/mac/${name}.so .
|
||||
@echo "===== 编译完成 ====="
|
||||
|
||||
build-win:
|
||||
@echo "===== 开始编译 win 插件 ====="
|
||||
cd plugins; \
|
||||
export GOOS=windows; \
|
||||
export GOARCH=amd64; \
|
||||
|
|
@ -63,6 +31,7 @@ build-win:
|
|||
export CGO_ENABLED=0; \
|
||||
export GOPROXY=https://goproxy.cn,direct; \
|
||||
cd ${name} && go build -o ../../pkg/win/${name}.so .
|
||||
@echo "===== 编译完成 ====="
|
||||
|
||||
.PHONY: zltx_v1
|
||||
zltx_v1:
|
||||
|
|
|
|||
Loading…
Reference in New Issue