-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.bat
More file actions
42 lines (35 loc) · 1.45 KB
/
generate.bat
File metadata and controls
42 lines (35 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
cd /d %~dp0
set PROTOC_VERSION=29.4
set PROTO_WAVES_VERSION=1.5.2
set PROTOC_URL=https://github.com/protocolbuffers/protobuf/releases/download/v%PROTOC_VERSION%/
set PROTOC_ARCH=protoc-%PROTOC_VERSION%-win32.zip
set PROTO_WAVES_URL=https://github.com/wavesplatform/protobuf-schemas/archive/
set PROTO_WAVES_ARCH=v%PROTO_WAVES_VERSION%.zip
set PROTO_OUT=out
set PROTO_TEMP=protobuf-%random%%random%
set PROTO_FINAL=waves
mkdir %PROTO_TEMP%
cd %PROTO_TEMP%
curl -fsSL -o %PROTOC_ARCH% %PROTOC_URL%%PROTOC_ARCH%
7z x %PROTOC_ARCH% -aoa
curl -fsSL -o %PROTO_WAVES_ARCH% %PROTO_WAVES_URL%%PROTO_WAVES_ARCH%
7z x %PROTO_WAVES_ARCH% -aoa
mkdir %PROTO_OUT%
FOR /R "protobuf-schemas-%PROTO_WAVES_VERSION%\proto\%PROTO_FINAL%" %%f IN (*.proto) DO (
bin\protoc --proto_path="%CD%\protobuf-schemas-%PROTO_WAVES_VERSION%\proto" --python_out=%PROTO_OUT% "%%f"
)
rmdir /s /q %PROTO_FINAL%
xcopy /s /y %PROTO_OUT%\%PROTO_FINAL% ..\%PROTO_FINAL%\
type nul > ..\%PROTO_FINAL%\__init__.py
cd ..
for /f %%n in ('dir /b /s "%PROTO_TEMP%\protobuf-schemas-%PROTO_WAVES_VERSION%\proto\%PROTO_FINAL%\*.proto" ^| find /c /v ""') do set PROTO_COUNT=%%n
for /f %%n in ('dir /b /s "%PROTO_FINAL%\*_pb2.py" ^| find /c /v ""') do set PY_COUNT=%%n
if NOT "%PROTO_COUNT%"=="%PY_COUNT%" (
echo Error: Expected %PROTO_COUNT% compiled python files, but found %PY_COUNT%.
pause
exit /B 1
)
echo Success: All %PROTO_COUNT% protobuf files compiled successfully
timeout 10
rmdir /s /q %PROTO_TEMP%
pause