diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2015-11-10 09:26:52 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2015-11-11 10:31:24 -0500 |
commit | fa7545ab2de9f81fed1a156a39778b138fb80bd5 (patch) | |
tree | c3e08630604d69bca69b3a1fded4a3449f29282f /scripts | |
parent | 8c12694b8a12300c223d14045a271f46fb1cbca3 (diff) | |
download | seabios-fa7545ab2de9f81fed1a156a39778b138fb80bd5.tar.gz |
buildversion: Add debugging messages
Add ability to output debug messages from the buildversion.py build
script.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/buildversion.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/scripts/buildversion.py b/scripts/buildversion.py index 1045049a..ad47b902 100755 --- a/scripts/buildversion.py +++ b/scripts/buildversion.py @@ -4,7 +4,7 @@ # 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, shlex, time, socket, optparse +import sys, os, subprocess, shlex, time, socket, optparse, logging, traceback VERSION_FORMAT = """ /* DO NOT EDIT! This is an autogenerated file. See scripts/buildversion.py. */ @@ -14,40 +14,51 @@ VERSION_FORMAT = """ # Run program and return the specified output def check_output(prog): + logging.debug("Running %s" % (repr(prog),)) try: process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE) output = process.communicate()[0] retcode = process.poll() except OSError: + logging.debug("Exception on run: %s" % (traceback.format_exc(),)) return "" + logging.debug("Got (code=%s): %s" % (retcode, repr(output))) if retcode: return "" try: return output.decode() except UnicodeError: + logging.debug("Exception on decode: %s" % (traceback.format_exc(),)) return "" # Obtain version info from "git" program def git_version(): if not os.path.exists('.git'): + logging.debug("No '.git' file/directory found") return "" - return check_output("git describe --tags --long --dirty").strip() + ver = check_output("git describe --tags --long --dirty").strip() + logging.debug("Got git version: %s" % (repr(ver),)) + return ver # Look for version in a ".version" file. Official release tarballs # have this file (see scripts/tarball.sh). def file_version(): if not os.path.isfile('.version'): + logging.debug("No '.version' file found") return "" try: f = open('.version', 'r') ver = f.readline().strip() f.close() except OSError: + logging.debug("Exception on read: %s" % (traceback.format_exc(),)) return "" + logging.debug("Got .version: %s" % (repr(ver),)) return ver # Generate an output file with the version information def write_version(outfile, version, toolstr): + logging.debug("Write file %s and %s" % (repr(version), repr(toolstr))) sys.stdout.write("Version: %s\n" % (version,)) f = open(outfile, 'w') f.write(VERSION_FORMAT % (version, toolstr)) @@ -74,6 +85,8 @@ def tool_versions(tools): continue # Check for any version conflicts if versions[isbinutils] and versions[isbinutils] != ver: + logging.debug("Mixed version %s vs %s" % ( + repr(versions[isbinutils]), repr(ver))) vers[isbinutils] = "mixed" continue versions[isbinutils] = ver @@ -88,11 +101,15 @@ def main(): help="extra version string to append to version") opts.add_option("-t", "--tools", dest="tools", default="", help="list of build programs to extract version from") + opts.add_option("-v", action="store_true", dest="verbose", + help="enable debug messages") options, args = opts.parse_args() if len(args) != 1: opts.error("Incorrect arguments") outfile = args[0] + if options.verbose: + logging.basicConfig(level=logging.DEBUG) cleanbuild, toolstr = tool_versions(options.tools) |