From 725d70ebaba30c20124075cf5e4bd751d2404d28 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 7 Mar 2022 14:41:57 +0800 Subject: [PATCH] 1 --- scripts/construct/build_pb.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/construct/build_pb.py b/scripts/construct/build_pb.py index 0fcb4d9..23b65d1 100644 --- a/scripts/construct/build_pb.py +++ b/scripts/construct/build_pb.py @@ -30,6 +30,24 @@ def printp_stderr(p): except Exception as e: print('build_pb stderr error:' + e) +def rebuild_impb(): + pb_files = ['im_proto', 'im_msgid'] + cpp_out = '../../third_party/framework/cpp/' + for proto_name in pb_files: + pb_file = proto_name + pb_dir = '../../third_party/framework/cpp/' + if not os.path.isfile(pb_dir + proto_name + '.pb.cc'): + cmd = 'protoc --proto_path=../../third_party/framework/cpp --cpp_out=%s ../../third_party/framework/cpp/%s.proto ' % (cpp_out, pb_file) + print(cmd) + os.system(cmd) + continue + s1 = os.stat(pb_dir + proto_name + '.pb.cc') + s2 = os.stat(pb_dir + proto_name + '.proto') + if s1.st_size <= 0 or s1.st_mtime < s2.st_mtime: + cmd = 'protoc --proto_path=../../third_party/framework/cpp --cpp_out=%s ../../third_party/framework/cpp/%s.proto ' % (cpp_out, pb_file) + print(cmd ) + os.system(cmd) + def need_rebuild(pb_files): for proto_name in pb_files: if not os.path.isfile(proto_name + '.pb.cc'): @@ -115,6 +133,7 @@ parser.add_option( if not options.nohooks: repair_githooks() +rebuild_impb() if need_rebuild(options.pb_files.split(',')): rebuild(options.cpp_out, options.python_out, options.java_out, options.pb_files.split(',')) else: