aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/build_info_gen.py
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-02-10 16:45:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:46 +0300
commit81eddc8c0b55990194e112b02d127b87d54164a9 (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /build/scripts/build_info_gen.py
parent397cbe258b9e064f49c4ca575279f02f39fef76e (diff)
downloadydb-81eddc8c0b55990194e112b02d127b87d54164a9.tar.gz
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/build_info_gen.py')
-rw-r--r--build/scripts/build_info_gen.py124
1 files changed, 62 insertions, 62 deletions
diff --git a/build/scripts/build_info_gen.py b/build/scripts/build_info_gen.py
index 9bc8475ded..949e0a1636 100644
--- a/build/scripts/build_info_gen.py
+++ b/build/scripts/build_info_gen.py
@@ -1,63 +1,63 @@
-import subprocess
-import os
-import sys
-import re
-
-indent = " "
-
-
-def escape_special_symbols(strval):
- retval = ""
- for c in strval:
- if c in ("\\", "\""):
- retval += "\\" + c
- elif ord(c) < 0x20:
- retval += c.encode("string_escape")
- else:
- retval += c
- return retval
-
-
-def escape_line_feed(strval):
- return re.sub(r'\\n', r'\\n"\\\n' + indent + '"', strval)
-
-
-def escaped_define(strkey, strval):
- return "#define " + strkey + " \"" + escape_line_feed(escape_special_symbols(strval)) + "\""
-
-
-def get_build_info(compiler, flags):
- build_info = "Build info:\n"
- build_info += indent + "Compiler: " + compiler + "\n"
- build_info += indent + "Compiler version: \n" + get_compiler_info(compiler) + "\n"
- build_info += indent + "Compile flags: " + (flags if flags else "no flags info")
- return build_info
-
-
-def get_compiler_info(compiler):
- compiler_binary = os.path.basename(compiler).lower()
- if len(compiler.split(' ')) > 1 or compiler_binary == "ymake" or compiler_binary == "ymake.exe":
- compiler_ver_out = "Build by wrapper. No useful info here."
- else:
- compiler_ver_cmd = [compiler]
- if compiler_binary not in ("cl", "cl.exe"):
- compiler_ver_cmd.append('--version')
- compiler_ver_out = subprocess.Popen(compiler_ver_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
- return "\n".join(['{}{}'.format(indent * 2, line.strip()) for line in compiler_ver_out.splitlines() if line.strip()])
-
-
-def main():
- if len(sys.argv) != 4:
+import subprocess
+import os
+import sys
+import re
+
+indent = " "
+
+
+def escape_special_symbols(strval):
+ retval = ""
+ for c in strval:
+ if c in ("\\", "\""):
+ retval += "\\" + c
+ elif ord(c) < 0x20:
+ retval += c.encode("string_escape")
+ else:
+ retval += c
+ return retval
+
+
+def escape_line_feed(strval):
+ return re.sub(r'\\n', r'\\n"\\\n' + indent + '"', strval)
+
+
+def escaped_define(strkey, strval):
+ return "#define " + strkey + " \"" + escape_line_feed(escape_special_symbols(strval)) + "\""
+
+
+def get_build_info(compiler, flags):
+ build_info = "Build info:\n"
+ build_info += indent + "Compiler: " + compiler + "\n"
+ build_info += indent + "Compiler version: \n" + get_compiler_info(compiler) + "\n"
+ build_info += indent + "Compile flags: " + (flags if flags else "no flags info")
+ return build_info
+
+
+def get_compiler_info(compiler):
+ compiler_binary = os.path.basename(compiler).lower()
+ if len(compiler.split(' ')) > 1 or compiler_binary == "ymake" or compiler_binary == "ymake.exe":
+ compiler_ver_out = "Build by wrapper. No useful info here."
+ else:
+ compiler_ver_cmd = [compiler]
+ if compiler_binary not in ("cl", "cl.exe"):
+ compiler_ver_cmd.append('--version')
+ compiler_ver_out = subprocess.Popen(compiler_ver_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
+ return "\n".join(['{}{}'.format(indent * 2, line.strip()) for line in compiler_ver_out.splitlines() if line.strip()])
+
+
+def main():
+ if len(sys.argv) != 4:
print >>sys.stderr, "Usage: build_info_gen.py <output file> <CXX compiler> <CXX flags>"
- sys.exit(1)
- cxx_compiler = sys.argv[2]
- cxx_flags = sys.argv[3]
- with open(sys.argv[1], 'w') as result:
- print >> result, "#pragma once\n"
- print >> result, escaped_define("BUILD_INFO", get_build_info(cxx_compiler, cxx_flags))
- print >> result, escaped_define("BUILD_COMPILER", cxx_compiler)
- print >> result, escaped_define("BUILD_COMPILER_VERSION", get_compiler_info(cxx_compiler))
- print >> result, escaped_define("BUILD_COMPILER_FLAGS", cxx_flags)
-
-if __name__ == "__main__":
- main()
+ sys.exit(1)
+ cxx_compiler = sys.argv[2]
+ cxx_flags = sys.argv[3]
+ with open(sys.argv[1], 'w') as result:
+ print >> result, "#pragma once\n"
+ print >> result, escaped_define("BUILD_INFO", get_build_info(cxx_compiler, cxx_flags))
+ print >> result, escaped_define("BUILD_COMPILER", cxx_compiler)
+ print >> result, escaped_define("BUILD_COMPILER_VERSION", get_compiler_info(cxx_compiler))
+ print >> result, escaped_define("BUILD_COMPILER_FLAGS", cxx_flags)
+
+if __name__ == "__main__":
+ main()