proto generation updates (#4653)

This commit is contained in:
Jesse Hills 2023-06-12 17:00:34 +12:00 committed by GitHub
parent 0a407c5425
commit f7c0ec6595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

18
.vscode/tasks.json vendored
View file

@ -36,6 +36,24 @@
] ]
} }
] ]
},
{
"label": "Generate proto files",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": [
"./script/api_protobuf/api_protobuf.py"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "never",
"close": true,
"panel": "new"
},
"problemMatcher": []
} }
] ]
} }

View file

@ -11,3 +11,5 @@ pytest-mock==3.10.0
pytest-asyncio==0.21.0 pytest-asyncio==0.21.0
asyncmock==0.4.2 asyncmock==0.4.2
hypothesis==5.49.0 hypothesis==5.49.0
clang-format==13.0.1 ; platform_machine != 'armv7l'

View file

@ -18,6 +18,7 @@ will be generated, they still need to be formatted
""" """
import re import re
import os
from pathlib import Path from pathlib import Path
from textwrap import dedent from textwrap import dedent
from subprocess import call from subprocess import call
@ -944,3 +945,19 @@ with open(root / "api_pb2_service.cpp", "w") as f:
f.write(cpp) f.write(cpp)
prot.unlink() prot.unlink()
try:
import clang_format
def exec_clang_format(path):
clang_format_path = os.path.join(
os.path.dirname(clang_format.__file__), "data", "bin", "clang-format"
)
call([clang_format_path, "-i", path])
exec_clang_format(root / "api_pb2_service.h")
exec_clang_format(root / "api_pb2_service.cpp")
exec_clang_format(root / "api_pb2.h")
exec_clang_format(root / "api_pb2.cpp")
except ImportError:
pass