44 lines
895 B
Python
44 lines
895 B
Python
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()
|