Add the sb-defaults command to print a hosts defaults.

This commit is contained in:
Chris Johns 2013-02-23 14:45:27 +11:00
parent de8f4bfb0f
commit 27e5a7e7f5
2 changed files with 60 additions and 5 deletions

29
source-builder/sb-defaults Executable file
View File

@ -0,0 +1,29 @@
#! /usr/bin/env python
#
# 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.
import sys, os
base = os.path.dirname(sys.argv[0])
sys.path.insert(0, base + '/sb')
try:
import defaults
defaults.run(sys.argv)
except ImportError:
print >> sys.stderr, "Incorrect Defaults installation"
sys.exit(1)

View File

@ -29,6 +29,7 @@ import os
import error
import execute
import path
import sys
basepath = 'sb'
@ -254,7 +255,7 @@ class command_line:
def _help(self):
print '%s: [options] [args]' % (self.command_name)
print 'Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns'
print 'RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2013 Chris Johns'
print 'Options and arguments:'
print '--force : Force the build to proceed'
print '--trace : Trace the execution (not current used)'
@ -564,16 +565,41 @@ def load(args, optargs = None):
d = o._post_process(d)
return o, d
if __name__ == '__main__':
import sys
def run(args):
try:
_opts, _defaults = load(args = sys.argv)
_opts, _defaults = load(args = args)
print 'Options:'
print _opts
pprint.pprint(_defaults)
print 'Defaults:'
for k in sorted(_defaults.keys()):
d = _defaults[k]
print '%-20s: %-8s %-10s' % (k, d[0], d[1]),
indent = False
if len(d[2]) == 0:
print
text_len = 80
for l in d[2].split('\n'):
while len(l):
if indent:
print '%20s %8s %10s' % (' ', ' ', ' '),
print l[0:text_len],
l = l[text_len:]
if len(l):
print ' \\',
print
indent = True
except error.general, gerr:
print gerr
sys.exit(1)
except error.internal, ierr:
print ierr
sys.exit(1)
except error.exit, eerr:
pass
except KeyboardInterrupt:
_notice(opts, 'user terminated')
sys.exit(1)
sys.exit(0)
if __name__ == '__main__':
run(sys.argv)