From 2c7e72c5f879a09938de5b2faa6373842cd3c5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E6=8A=98=E8=85=BE=E7=9A=84=E5=B0=8F=E7=A0=81?= =?UTF-8?q?=E5=86=9C?= <747357766@qq.com> Date: Fri, 21 Mar 2025 15:43:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0make=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..df50143 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +# 获取所有的 .proto 文件 +PROTO_FILES := $(wildcard *.proto) + +# 定义生成目标 +all: $(PROTO_FILES) + @for file in $(PROTO_FILES); do \ + package_name=$$(grep -oP 'package \K\w+' $$file); \ + mkdir -p $$package_name; \ + protoc --proto_path=. --go_out=$$package_name --go_opt=paths=source_relative --go-grpc_out=$$package_name --go-grpc_opt=paths=source_relative $$file; \ + done + +# 清理生成的文件和文件夹 +clean: + @for file in $(PROTO_FILES); do \ + package_name=$$(grep -oP 'package \K\w+' $$file); \ + rm -rf $$package_name; \ + done +