bdledger-apis/scripts/gen.bat

38 lines
1.3 KiB
Batchfile

@echo off
setlocal EnableDelayedExpansion
cd /d "%~dp0.."
where /q protoc || echo Missing protoc && exit /b
set gen=.\gen
set pkg=bdware/bdledger/api
set protos=%pkg%/common.proto %pkg%/error_details.proto %pkg%/node.proto %pkg%/ledger.proto %pkg%/query.proto %pkg%/contract.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! %protos%
)
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:!nout! --grpc_out=!nout! --plugin=protoc-gen-grpc=!pluginPath! %protos%
)
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! %protos%
)
)