Support a common verion number for all commands.

This commit is contained in:
Chris Johns 2013-04-05 09:17:47 +11:00
parent 69e593825e
commit efb6688be0
5 changed files with 61 additions and 32 deletions

View File

@ -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' +

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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())