aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-10-13 15:44:25 -0400
committerKevin O'Connor <kevin@koconnor.net>2015-10-15 10:55:10 -0400
commitefd70a5006b9d402ba74fd3c49872062cb48667f (patch)
tree5a67c5aa870eaca0cd9adef23dce8462fdf7113e /scripts
parenta6c877401b748092e2e7799bfb4a4bd84729b1da (diff)
downloadseabios-hppa-efd70a5006b9d402ba74fd3c49872062cb48667f.zip
seabios-hppa-efd70a5006b9d402ba74fd3c49872062cb48667f.tar.gz
seabios-hppa-efd70a5006b9d402ba74fd3c49872062cb48667f.tar.bz2
build: Report gcc and binutils versions in debug log
Attempt to extract the gcc and binutils versions. Report that information in the debug log. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/buildversion.py47
1 files changed, 43 insertions, 4 deletions
diff --git a/scripts/buildversion.py b/scripts/buildversion.py
index b948134..56bfcfa 100755
--- a/scripts/buildversion.py
+++ b/scripts/buildversion.py
@@ -4,11 +4,12 @@
# Copyright (C) 2015 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import sys, os, subprocess, time, socket, optparse
+import sys, os, subprocess, time, socket, optparse, re
VERSION_FORMAT = """
/* DO NOT EDIT! This is an autogenerated file. See scripts/buildversion.py. */
#define BUILD_VERSION "%s"
+#define BUILD_TOOLS "%s"
"""
# Obtain version info from "git" program
@@ -35,23 +36,61 @@ def file_version():
return ver
# Generate an output file with the version information
-def write_version(outfile, version):
+def write_version(outfile, version, toolstr):
sys.stdout.write("Version: %s\n" % (version,))
f = open(outfile, 'w')
- f.write(VERSION_FORMAT % (version,))
+ f.write(VERSION_FORMAT % (version, toolstr))
f.close()
+re_gcc = re.compile(r'^(?P<prog>.*) \(GCC\) (?P<version>.*)$')
+re_binutils = re.compile(r'^GNU (?P<prog>.*) version (?P<version>.*)$')
+
+# Run "tool --version" for each specified tool and extract versions
+def tool_versions(tools):
+ tools = [t.strip() for t in tools.split(';')]
+ gcc = binutils = ""
+ success = 0
+ for tool in tools:
+ try:
+ ver = subprocess.check_output([tool, '--version']).decode()
+ except:
+ continue
+ ver = ver.split('\n')[0]
+ m = re_gcc.match(ver)
+ if m:
+ ver = m.group('version')
+ if gcc and gcc != ver:
+ gcc = "mixed"
+ continue
+ gcc = ver
+ success += 1
+ continue
+ m = re_binutils.match(ver)
+ if m:
+ ver = m.group('version')
+ if binutils and binutils != ver:
+ binutils = "mixed"
+ continue
+ binutils = ver
+ success += 1
+ cleanbuild = binutils and gcc and success == len(tools)
+ return cleanbuild, "gcc: %s binutils: %s" % (gcc, binutils)
+
def main():
usage = "%prog [options] <outputheader.h>"
opts = optparse.OptionParser(usage)
opts.add_option("-e", "--extra", dest="extra", default="",
help="extra version string to append to version")
+ opts.add_option("-t", "--tools", dest="tools", default="",
+ help="list of build programs to extra version from")
options, args = opts.parse_args()
if len(args) != 1:
opts.error("Incorrect arguments")
outfile = args[0]
+ cleanbuild, toolstr = tool_versions(options.tools)
+
ver = git_version()
if not ver:
ver = file_version()
@@ -60,7 +99,7 @@ def main():
btime = time.strftime("%Y%m%d_%H%M%S")
hostname = socket.gethostname()
ver = "%s-%s-%s%s" % (ver, btime, hostname, options.extra)
- write_version(outfile, ver)
+ write_version(outfile, ver, toolstr)
if __name__ == '__main__':
main()