]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
build: Report gcc and binutils versions in debug log
authorKevin O'Connor <kevin@koconnor.net>
Tue, 13 Oct 2015 19:44:25 +0000 (15:44 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 15 Oct 2015 14:55:10 +0000 (10:55 -0400)
Attempt to extract the gcc and binutils versions.  Report that
information in the debug log.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Makefile
scripts/buildversion.py
src/output.c
src/util.h
src/version.c
vgasrc/vgainit.c
vgasrc/vgaversion.c

index 6e361047ac2c6f6d9af64234c5859d68587adba7..4e4092d075cbfb74db4a97006ef931648b58327b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -158,7 +158,7 @@ $(OUT)romlayout.o: src/romlayout.S $(OUT)autoconf.h $(OUT)asm-offsets.h
 
 $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(OUT)romlayout.o src/version.c scripts/layoutrom.py scripts/buildversion.py
        @echo "  Building ld scripts"
-       $(Q)$(PYTHON) ./scripts/buildversion.py -e "$(EXTRAVERSION)" $(OUT)autoversion.h
+       $(Q)$(PYTHON) ./scripts/buildversion.py -e "$(EXTRAVERSION)" -t "$(CC);$(AS);$(LD);$(OBJCOPY);$(OBJDUMP);$(STRIP)" $(OUT)autoversion.h
        $(Q)$(CC) $(CFLAGS32FLAT) -c src/version.c -o $(OUT)version.o
        $(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
        $(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode16.o $(OUT)romlayout.o -o $(OUT)code16.o
@@ -230,7 +230,7 @@ $(OUT)vgaentry.o: vgasrc/vgaentry.S $(OUT)autoconf.h $(OUT)asm-offsets.h
 
 $(OUT)vgarom.o: $(OUT)vgaccode16.o $(OUT)vgaentry.o $(OUT)vgasrc/vgalayout.lds vgasrc/vgaversion.c scripts/buildversion.py
        @echo "  Linking $@"
-       $(Q)$(PYTHON) ./scripts/buildversion.py -e "$(EXTRAVERSION)" $(OUT)autovgaversion.h
+       $(Q)$(PYTHON) ./scripts/buildversion.py -e "$(EXTRAVERSION)" -t "$(CC);$(AS);$(LD);$(OBJCOPY);$(OBJDUMP);$(STRIP)" $(OUT)autovgaversion.h
        $(Q)$(CC) $(CFLAGS16) -c vgasrc/vgaversion.c -o $(OUT)vgaversion.o
        $(Q)$(LD) --gc-sections -T $(OUT)vgasrc/vgalayout.lds $(OUT)vgaccode16.o $(OUT)vgaentry.o $(OUT)vgaversion.o -o $@
 
index b948134c409a6bf4715fbdc434e823ca4bd7c56f..56bfcfa4bc6dd4fa83d064543a5b407e77d67bd8 100755 (executable)
@@ -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()
index 45397b3f6da205c42f6241f6da3654a6f4581310..8a883889c8a0cf835491b95be16058ae4aa758ac 100644 (file)
@@ -30,6 +30,7 @@ void
 debug_banner(void)
 {
     dprintf(1, "SeaBIOS (version %s)\n", VERSION);
+    dprintf(1, "BUILD: %s\n", BUILDINFO);
 }
 
 // Write a character to debug port(s).
index 327abeb71ddf811497efd30bbd1e04b71d34921f..cba3359d58bf98f7542fe501c10a61995d1bcab9 100644 (file)
@@ -236,6 +236,6 @@ void vgahook_setup(struct pci_device *pci);
 
 
 // version (auto generated file out/version.c)
-extern const char VERSION[];
+extern const char VERSION[], BUILDINFO[];
 
 #endif // util.h
index d8c266fb221118da92b566c1fd69421fabe7cffa..a8a58cf09cf12897323f87d4febb86eebbff0e9a 100644 (file)
@@ -2,3 +2,4 @@
 #include "autoversion.h"
 
 char VERSION[] = BUILD_VERSION;
+char BUILDINFO[] = BUILD_TOOLS;
index 8d12261829f663f4fed98a99faa9346f9d0b5d21..40997dbbd343f0129ebb2c0e683692f0eb64d743 100644 (file)
@@ -150,6 +150,7 @@ vga_post(struct bregs *regs)
 {
     serial_debug_preinit();
     dprintf(1, "Start SeaVGABIOS (version %s)\n", VERSION);
+    dprintf(1, "VGABUILD: %s\n", BUILDINFO);
     debug_enter(regs, DEBUG_VGA_POST);
 
     if (CONFIG_VGA_PCI && !GET_GLOBAL(HaveRunInit)) {
index 02c8ea38c16d9c42bfb1807aec6e7364bca47602..1ef5ddb792a26a7591f813193938b1fd6a8da16d 100644 (file)
@@ -3,3 +3,4 @@
 #include "types.h"
 
 char VERSION[] VAR16 = BUILD_VERSION;
+char BUILDINFO[] VAR16 = BUILD_TOOLS;