mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
Add optargs for tool extensions of arguments. Fix up the builder.
This commit is contained in:
parent
8f7642f224
commit
71b88934f1
22
sb/build.py
22
sb/build.py
@ -30,6 +30,7 @@ import sys
|
|||||||
import urllib2
|
import urllib2
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
|
import check
|
||||||
import config
|
import config
|
||||||
import defaults
|
import defaults
|
||||||
import error
|
import error
|
||||||
@ -429,11 +430,30 @@ class build:
|
|||||||
package = packages['main']
|
package = packages['main']
|
||||||
return package.name()
|
return package.name()
|
||||||
|
|
||||||
|
def list_configs(opts, _defaults):
|
||||||
|
configs = []
|
||||||
|
for cp in opts.expand('%{_configdir}', _defaults).split(':'):
|
||||||
|
print 'Examining: %s' % (os.path.abspath(cp))
|
||||||
|
configs += glob.glob(os.path.join(cp, '*.cfg'))
|
||||||
|
for c in sorted(configs):
|
||||||
|
config = os.path.basename(c)
|
||||||
|
if config.endswith('.cfg'):
|
||||||
|
config = config[:-4]
|
||||||
|
print ' ', config
|
||||||
|
|
||||||
def run(args):
|
def run(args):
|
||||||
try:
|
try:
|
||||||
opts, _defaults = defaults.load(args)
|
optargs = { '--list-configs': 'List available configurations' }
|
||||||
|
opts, _defaults = defaults.load(args, optargs)
|
||||||
log.default = log.log(opts.logfiles())
|
log.default = log.log(opts.logfiles())
|
||||||
_notice(opts, 'Source Builder, Package Builder v%s' % (version))
|
_notice(opts, 'Source Builder, Package Builder v%s' % (version))
|
||||||
|
if not check.host_setup(opts, _defaults):
|
||||||
|
if not opts.force():
|
||||||
|
raise error.general('host build environment is not set up correctly (use --force to proceed)')
|
||||||
|
_notice(opts, 'warning: forcing build with known host setup problems')
|
||||||
|
if opts.get_arg('--list-configs'):
|
||||||
|
list_configs(opts, _defaults)
|
||||||
|
else:
|
||||||
for config_file in opts.config_files():
|
for config_file in opts.config_files():
|
||||||
b = build(config_file, _defaults = _defaults, opts = opts)
|
b = build(config_file, _defaults = _defaults, opts = opts)
|
||||||
b.make()
|
b.make()
|
||||||
|
@ -276,14 +276,18 @@ class command_line:
|
|||||||
print '--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code'
|
print '--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code'
|
||||||
print '--with-<label> : Add the --with-<label> to the build'
|
print '--with-<label> : Add the --with-<label> to the build'
|
||||||
print '--without-<label> : Add the --without-<label> to the build'
|
print '--without-<label> : Add the --without-<label> to the build'
|
||||||
|
if self.optargs:
|
||||||
|
for a in self.optargs:
|
||||||
|
print '%-22s : %s' % (a, self.optargs[a])
|
||||||
raise error.exit()
|
raise error.exit()
|
||||||
|
|
||||||
def __init__(self, argv):
|
def __init__(self, argv, optargs):
|
||||||
self.command_path = path.dirname(argv[0])
|
self.command_path = path.dirname(argv[0])
|
||||||
if len(self.command_path) == 0:
|
if len(self.command_path) == 0:
|
||||||
self.command_path = '.'
|
self.command_path = '.'
|
||||||
self.command_name = path.basename(argv[0])
|
self.command_name = path.basename(argv[0])
|
||||||
self.args = argv[1:]
|
self.args = argv[1:]
|
||||||
|
self.optargs = optargs
|
||||||
self.defaults = {}
|
self.defaults = {}
|
||||||
for to in command_line._long_true_opts:
|
for to in command_line._long_true_opts:
|
||||||
self.defaults[command_line._long_true_opts[to]] = ('none', 'none', '0')
|
self.defaults[command_line._long_true_opts[to]] = ('none', 'none', '0')
|
||||||
@ -393,8 +397,8 @@ class command_line:
|
|||||||
self.defaults[_arch] = ('none', 'none', _arch_value)
|
self.defaults[_arch] = ('none', 'none', _arch_value)
|
||||||
self.defaults[_vendor] = ('none', 'none', _vendor_value)
|
self.defaults[_vendor] = ('none', 'none', _vendor_value)
|
||||||
self.defaults[_os] = ('none', 'none', _os_value)
|
self.defaults[_os] = ('none', 'none', _os_value)
|
||||||
if not lo:
|
if not lo and a not in self.optargs:
|
||||||
raise error.general('invalid argument: ' + a)
|
raise error.general('invalid argument (try --help): %s' % (a))
|
||||||
else:
|
else:
|
||||||
if a == '-f':
|
if a == '-f':
|
||||||
self.opts['force'] = '1'
|
self.opts['force'] = '1'
|
||||||
@ -404,6 +408,8 @@ class command_line:
|
|||||||
self.opts['quiet'] = '1'
|
self.opts['quiet'] = '1'
|
||||||
elif a == '-?':
|
elif a == '-?':
|
||||||
self._help()
|
self._help()
|
||||||
|
else:
|
||||||
|
raise error.general('invalid argument (try --help): %s' % (a))
|
||||||
else:
|
else:
|
||||||
self.opts['params'].append(a)
|
self.opts['params'].append(a)
|
||||||
i += 1
|
i += 1
|
||||||
@ -463,6 +469,14 @@ class command_line:
|
|||||||
def params(self):
|
def params(self):
|
||||||
return self.opts['params']
|
return self.opts['params']
|
||||||
|
|
||||||
|
def get_arg(self, arg):
|
||||||
|
if not arg in self.optargs:
|
||||||
|
raise error.internal('bad arg: %s' % (arg))
|
||||||
|
for a in self.args:
|
||||||
|
if a.startswith(arg):
|
||||||
|
return a
|
||||||
|
return None
|
||||||
|
|
||||||
def get_config_files(self, config):
|
def get_config_files(self, config):
|
||||||
#
|
#
|
||||||
# Convert to shell paths and return shell paths.
|
# Convert to shell paths and return shell paths.
|
||||||
@ -471,19 +485,20 @@ class command_line:
|
|||||||
# not the initial set of values ?
|
# not the initial set of values ?
|
||||||
#
|
#
|
||||||
config = path.shell(config)
|
config = path.shell(config)
|
||||||
if config.find('*') >= 0 or config.find('?'):
|
if '*' in config or '?' in config:
|
||||||
|
print config
|
||||||
configdir = path.dirname(config)
|
configdir = path.dirname(config)
|
||||||
configbase = path.basename(config)
|
configbase = path.basename(config)
|
||||||
if len(configbase) == 0:
|
if len(configbase) == 0:
|
||||||
configbase = '*'
|
configbase = '*'
|
||||||
|
if not configbase.endswith('.cfg'):
|
||||||
|
configbase = configbase + '.cfg'
|
||||||
if len(configdir) == 0:
|
if len(configdir) == 0:
|
||||||
configdir = self.expand(defaults['_configdir'][2], defaults)
|
configdir = self.expand(defaults['_configdir'][2], defaults)
|
||||||
hostconfigdir = path.host(configdir)
|
|
||||||
if not os.path.isdir(hostconfigdir):
|
|
||||||
raise error.general('configdir is not a directory or does not exist: %s' % (hostconfigdir))
|
|
||||||
files = glob.glob(os.path.join(hostconfigdir, configbase))
|
|
||||||
configs = []
|
configs = []
|
||||||
for f in files:
|
for cp in configdir.split(':'):
|
||||||
|
hostconfigdir = path.host(cp)
|
||||||
|
for f in glob.glob(os.path.join(hostconfigdir, configbase)):
|
||||||
configs += path.shell(f)
|
configs += path.shell(f)
|
||||||
else:
|
else:
|
||||||
configs = [config]
|
configs = [config]
|
||||||
@ -510,7 +525,7 @@ class command_line:
|
|||||||
return self.opts['prefixbase']
|
return self.opts['prefixbase']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def load(args):
|
def load(args, optargs = None):
|
||||||
"""
|
"""
|
||||||
Copy the defaults, get the host specific values and merge them overriding
|
Copy the defaults, get the host specific values and merge them overriding
|
||||||
any matching defaults, then create an options object to handle the command
|
any matching defaults, then create an options object to handle the command
|
||||||
@ -540,7 +555,7 @@ def load(args):
|
|||||||
raise error.general('no hosts defaults found; please add')
|
raise error.general('no hosts defaults found; please add')
|
||||||
for k in overrides:
|
for k in overrides:
|
||||||
d[k] = overrides[k]
|
d[k] = overrides[k]
|
||||||
o = command_line(args)
|
o = command_line(args, optargs)
|
||||||
for k in o.defaults:
|
for k in o.defaults:
|
||||||
d[k] = o.defaults[k]
|
d[k] = o.defaults[k]
|
||||||
d = o._post_process(d)
|
d = o._post_process(d)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import distutils.dir_util
|
import distutils.dir_util
|
||||||
|
import glob
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -214,11 +215,17 @@ class buildset:
|
|||||||
def run():
|
def run():
|
||||||
import sys
|
import sys
|
||||||
try:
|
try:
|
||||||
opts, _defaults = defaults.load(sys.argv)
|
optargs = { '--list-configs': 'List available configurations' }
|
||||||
|
opts, _defaults = defaults.load(sys.argv, optargs)
|
||||||
log.default = log.log(opts.logfiles())
|
log.default = log.log(opts.logfiles())
|
||||||
_notice(opts, 'Source Builder - Set Builder, v%s' % (version))
|
_notice(opts, 'Source Builder - Set Builder, v%s' % (version))
|
||||||
if not check.host_setup(opts, _defaults):
|
if not check.host_setup(opts, _defaults):
|
||||||
raise error.general('host build environment is not set up correctly')
|
if not opts.force():
|
||||||
|
raise error.general('host build environment is not set up correctly (use --force to proceed)')
|
||||||
|
_notice(opts, 'warning: forcing build with known host setup problems')
|
||||||
|
if opts.get_arg('--list-configs'):
|
||||||
|
build.list_configs(opts, _defaults)
|
||||||
|
else:
|
||||||
for bset in opts.params():
|
for bset in opts.params():
|
||||||
c = buildset(bset, _defaults = _defaults, opts = opts)
|
c = buildset(bset, _defaults = _defaults, opts = opts)
|
||||||
c.make()
|
c.make()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user