This commit is contained in:
xxjwxc
2023-10-27 17:40:04 +08:00
parent 92d3fe0f34
commit 7164e74b59
2 changed files with 52 additions and 28 deletions

View File

@@ -6,6 +6,7 @@ source_install:
clear: # 删除proto文件夹下所有go文件谨慎操作
rm -rf ./prc/**/*.go
new: #make new service=example
ifeq ($(OS),Windows_NT) # windows
echo start install $(service)
@# 开始替换文件
@test -d $(service) || cp -r ./example/ ./$(service)/
@@ -17,4 +18,19 @@ new: #make new service=example
@# 开始更新apidoc
@test -d ./apidoc/proto/$(service)/ || cp -r ./apidoc/proto/example/ ./apidoc/proto/$(service)/
@sed -i 's#example#$(service)#g' ./apidoc/proto/$(service)/*.proto
@echo service $(service) success
@echo service $(service) success
else
echo start install $(service)
@# 开始替换文件
@test -d $(service) || cp -r ./example/ ./$(service)/
find ./$(service)/ -type f -name "*.go" | xargs sed -i '' 's#example#$(service)#g'
@sed -i '' 's#example#$(service)#g' ./$(service)/go.mod
@sed -i '' 's#example#$(service)#g' ./$(service)/Makefile
@sed -i '' 's#example#$(service)#g' ./$(service)/generate/proto_makefile
@sed -i '' 's#example#$(service)#g' ./$(service)/conf/config.yml
@# 开始更新apidoc
@test -d ./apidoc/proto/$(service)/ || cp -r ./apidoc/proto/example/ ./apidoc/proto/$(service)/
@sed -i '' 's#example#$(service)#g' ./apidoc/proto/$(service)/*.proto
@echo service $(service) success
endif

View File

@@ -8,33 +8,41 @@ COMMSHELLFILE :=`ls $(APIDOCDIR)/proto/common/*.proto | cut -d'/' -f5`
gen_proto: gen_build gen_base
clean_proto:
rm -f rpc/common/*.pb.go
rm -f rpc/common/*.pb.go
gen_build:# 自定义注册
@mkdir -p rpc/$(NAME)
@echo "gen_build proto"
@rm -f rpc/$(NAME)/*.pb.go
@rm -f rpc/$(NAME)/*.pb.gmsec.go
@for file in $(BUILDSHELLFILE); do \
echo build $$file; \
protoc --proto_path="$(APIDOCDIR)/proto/" --gmsec_out=plugins=gmsec:./ $(NAME)/$$file; \
done;
@sed -i 's/,omitempty//g' ./rpc/$(NAME)/*.pb.go #开始取消json omitempty
cp -rf ./rpc/$(NAME)/ $(RPCCDIR)/ #子目录向父目录拷贝
#@sed -i 's#common "rpc/common"#common "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.go #开始替换common包
#@sed -i 's#common "rpc/common"#common "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.gmsec.go #开始替换common包
#@sed -i 's#_ "rpc/common"#_ "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.go #开始替换common包
#@sed -i 's#_ "rpc/common"#_ "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.gmsec.go #开始替换common包
@mkdir -p rpc/$(NAME)
@echo "gen_build proto"
@rm -f rpc/$(NAME)/*.pb.go
@rm -f rpc/$(NAME)/*.pb.gmsec.go
@for file in $(BUILDSHELLFILE); do \
echo build $$file; \
protoc --proto_path="$(APIDOCDIR)/proto/" --gmsec_out=plugins=gmsec:./ $(NAME)/$$file; \
done;
ifeq ($(OS),Windows_NT) # windows
@sed -i 's/,omitempty//g' ./rpc/$(NAME)/*.pb.go #开始取消json omitempty
cp -rf ./rpc/$(NAME)/ $(RPCCDIR)/ #子目录向父目录拷贝
else
@sed -i '' 's/,omitempty//g' ./rpc/$(NAME)/*.pb.go #开始取消json omitempty
cp -rf ./rpc/$(NAME)/ $(RPCCDIR)/$(NAME)/ #子目录向父目录拷贝
endif
#@sed -i 's#common "rpc/common"#common "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.go #开始替换common包
#@sed -i 's#common "rpc/common"#common "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.gmsec.go #开始替换common包
#@sed -i 's#_ "rpc/common"#_ "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.go #开始替换common包
#@sed -i 's#_ "rpc/common"#_ "$(NAME)/rpc/common"#g' ./rpc/$(NAME)/*.pb.gmsec.go #开始替换common包
gen_base:# 基础库
@mkdir -p $(RPCCDIR)/common
@echo "gen proto"
@rm -f rpc/common/*.pb.go
@rm -f rpc/common/*.pb.gmsec.go
@for file in $(COMMSHELLFILE); do \
echo base $$file; \
protoc --proto_path="$(APIDOCDIR)/proto/" --gmsec_out=plugins=gmsec:$(APIDOCDIR)/ common/$$file; \
done;
@sed -i 's/,omitempty//g' $(RPCCDIR)/common/*.pb.go #开始取消json omitempty
#cp -rf $(RPCCDIR)/common/ ./rpc/ #父目录向当前目录拷贝
@mkdir -p $(RPCCDIR)/common
@echo "gen proto"
@rm -f rpc/common/*.pb.go
@rm -f rpc/common/*.pb.gmsec.go
@for file in $(COMMSHELLFILE); do \
echo base $$file; \
protoc --proto_path="$(APIDOCDIR)/proto/" --gmsec_out=plugins=gmsec:$(APIDOCDIR)/ common/$$file; \
done;
ifeq ($(OS),Windows_NT) # windows
@sed -i 's/,omitempty//g' $(RPCCDIR)/common/*.pb.go #开始取消json omitempty
else
@sed -i '' 's/,omitempty//g' $(RPCCDIR)/common/*.pb.go #开始取消json omitempty
endif
#cp -rf $(RPCCDIR)/common/ ./rpc/ #父目录向当前目录拷贝