diff options
author | snermolaev <[email protected]> | 2024-08-05 07:26:47 +0300 |
---|---|---|
committer | snermolaev <[email protected]> | 2024-08-05 07:36:44 +0300 |
commit | feaa798c9e6b0df5535f86d2ccc7c9f8d007ceda (patch) | |
tree | 360cfa115fe63a1567a4209a019e2bb561a2bb07 /build/scripts/collect_rawproto.py | |
parent | bce53150cdcc96594c071350dc134be6f81c22eb (diff) |
collect .proto files by PROTO_DESCRIPTIONS
1b642fbbf446d68522225c9794b993dc4ba3760e
Diffstat (limited to 'build/scripts/collect_rawproto.py')
-rw-r--r-- | build/scripts/collect_rawproto.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/build/scripts/collect_rawproto.py b/build/scripts/collect_rawproto.py new file mode 100644 index 00000000000..92086b4f773 --- /dev/null +++ b/build/scripts/collect_rawproto.py @@ -0,0 +1,37 @@ +import argparse +import os +import tarfile +import stat +import sys + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--output', required=True) + parser.add_argument('args', nargs='*') + return parser.parse_args() + + +def main(args): + rawprotos = args.args + with tarfile.open(args.output, 'w') as fout: + for rawproto in sorted(os.path.normpath(r).replace('\\', '/') for r in rawprotos): + assert rawproto.endswith('.rawproto') + arcname = os.path.splitext(rawproto[:-len('.rawproto')])[0] + with open(rawproto, 'rb') as fin: + tarinfo = fout.gettarinfo(rawproto, arcname) + tarinfo.mode = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH if tarinfo.mode | stat.S_IXUSR else 0 + tarinfo.mode = ( + tarinfo.mode | stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH + ) + tarinfo.mtime = 0 + tarinfo.uid = 0 + tarinfo.gid = 0 + tarinfo.uname = 'dummy' + tarinfo.gname = 'dummy' + fout.addfile(tarinfo, fin) + return 0 + + +if __name__ == '__main__': + sys.exit(main(parse_args())) |