sb/setbuilder: Control buildsets using the --with-* command line option

- Expand macros in buildset file names

- Add support to buildsets for `%defineifnot`

- Update 6 and 7 to support command line build overrides

Closes #4646
This commit is contained in:
Chris Johns
2022-05-05 12:32:16 +10:00
parent 22e32ecc27
commit 7d80719f74
4 changed files with 57 additions and 29 deletions

View File

@@ -284,6 +284,7 @@ class buildset:
line = line[1:b]
return line.strip()
bset = macro_expand(self.macros, bset)
bsetname = bset
if not path.exists(bsetname):
@@ -315,15 +316,22 @@ class buildset:
if ls[0][-1] == ':' and ls[0][:-1] == 'package':
self.bset_pkg = ls[1].strip()
self.macros['package'] = self.bset_pkg
elif ls[0][0] == '%':
elif ls[0][0] == '%' and (len(ls[0]) > 1 and ls[0][1] != '{'):
def err(msg):
raise error.general('%s:%d: %s' % (self.bset, lc, msg))
if ls[0] == '%define':
if ls[0] == '%define' or ls[0] == '%defineifnot' :
name = ls[1].strip()
value = None
if len(ls) > 2:
self.macros.define(ls[1].strip(),
' '.join([f.strip() for f in ls[2:]]))
else:
self.macros.define(ls[1].strip())
value = ' '.join([f.strip() for f in ls[2:]])
if ls[0] == '%defineifnot':
if self.macros.defined(name):
name = None
if name is not None:
if value is not None:
self.macros.define(name, value)
else:
self.macros.define(name)
elif ls[0] == '%undefine':
if len(ls) > 2:
raise error.general('%s:%d: %undefine requires ' \
@@ -336,7 +344,7 @@ class buildset:
elif ls[0] == '%hash':
sources.hash(ls[1:], self.macros, err)
else:
l = l.strip()
l = macro_expand(self.macros, l.strip())
c = build.find_config(l, self.configs)
if c is None:
raise error.general('%s:%d: cannot find file: %s' % (self.bset,