diff --git a/Tools/ProtoBuf/GenerateProtocol.ps1 b/Tools/ProtoBuf/GenerateProtocol.ps1 deleted file mode 100644 index e69de29..0000000 diff --git a/Tools/ProtoBuf/bin/grpc_csharp_plugin.exe b/Tools/ProtoBuf/bin/grpc_csharp_plugin.exe new file mode 100644 index 0000000..0f3fd1c Binary files /dev/null and b/Tools/ProtoBuf/bin/grpc_csharp_plugin.exe differ diff --git a/Tools/ProtoBuf/gen.py b/Tools/ProtoBuf/gen.py new file mode 100644 index 0000000..837d09f --- /dev/null +++ b/Tools/ProtoBuf/gen.py @@ -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()