build: 添加 Makefile 用于构建管理

添加 Makefile 文件,包含构建、清理、测试和多平台构建功能,简化开发流程
This commit is contained in:
kingecg 2025-07-03 11:28:39 +08:00
parent 61d8c20d09
commit bb031c55b2
1 changed files with 28 additions and 0 deletions

28
Makefile Normal file
View File

@ -0,0 +1,28 @@
.PHONY: clean test build build-all
# 构建目标
BINARY := gofirewall
# 默认构建
build:
@echo "Building for current platform..."
go build -o $(BINARY)
# 清理构建产物
clean:
@echo "Cleaning build artifacts..."
@rm -f $(BINARY) $(BINARY)-*
# 运行测试
test:
@echo "Running tests..."
go test ./...
# 多平台构建
build-all: clean test
@echo "Building for all platforms..."
GOOS=linux GOARCH=amd64 go build -o $(BINARY)-linux-amd64
GOOS=linux GOARCH=arm64 go build -o $(BINARY)-linux-arm64
GOOS=windows GOARCH=amd64 go build -o $(BINARY)-windows-amd64.exe
GOOS=darwin GOARCH=amd64 go build -o $(BINARY)-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o $(BINARY)-darwin-arm64