From efb6688be01b2f1a358980d6069e23cf6e51f163 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Fri, 5 Apr 2013 09:17:47 +1100 Subject: [PATCH] Support a common verion number for all commands. --- source-builder/sb/build.py | 29 ++++++++++++++------------ source-builder/sb/check.py | 11 ++++------ source-builder/sb/reports.py | 8 ++----- source-builder/sb/setbuilder.py | 8 ++----- source-builder/sb/version.py | 37 +++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 source-builder/sb/version.py diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py index 283e2c2..4a46a62 100644 --- a/source-builder/sb/build.py +++ b/source-builder/sb/build.py @@ -31,18 +31,21 @@ import sys import urllib2 import urlparse -import check -import config -import defaults -import error -import execute -import log -import path - -# -# Version of Sourcer Builder Build. -# -version = '0.1' +try: + import check + import config + import defaults + import error + import execute + import log + import path + import version +except KeyboardInterrupt: + print 'abort: user terminated' + sys.exit(1) +except: + print 'error: unknown application load error' + sys.exit(1) def _notice(opts, text): if not opts.quiet() and not log.default.has_stdout(): @@ -515,7 +518,7 @@ def run(args): optargs = { '--list-configs': 'List available configurations' } opts, _defaults = defaults.load(args, optargs) log.default = log.log(opts.logfiles()) - _notice(opts, 'RTEMS Source Builder, Package Builder v%s' % (version)) + _notice(opts, 'RTEMS Source Builder, Package Builder v%s' % (version.str())) if not check.host_setup(opts, _defaults): if not opts.force(): raise error.general('host build environment is not set up' + diff --git a/source-builder/sb/check.py b/source-builder/sb/check.py index 60a9e9a..a0c0e4d 100644 --- a/source-builder/sb/check.py +++ b/source-builder/sb/check.py @@ -28,11 +28,7 @@ import error import execute import log import path - -# -# Version of Sourcer Builder Check. -# -version = '0.1' +import version def _notice(opts, text): if not opts.quiet() and log.default and not log.default.has_stdout(): @@ -140,10 +136,11 @@ def run(): import sys try: _opts, _defaults = defaults.load(args = sys.argv) + _notice(_opts, 'RTEMS Source Builder - Check, v%s' % (version.str())) if host_setup(_opts, _defaults): - print 'RTEMS Source Builder environment is ok' + print 'Environment is ok' else: - print 'RTEMS Source Builder environment is not correctly set up' + print 'Environment is not correctly set up' except error.general, gerr: print gerr sys.exit(1) diff --git a/source-builder/sb/reports.py b/source-builder/sb/reports.py index 61d38c1..bbb42f4 100644 --- a/source-builder/sb/reports.py +++ b/source-builder/sb/reports.py @@ -37,6 +37,7 @@ try: import log import path import setbuilder + import version except KeyboardInterrupt: print 'user terminated' sys.exit(1) @@ -44,11 +45,6 @@ except: print 'error: unknown application load error' sys.exit(1) -# -# Version of Sourcer Builder Build. -# -version = '0.1' - def _notice(opts, text): if not opts.quiet() and not log.default.has_stdout(): print text @@ -371,7 +367,7 @@ def run(args): log.default = log.log(opts.logfiles()) if opts.get_arg('--output') and len(opts.params()) > 1: raise error.general('--output can only be used with a single config') - print 'RTEMS Source Builder, Reporter v%s' % (version) + print 'RTEMS Source Builder, Reporter v%s' % (version.str()) if not check.host_setup(opts, _defaults): _notice(opts, 'warning: forcing build with known host setup problems') configs = build.get_configs(opts, _defaults) diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index efdc99d..4a0b554 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -38,6 +38,7 @@ try: import log import path import reports + import vrrsion except KeyboardInterrupt: print 'abort: user terminated' sys.exit(1) @@ -45,11 +46,6 @@ except: print 'error: unknown application load error' sys.exit(1) -# -# Version of RTEMS Source Builder Set Builder. -# -version = '0.1' - def _trace(opts, text): if opts.trace(): print text @@ -366,7 +362,7 @@ def run(): '--pkg-tar-files': 'Create package tar files' } opts, _defaults = defaults.load(sys.argv, optargs) log.default = log.log(opts.logfiles()) - _notice(opts, 'RTEMS Source Builder - Set Builder, v%s' % (version)) + _notice(opts, 'RTEMS Source Builder - Set Builder, v%s' % (version.str())) if not check.host_setup(opts, _defaults): raise error.general('host build environment is not set up correctly') configs = build.get_configs(opts, _defaults) diff --git a/source-builder/sb/version.py b/source-builder/sb/version.py new file mode 100644 index 0000000..89c2c36 --- /dev/null +++ b/source-builder/sb/version.py @@ -0,0 +1,37 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2013 Chris Johns (chrisj@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# +# Manage paths locally. The internally the path is in Unix or shell format and +# we convert to the native format when performing operations at the Python +# level. This allows macro expansion to work. +# + +major = 0 +minor = 2 +revision = 0 + +def str(): + return '%d.%d.%d'% (major, minor, revision) + +if __name__ == '__main__': + print 'major = %d' % (major) + print 'minor = %d' % (minor) + print 'revision = %d' % (revision) + print 'Version: %s' % (str())