82 lines
2.1 KiB
Makefile
82 lines
2.1 KiB
Makefile
# Makefile for pig-farm-controller
|
|
|
|
# 默认目标
|
|
.PHONY: help
|
|
help:
|
|
@echo "Usage: make [target]"
|
|
@echo
|
|
@echo "Targets:"
|
|
@echo " run Run the application"
|
|
@echo " build Build the application"
|
|
@echo " clean Clean generated files"
|
|
@echo " test Run all tests"
|
|
@echo " swag Generate swagger docs"
|
|
@echo " help Show this help message"
|
|
@echo " proto Generate protobuf files"
|
|
@echo " lint Lint the code"
|
|
|
|
# 运行应用
|
|
.PHONY: run
|
|
run:
|
|
go run main.go
|
|
|
|
# 构建应用
|
|
.PHONY: build
|
|
build:
|
|
go build -o bin/pig-farm-controller .
|
|
|
|
# 清理生成文件
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f bin/pig-farm-controller
|
|
|
|
# 运行所有测试
|
|
.PHONY: test
|
|
test:
|
|
go test --count=1 ./...
|
|
|
|
# 生成swagger文档
|
|
.PHONY: swag
|
|
swag:
|
|
if exist docs rmdir /s /q docs
|
|
swag init -g internal/app/api/api.go --parseInternal --parseDependency
|
|
|
|
|
|
# 生成protobuf文件
|
|
.PHONY: proto
|
|
proto:
|
|
protoc --go_out=internal/infra/transport/proto --go_opt=paths=source_relative --go-grpc_out=internal/infra/transport/proto --go-grpc_opt=paths=source_relative -Iinternal/infra/transport/proto internal/infra/transport/proto/device.proto
|
|
|
|
# 运行代码检查
|
|
.PHONY: lint
|
|
lint:
|
|
golangci-lint run ./...
|
|
|
|
# 测试模式(改动文件自动重编译重启)
|
|
.PHONY: dev
|
|
dev:
|
|
air
|
|
|
|
# 启用谷歌浏览器MCP服务器
|
|
.PHONY: mcp-chrome
|
|
mcp-chrome:
|
|
node "C:\nvm4w\nodejs\node_modules\chrome-devtools-mcp\build\src\index.js"
|
|
|
|
# 生成文件目录树
|
|
.PHONY: tree
|
|
|
|
# 定义要额外排除的生成代码目录
|
|
EXCLUDE_CONTEXT_PREFIX = internal/infra/transport/lora/chirp_stack_proto/
|
|
# 最终的文件清单会保存在这里
|
|
OUTPUT_FILE = project_structure.txt
|
|
|
|
# 使用 PowerShell 脚本块执行 Git 命令和二次过滤
|
|
tree:
|
|
@powershell -Command "git ls-files --exclude-standard | Select-String -NotMatch '$(EXCLUDE_CONTEXT_PREFIX)' | Out-File -Encoding UTF8 $(OUTPUT_FILE)"
|
|
@powershell -Command "Add-Content -Path $(OUTPUT_FILE) -Value '$(EXCLUDE_CONTEXT_PREFIX)' -Encoding UTF8"
|
|
@echo "The project file list has been generated to project_structure.txt"
|
|
|
|
# 启用gemini-cli
|
|
.PHONY: gemini
|
|
gemini:
|
|
gemini -m "gemini-2.5-flash"
|