aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/cpp_flatc_wrapper.py
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/scripts/cpp_flatc_wrapper.py
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/scripts/cpp_flatc_wrapper.py')
-rw-r--r--build/scripts/cpp_flatc_wrapper.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/build/scripts/cpp_flatc_wrapper.py b/build/scripts/cpp_flatc_wrapper.py
new file mode 100644
index 0000000000..78a20e0280
--- /dev/null
+++ b/build/scripts/cpp_flatc_wrapper.py
@@ -0,0 +1,31 @@
+import os
+import subprocess
+import sys
+
+
+def main():
+ cmd = sys.argv[1:]
+ h_file = None
+ try:
+ index = cmd.index('-o')
+ h_file = cmd[index+1]
+ cmd[index+1] = os.path.dirname(h_file)
+ except (ValueError, IndexError):
+ pass
+ p = subprocess.Popen(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ if p.returncode:
+ if out:
+ sys.stderr.write('stdout:\n{}\n'.format(out))
+ if err:
+ sys.stderr.write('stderr:\n{}\n'.format(err))
+ sys.exit(p.returncode)
+ if h_file and h_file.endswith(('.fbs.h', '.fbs64.h')):
+ cpp_file = '{}.cpp'.format(h_file[:-2])
+ with open(cpp_file, 'w') as f:
+ f.write('#include "{}"\n'.format(os.path.basename(h_file)))
+ sys.exit(0)
+
+
+if __name__ == '__main__':
+ main()