File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,11 @@ run: tidy format dev
3737
3838.PHONY : build
3939build : tidy # 编译源码,依赖 tidy 目标自动添加/移除依赖包.
40- @go build -v -ldflags " $( GO_LDFLAGS) " -o $(OUTPUT_DIR ) /$(PROJECT_NAME ) $(ROOT_DIR ) /$(PROJECT_NAME ) .go
40+ @CGO_ENABLED=0 go build -v -ldflags " $( GO_LDFLAGS) " -o $(OUTPUT_DIR ) /$(PROJECT_NAME ) $(ROOT_DIR ) /$(PROJECT_NAME ) .go
41+
42+ .PHONY : build-linux
43+ build-linux : tidy # 编译 Linux/Debian 版本(静态链接,无 CGO 依赖).
44+ @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -installsuffix cgo -ldflags " $( GO_LDFLAGS) " -o $(OUTPUT_DIR ) /$(PROJECT_NAME ) -linux-amd64 $(ROOT_DIR ) /$(PROJECT_NAME ) .go
4145
4246.PHONY : format
4347format : # 格式化 Go 源码.
@@ -139,7 +143,8 @@ swagger-clean: # 清理 Swagger 文档
139143help : # 显示帮助信息
140144 @echo " Available targets:"
141145 @echo " all - 构建项目 (默认)"
142- @echo " build - 编译源码"
146+ @echo " build - 编译源码(当前平台)"
147+ @echo " build-linux - 编译 Linux/Debian 版本(静态链接)"
143148 @echo " run - 开发运行"
144149 @echo " dev - 开发运行"
145150 @echo " test - 运行测试"
You can’t perform that action at this time.
0 commit comments