1 Star 0 Fork 250

笨笨陈/moredoc

forked from mnt.ltd/moredoc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Makefile 2.69 KB
一键复制 编辑 原始数据 按行查看 历史
进击的皇虫 提交于 2023-03-14 15:32 . API文档
GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
GITHASH=$(shell git rev-parse HEAD 2>/dev/null)
BUILDAT=$(shell date +%FT%T%z)
API_PROTO_FILES=$(shell find api/* -name *.proto)
LDFLAGS="-s -w -X moredoc/cmd.GitHash=${GITHASH} -X moredoc/cmd.BuildAt=${BUILDAT} -X moredoc/cmd.Version=${VERSION}"
.PHONY: init
# init env
init:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@latest
go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest
go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
.PHONY: api
# generate api proto
api:
protoc --proto_path=. \
--proto_path=./third_party \
--proto_path=./api \
--gogofaster_out="plugins=grpc,paths=source_relative:." \
--grpc-gateway_out="paths=source_relative:." \
$(API_PROTO_FILES)
doc:
for file in $(API_PROTO_FILES); do \
protoc --proto_path=. \
--proto_path=./third_party \
--proto_path=./api \
--doc_out=docs/api \
--doc_opt=markdown,`basename $$file .proto`.md \
--openapi_out==paths=source_relative:docs \
$$file; \
done
# 整合到单文件
protoc --proto_path=. \
--proto_path=./third_party \
--proto_path=./api \
--doc_out=docs/api \
--doc_opt=markdown,apis.md \
--openapi_out==paths=source_relative:docs \
$(API_PROTO_FILES)
.PHONY: clean-api-go
# clean api go file
clean-api-go:
rm -rf api/*/*.go
builddarwin:
GOOS=darwin GOARCH=amd64 go build -v -o release/${VERSION}/darwin/moredoc -ldflags ${LDFLAGS}
cp -r dist release/${VERSION}/darwin
cp -r dictionary release/${VERSION}/darwin
cp -r app.example.toml release/${VERSION}/darwin
buildlinux:
GOOS=linux GOARCH=amd64 go build -v -o release/${VERSION}/linux/moredoc -ldflags ${LDFLAGS}
cp -r dist release/${VERSION}/linux
cp -r dictionary release/${VERSION}/linux
cp -r app.example.toml release/${VERSION}/linux
buildwin:
GOOS=windows GOARCH=amd64 go build -v -o release/${VERSION}/windows/moredoc.exe -ldflags ${LDFLAGS}
cp -r dist release/${VERSION}/windows
cp -r dictionary release/${VERSION}/windows
cp -r app.example.toml release/${VERSION}/windows
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/c_3into1_chenrx/moredoc.git
git@gitee.com:c_3into1_chenrx/moredoc.git
c_3into1_chenrx
moredoc
moredoc
master

搜索帮助