bdledger-apis/grpc/scripts/gen.bat

47 lines
1.7 KiB
Batchfile
Raw Normal View History

2020-04-07 13:28:09 +00:00
@echo off
setlocal EnableDelayedExpansion
cd /d "%~dp0..\pb"
where /q protoc || echo Missing protoc && exit /b
set gen=..\gen
set pbs=bdware/bdledger/api/*.proto
for %%A in (%*) do (
if "%%A"=="go" (
set plugin=protoc-gen-go
where /q !plugin! || echo Missing !plugin! && exit /b
set out=%gen%\go
if not exist !out! mkdir !out!
echo Generating Go code
start /b protoc --go_out=plugins=grpc:!out! %pbs%
)
if "%%A"=="nodejs" (
set plugin=grpc_tools_node_protoc_plugin
where /q !plugin! || echo missing !plugin! && exit /b
for /f %%i in ('where !plugin!') do set pluginPath=%%i
set out=%gen%\nodejs
if not exist !out! mkdir !out!
echo Generating Node.js code
start /b protoc --js_out=import_style=commonjs,binary:!out! --grpc_out=!out! --plugin=protoc-gen-grpc=!pluginPath! %pbs% google/protobuf/empty.proto
)
if "%%A"=="ts" (
set plugin=protoc-gen-ts
where /q !plugin! || echo missing !plugin! && exit /B
for /f %%i in ('where !plugin!') do set pluginPath=%%i
set out=%gen%\nodejs
if not exist !out! mkdir !out!
echo Generating TypeScript definitions
start /b protoc --ts_out=!out! --plugin=protoc-gen-ts=!pluginPath! %pbs% google/protobuf/empty.proto
)
if "%%A"=="docs" (
set plugin=protoc-gen-ts
where /q !plugin! || echo missing !plugin! && exit /B
set out=..\..\docs
if not exist !out! mkdir !out!
echo Generating documentation
start /b protoc --doc_out=!out! --doc_opt=html,apis.html %pbs% google/protobuf/empty.proto
start /b protoc --doc_out=!out! --doc_opt=markdown,apis.md %pbs% google/protobuf/empty.proto
start /b protoc --doc_out=!out! --doc_opt=json,apis.json %pbs% google/protobuf/empty.proto
)
)