modify scripts

This commit is contained in:
2025-03-14 15:27:03 +08:00
parent 089cb11f8c
commit a3dadecfc8
23 changed files with 110 additions and 369 deletions

48
Makefile Normal file
View File

@ -0,0 +1,48 @@
# 设置变量
PROJECT_NAME := aigrammar
SRC_DIR := src
BIN_DIR := bin
CONF_DIR := conf
OUTPUT := $(BIN_DIR)/$(PROJECT_NAME)
# Go 编译参数
GO := go
GOFLAGS := -mod=readonly
GOFILES := $(shell find $(SRC_DIR) -name '*.go')
# 默认目标: 构建可执行文件
all: build
# 编译代码
build: $(GOFILES)
@mkdir -p $(BIN_DIR)
$(GO) build -o $(OUTPUT) ./$(SRC_DIR)/...
@echo "✅ Build complete: $(OUTPUT)"
# 运行程序
run: build
$(OUTPUT) --config=$(CONF_DIR)/config.toml
# 清理编译生成的二进制文件
clean:
rm -rf $(BIN_DIR)
@echo "🗑 Cleaned up $(BIN_DIR)"
# 格式化 Go 代码
fmt:
$(GO) fmt ./$(SRC_DIR)/...
# 整理 go.mod清理无用依赖
tidy:
$(GO) mod tidy
# 显示帮助信息
help:
@echo "Usage: make [target]"
@echo "Targets:"
@echo " all - 编译 (默认目标)"
@echo " build - 编译 Go 代码"
@echo " run - 运行编译后的程序"
@echo " clean - 删除 bin 目录"
@echo " fmt - 格式化 Go 代码"
@echo " tidy - 整理 go.mod 依赖"