(tools) feat: Add ProtoBuf C# code generator
This commit is contained in:
BIN
Tools/ProtoBuf/bin/grpc_csharp_plugin.exe
Normal file
BIN
Tools/ProtoBuf/bin/grpc_csharp_plugin.exe
Normal file
Binary file not shown.
43
Tools/ProtoBuf/gen.py
Normal file
43
Tools/ProtoBuf/gen.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
from subprocess import Popen
|
||||||
|
from os import path
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
protoc_dir = "./bin/protoc.exe"
|
||||||
|
grpc_cs_plugin_dir = "./bin/grpc_csharp_plugin.exe"
|
||||||
|
|
||||||
|
proto_dir = "./proto"
|
||||||
|
message_dir = proto_dir + "/message.proto"
|
||||||
|
|
||||||
|
gen_dir = "./gen"
|
||||||
|
gen_code_dst_dir = "../../Client/Assets/Scripts/Protocol"
|
||||||
|
|
||||||
|
|
||||||
|
def GenerateProtocol():
|
||||||
|
if not path.exists(gen_dir):
|
||||||
|
os.makedirs(gen_dir)
|
||||||
|
|
||||||
|
result = Popen(
|
||||||
|
[
|
||||||
|
protoc_dir,
|
||||||
|
f"--proto_path={proto_dir}",
|
||||||
|
f"--csharp_out={gen_dir}",
|
||||||
|
f"--grpc_out={gen_dir}",
|
||||||
|
f"--plugin=protoc-gen-grpc={grpc_cs_plugin_dir}",
|
||||||
|
message_dir,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
result.wait()
|
||||||
|
|
||||||
|
|
||||||
|
def MoveGeneratedCode():
|
||||||
|
shutil.copytree(
|
||||||
|
gen_dir, gen_code_dst_dir, copy_function=shutil.move, dirs_exist_ok=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
GenerateProtocol()
|
||||||
|
MoveGeneratedCode()
|
Reference in New Issue
Block a user