39 lines
730 B
Python
39 lines
730 B
Python
import subprocess
|
|
import os
|
|
import shutil
|
|
|
|
|
|
protoc_dir = "./bin/protoc.exe"
|
|
|
|
proto_dir = "./proto"
|
|
message_dir = f"{proto_dir}/message.proto"
|
|
|
|
gen_dir = "./gen"
|
|
gen_code_dst_dir = "../../Client/Assets/Scripts/Protocol"
|
|
|
|
|
|
def GenerateProtocol():
|
|
if not os.path.exists(gen_dir):
|
|
os.makedirs(gen_dir)
|
|
|
|
gen_code = subprocess.Popen(
|
|
[
|
|
protoc_dir,
|
|
f"--proto_path={proto_dir}",
|
|
f"--csharp_out={gen_dir}",
|
|
message_dir,
|
|
]
|
|
)
|
|
gen_code.wait()
|
|
|
|
|
|
def MoveGeneratedCode():
|
|
shutil.copytree(
|
|
gen_dir, gen_code_dst_dir, copy_function=shutil.move, dirs_exist_ok=True
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
GenerateProtocol()
|
|
MoveGeneratedCode()
|