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
|
2020-04-07 16:49:17 +00:00
|
|
|
set exec=protoc
|
2020-04-07 13:28:09 +00:00
|
|
|
|
|
|
|
for %%A in (%*) do (
|
2020-04-07 16:49:17 +00:00
|
|
|
if "%%A"=="-a" set exec=start /b protoc
|
|
|
|
if "%%A"=="--async" set exec=start /b protoc
|
2020-04-07 13:28:09 +00:00
|
|
|
if "%%A"=="go" (
|
|
|
|
set plugin=protoc-gen-go
|
|
|
|
where /q !plugin! || echo Missing !plugin! && exit /b
|
2020-06-16 07:12:53 +00:00
|
|
|
set vplugin=protoc-gen-govalidators
|
|
|
|
where /q !vplugin! || echo Missing !vplugin! && exit /b
|
2020-04-07 13:28:09 +00:00
|
|
|
set out=%gen%\go
|
|
|
|
if not exist !out! mkdir !out!
|
|
|
|
echo Generating Go code
|
2020-09-22 08:21:24 +00:00
|
|
|
!exec! --go-grpc_out=!out! --govalidators_out=!out! %pbs%
|
2020-04-07 13:28:09 +00:00
|
|
|
)
|
2020-06-08 09:24:03 +00:00
|
|
|
if "%%A"=="gohttp" (
|
|
|
|
set plugin=protoc-gen-grpc-gateway
|
|
|
|
where /q !plugin! || echo Missing !plugin! && exit /b
|
|
|
|
set out=%gen%\go
|
|
|
|
if not exist !out! mkdir !out!
|
|
|
|
echo Generating Go HTTP code
|
|
|
|
!exec! --grpc-gateway_out=grpc_api_configuration=bdware/bdledger/api/grpc-gateway.yml,logtostderr=true:!out! %pbs%
|
|
|
|
)
|
2020-04-07 13:28:09 +00:00
|
|
|
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
|
2020-04-07 16:49:17 +00:00
|
|
|
!exec! --js_out=import_style=commonjs,binary:!out! --grpc_out=!out! --plugin=protoc-gen-grpc=!pluginPath! %pbs% google/protobuf/empty.proto
|
2020-04-07 13:28:09 +00:00
|
|
|
)
|
|
|
|
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
|
2020-04-07 16:49:17 +00:00
|
|
|
!exec! --ts_out=!out! --plugin=protoc-gen-ts=!pluginPath! %pbs% google/protobuf/empty.proto
|
2020-04-07 13:28:09 +00:00
|
|
|
)
|
|
|
|
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
|
2020-04-07 16:49:17 +00:00
|
|
|
!exec! --doc_out=!out! --doc_opt=html,apis.html %pbs% google/protobuf/empty.proto
|
2020-04-07 13:28:09 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
)
|