mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
Add the sb-defaults command to print a hosts defaults.
This commit is contained in:
29
source-builder/sb-defaults
Executable file
29
source-builder/sb-defaults
Executable 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)
|
@@ -29,6 +29,7 @@ import os
|
|||||||
import error
|
import error
|
||||||
import execute
|
import execute
|
||||||
import path
|
import path
|
||||||
|
import sys
|
||||||
|
|
||||||
basepath = 'sb'
|
basepath = 'sb'
|
||||||
|
|
||||||
@@ -254,7 +255,7 @@ class command_line:
|
|||||||
|
|
||||||
def _help(self):
|
def _help(self):
|
||||||
print '%s: [options] [args]' % (self.command_name)
|
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 'Options and arguments:'
|
||||||
print '--force : Force the build to proceed'
|
print '--force : Force the build to proceed'
|
||||||
print '--trace : Trace the execution (not current used)'
|
print '--trace : Trace the execution (not current used)'
|
||||||
@@ -564,16 +565,41 @@ def load(args, optargs = None):
|
|||||||
d = o._post_process(d)
|
d = o._post_process(d)
|
||||||
return o, d
|
return o, d
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def run(args):
|
||||||
import sys
|
|
||||||
try:
|
try:
|
||||||
_opts, _defaults = load(args = sys.argv)
|
_opts, _defaults = load(args = args)
|
||||||
|
print 'Options:'
|
||||||
print _opts
|
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:
|
except error.general, gerr:
|
||||||
print gerr
|
print gerr
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except error.internal, ierr:
|
except error.internal, ierr:
|
||||||
print ierr
|
print ierr
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
except error.exit, eerr:
|
||||||
|
pass
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
_notice(opts, 'user terminated')
|
||||||
|
sys.exit(1)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run(sys.argv)
|
||||||
|
Reference in New Issue
Block a user