Build Sets can reference other build sets.

A build set can invoke another build set. This allows an 'all'
type build set that builds all the RTEMS archs.

Change the get config call to return a map of paths and files.
This commit is contained in:
Chris Johns 2013-02-19 19:00:56 +11:00
parent 8d7624e1d4
commit fba1136108
2 changed files with 53 additions and 35 deletions

View File

@ -466,29 +466,24 @@ class build:
package = packages['main'] package = packages['main']
return package.name() return package.name()
def get_configs(opts, _defaults, ext = '.cfg'): def get_configs(opts, _defaults):
def _scan(_path, ext): def _scan(_path, ext):
configs = [] configs = []
for root, dirs, files in os.walk(_path): for root, dirs, files in os.walk(_path):
prefix = root[len(_path) + 1:] prefix = root[len(_path) + 1:]
for file in files: for file in files:
if file.endswith(ext): for e in ext:
if file.endswith(e):
configs += [path.join(prefix, file)] configs += [path.join(prefix, file)]
return configs return configs
paths = [] configs = { 'paths': [], 'files': [] }
configs = []
files = []
for cp in opts.expand('%{_configdir}', _defaults).split(':'): for cp in opts.expand('%{_configdir}', _defaults).split(':'):
paths += [path.host(path.abspath(cp))] configs['paths'] += [path.host(path.abspath(cp))]
files += _scan(cp, ext) configs['files'] += _scan(cp, ['.cfg', '.bset'])
for f in sorted(files): configs['files'] = sorted(configs['files'])
config = f return configs
if config.endswith(ext):
config = config[:0 - len(ext)]
configs += [config]
return paths, configs
def run(args): def run(args):
try: try:

View File

@ -52,9 +52,10 @@ def _notice(opts, text):
class buildset: class buildset:
"""Build a set builds a set of packages.""" """Build a set builds a set of packages."""
def __init__(self, bset, _defaults, opts): def __init__(self, bset, _configs, _defaults, opts):
_trace(opts, '_bset:%s: init' % (bset)) _trace(opts, '_bset:%s: init' % (bset))
self.opts = opts self.opts = opts
self.configs = _configs
self.defaults = _defaults self.defaults = _defaults
self.bset = bset self.bset = bset
self.bset_pkg = '%s-%s-set' % (self.opts.expand('%{_target}', _defaults), self.bset_pkg = '%s-%s-set' % (self.opts.expand('%{_target}', _defaults),
@ -64,6 +65,18 @@ class buildset:
if not self.opts.quiet(): if not self.opts.quiet():
log.output(text) log.output(text)
def _find_config(self, config):
if config.endswith('.bset') or config.endswith('.cfg'):
names = [config]
else:
names = ['%s.cfg' % (path.basename(config)),
'%s.bset' % (path.basename(config))]
for c in self.configs['files']:
if path.basename(c) in names:
if path.dirname(config).endswith(path.dirname(config)):
return c
return None
def copy(self, src, dst): def copy(self, src, dst):
if os.path.isdir(path.host(src)): if os.path.isdir(path.host(src)):
topdir = self.opts.expand('%{_topdir}', self.defaults) topdir = self.opts.expand('%{_topdir}', self.defaults)
@ -167,7 +180,11 @@ class buildset:
else: else:
raise error.general('invalid directive in build set files: %s' % (l)) raise error.general('invalid directive in build set files: %s' % (l))
else: else:
configs += [l.strip()] l = l.strip()
c = self._find_config(l)
if c is None:
raise error.general('cannot find file: %s' % (l))
configs += [c]
except: except:
bset.close() bset.close()
raise raise
@ -191,7 +208,7 @@ class buildset:
return self.parse(bset) return self.parse(bset)
def make(self): def build(self):
_trace(self.opts, '_bset:%s: make' % (self.bset)) _trace(self.opts, '_bset:%s: make' % (self.bset))
_notice(self.opts, 'Build Set: %s' % (self.bset)) _notice(self.opts, 'Build Set: %s' % (self.bset))
@ -204,6 +221,11 @@ class buildset:
try: try:
builds = [] builds = []
for s in range(0, len(configs)): for s in range(0, len(configs)):
if configs[s].endswith('.bset'):
bs = buildset(configs[s], _configs = self.configs, _defaults = self.defaults, opts = self.opts)
bs.build()
del bs
elif configs[s].endswith('.cfg'):
b = build.build(configs[s], _defaults = self.defaults, opts = self.opts) b = build.build(configs[s], _defaults = self.defaults, opts = self.opts)
if s == 0: if s == 0:
tmproot = self.first_package(b) tmproot = self.first_package(b)
@ -212,6 +234,8 @@ class buildset:
if s == len(configs) - 1: if s == len(configs) - 1:
self.last_package(b, tmproot) self.last_package(b, tmproot)
builds += [b] builds += [b]
else:
raise error.general('invalid config type: %s' % (configs[s]))
if not self.opts.no_clean(): if not self.opts.no_clean():
for b in builds: for b in builds:
_notice(self.opts, 'cleaning: %s' % (b.name())) _notice(self.opts, 'cleaning: %s' % (b.name()))
@ -232,24 +256,23 @@ def run():
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):
if not opts.force(): raise error.general('host build environment is not set up correctly')
raise error.general('host build environment is not set up correctly (use --force to proceed)') configs = build.get_configs(opts, _defaults)
_notice(opts, 'warning: forcing build with known host setup problems')
if opts.get_arg('--list-configs') or opts.get_arg('--list-bsets'): if opts.get_arg('--list-configs') or opts.get_arg('--list-bsets'):
if opts.get_arg('--list-configs'): if opts.get_arg('--list-configs'):
ext = '.cfg' ext = '.cfg'
else: else:
ext = '.bset' ext = '.bset'
paths, configs = build.get_configs(opts, _defaults, ext = ext) for p in configs['paths']:
for p in paths:
print 'Examining: %s' % (os.path.relpath(p)) print 'Examining: %s' % (os.path.relpath(p))
for c in configs: for c in configs['files']:
if c.endswith(ext):
print ' %s' % (c) print ' %s' % (c)
else: else:
for bset in opts.params(): for bset in opts.params():
c = buildset(bset, _defaults = _defaults, opts = opts) b = buildset(bset, _configs = configs, _defaults = _defaults, opts = opts)
c.make() b.build()
del c del b
except error.general, gerr: except error.general, gerr:
print gerr print gerr
sys.exit(1) sys.exit(1)