Skip to content

Instantly share code, notes, and snippets.

@navono navono/protoc.sh
Last active Jun 13, 2019

Embed
What would you like to do?
proto shell 编译脚本
#! /bin/bash
# test.sh
PROTOC_GEN_TS_PATH=$(pwd)/node_modules/.bin/protoc-gen-ts.cmd
# Directory to write generated code to
OUT_DIR="./generated"
JS_DIR=$OUT_DIR/js
GO_DIR=$OUT_DIR/go
SWAGGER_DIR=$OUT_DIR/swagger
mkdir -p $JS_DIR
mkdir -p $GO_DIR
mkdir -p $SWAGGER_DIR
function compile {
for file in $1/*
do
if [ -d "$file" ]; then
compile $file
else
##check for the file
ext="${file##*.}"
if [[ -f "$file" ]] && [[ "$ext" = "proto" ]] ; then
protoc -I. -Ithird_party \
--js_out=import_style=commonjs,binary:$JS_DIR \
--ts_out=service=true:$JS_DIR \
--go_out=plugins=grpc:$GO_DIR \
--grpc-gateway_out=logtostderr=true:$GO_DIR \
--swagger_out=logtostderr=true:$SWAGGER_DIR \
--lint_out=. $file
fi
fi
done
}
echo "proto files compiling..."
# 运行需要编译的 proto 目录
compile ./are
@navono

This comment has been minimized.

Copy link
Owner Author

navono commented Jun 13, 2019

Windows 运行 Docker:

docker run --rm -v %cd%:/data -w /data navono007/proto-compiler /bin/bash ./protoc.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.