-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.bat
42 lines (35 loc) · 1.1 KB
/
compile.bat
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
rem Checkout pip requirements
python -m venv venv
.\venv\Scripts\pip install -r requirements.txt
setlocal EnableDelayedExpansion
rem Remove the 'stubs' directory if it exists, and create a new one
if exist api (
rd /s /q api
)
mkdir api
rem Base directory to start the search
set baseDir=src\main\proto
rem Find all .proto files in the specified directory and subdirectories
set "protoFiles="
for /r %baseDir% %%f in (*.proto) do (
rem Get the relative path from the base directory
set "relativePath=%%f"
set "relativePath=!relativePath:%CD%\=!"
set "protoFiles=!protoFiles! !relativePath!"
)
rem Run the grpc_tools.protoc command
.\venv\Scripts\python -m grpc_tools.protoc ^
--python_out=api ^
--grpc_python_out=api ^
--proto_path=%baseDir% ^
--plugin=protoc-gen-mypy=.\venv\Scripts\protoc-gen-mypy ^
--mypy_out=api ^
--experimental_allow_proto3_optional ^
!protoFiles!
rem Invoke protol to fix broken imports
.\venv\Scripts\protol ^
--create-package ^
--in-place ^
--python-out api ^
protoc --proto-path=%baseDir% !protoFiles! --experimental_allow_proto3_optional
endlocal