summaryrefslogtreecommitdiffstats
path: root/source-builder/sb/config.py
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2020-08-10 14:49:49 +1000
committerChris Johns <chrisj@rtems.org>2020-08-10 16:19:47 +1000
commit12418190b984f3f94da08588276ef3d6440bd454 (patch)
tree7d338838a57cc342f1edd7e578c25054a18e9342 /source-builder/sb/config.py
parent6/7: Update unstable RTEMS 6/7 tool chain (diff)
downloadrtems-source-builder-12418190b984f3f94da08588276ef3d6440bd454.tar.bz2
sb/track: Add a command to track build sets.
- Process a build set for a range of hosts and output a dependency tree, the used build set and configuration files. - Output the configuration files that are no referenced Closes #4036
Diffstat (limited to 'source-builder/sb/config.py')
-rw-r--r--source-builder/sb/config.py87
1 files changed, 52 insertions, 35 deletions
diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index afcac84..f8854a5 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -283,6 +283,7 @@ class file:
return s
def _reset(self, name):
+ self.parent = 'root'
self.name = name
self.load_depth = 0
self.configpath = []
@@ -430,7 +431,8 @@ class file:
if len(shell_macro) > 3:
e = execute.capture_execution()
if options.host_windows:
- shell_cmd = ''.join([c if c != '"' else '\\' + c for c in shell_macro[2:-1]])
+ shell_cmd = \
+ ''.join([c if c != '"' else '\\' + c for c in shell_macro[2:-1]])
cmd = '%s -c "%s"' % (self.macros.expand('%{__sh}'), shell_cmd)
else:
cmd = shell_macro[2:-1]
@@ -458,7 +460,8 @@ class file:
if braces > 0:
braces -= 1
else:
- shell_cmd = '%(' + self._shell(line[pos + 2:p], nesting + 1) + ')'
+ shell_cmd = '%(' + \
+ self._shell(line[pos + 2:p], nesting + 1) + ')'
line = line[:pos] + _exec(shell_cmd) + line[p + 1:]
updating = True
break
@@ -472,9 +475,10 @@ class file:
('with_download' in self.macros and self.macros['with_download'] == '1'):
return '0'
ok = False
- log.trace('pkgconfig: check: crossc=%d pkg_crossc=%d prefix=%s' % ( self._cross_compile(),
- self.pkgconfig_crosscompile,
- self.pkgconfig_prefix))
+ log.trace('pkgconfig: check: crossc=%d pkg_crossc=%d prefix=%s'
+ % ( self._cross_compile(),
+ self.pkgconfig_crosscompile,
+ self.pkgconfig_prefix))
log.trace('pkgconfig: check: test=%s' % (test))
if type(test) == str:
test = test.split()
@@ -594,7 +598,8 @@ class file:
elif m.startswith('%{expand'):
colon = m.find(':')
if colon < 8:
- log.warning(self._name_line_msg('malformed expand macro, no colon found'))
+ log.warning(self._name_line_msg('malformed expand macro, ' \
+ 'no colon found'))
else:
e = self._expand(m[colon + 1:-1].strip())
s = s.replace(m, self._label(e))
@@ -861,7 +866,8 @@ class file:
dir, info, data = self._process_directive(r, dir, info, data)
else:
if in_dir != dir:
- self._error('directives cannot change scope across if statements')
+ self._error('directives cannot change' \
+ ' scope across if statements')
return data
if r[1] == '%else':
@@ -904,22 +910,25 @@ class file:
elif cls[0] == '&&':
join_op = 'and'
cls = cls[1:]
- log.trace('config: %s: %3d: _if[%i]: joining: %s' % (self.name, self.lc,
- self.if_depth,
- join_op))
+ log.trace('config: %s: %3d: _if[%i]: joining: %s' % \
+ (self.name, self.lc,
+ self.if_depth,
+ join_op))
ori = 0
andi = 0
i = len(cls)
if '||' in cls:
ori = cls.index('||')
- log.trace('config: %s: %3d: _if[%i}: OR found at %i' % (self.name, self.lc,
- self.if_depth,
- ori))
+ log.trace('config: %s: %3d: _if[%i}: OR found at %i' % \
+ (self.name, self.lc,
+ self.if_depth,
+ ori))
if '&&' in cls:
andi = cls.index('&&')
- log.trace('config: %s: %3d: _if[%i]: AND found at %i' % (self.name, self.lc,
- self.if_depth,
- andi))
+ log.trace('config: %s: %3d: _if[%i]: AND found at %i' % \
+ (self.name, self.lc,
+ self.if_depth,
+ andi))
if ori > 0 or andi > 0:
if ori == 0:
i = andi
@@ -929,9 +938,10 @@ class file:
i = andi
else:
i = andi
- log.trace('config: %s: %3d: _if[%i]: next OP found at %i' % (self.name, self.lc,
- self.if_depth,
- i))
+ log.trace('config: %s: %3d: _if[%i]: next OP found at %i' % \
+ (self.name, self.lc,
+ self.if_depth,
+ i))
ls = cls[:i]
if len(ls) == 0:
self._error('invalid if expression: ' + reduce(add, sls, ''))
@@ -1226,7 +1236,8 @@ class file:
log.trace('config: %s: %3d: _parse: directive: %s' % \
(self.name, self.lc, ls[0].strip()))
return ('directive', ls[0].strip(), ls[1:])
- log.warning(self._name_line_msg("unknown directive: '" + ls[0] + "'"))
+ log.warning(self._name_line_msg("unknown directive: '" + \
+ ls[0] + "'"))
return ('data', [lo])
else:
return ('data', [lo])
@@ -1247,7 +1258,8 @@ class file:
_package = results[2][0]
else:
if results[2][0].strip() != '-n':
- log.warning(self._name_line_msg("unknown directive option: '%s'" % (' '.join(results[2]))))
+ log.warning(self._name_line_msg("unknown directive option: '%s'" % \
+ (' '.join(results[2]))))
_package = results[2][1].strip()
self._set_package(_package)
if directive and directive != results[1]:
@@ -1257,7 +1269,8 @@ class file:
return (directive, info, data)
def _process_data(self, results, directive, info, data):
- log.trace('config: %s: %3d: _process_data: result=#%r# directive=#%s# info=#%r# data=#%r#' % \
+ log.trace('config: %s: %3d: _process_data: result=#%r# ' \
+ 'directive=#%s# info=#%r# data=#%r#' % \
(self.name, self.lc, results, directive, info, data))
new_data = []
for l in results[1]:
@@ -1284,10 +1297,12 @@ class file:
if info is not None:
self._info_append(info, info_data)
else:
- log.warning(self._name_line_msg("invalid format: '%s'" % (info_data[:-1])))
+ log.warning(self._name_line_msg("invalid format: '%s'" % \
+ (info_data[:-1])))
else:
l = self._expand(l)
- log.trace('config: %s: %3d: _data: %s %s' % (self.name, self.lc, l, new_data))
+ log.trace('config: %s: %3d: _data: %s %s' % \
+ (self.name, self.lc, l, new_data))
new_data.append(l)
return (directive, info, data + new_data)
@@ -1303,7 +1318,8 @@ class file:
self.package = _package
def _directive_extend(self, dir, data):
- log.trace('config: %s: %3d: _directive_extend: %s: %r' % (self.name, self.lc, dir, data))
+ log.trace('config: %s: %3d: _directive_extend: %s: %r' % \
+ (self.name, self.lc, dir, data))
self._packages[self.package].directive_extend(dir, data)
def _info_append(self, info, data):
@@ -1328,7 +1344,6 @@ class file:
return end
if self.load_depth == 0:
- self._reset(name)
self._packages[self.package] = package(self.package,
self.define('%{_arch}'),
self)
@@ -1336,6 +1351,7 @@ class file:
self.load_depth += 1
save_name = self.name
+ save_parent = self.parent
save_lc = self.lc
#
@@ -1382,7 +1398,9 @@ class file:
raise error.general('error opening config file: %s' % (path.host(configname)))
self.configpath += [configname]
- self._includes += [configname]
+
+ self._includes += [configname + ':' + self.parent]
+ self.parent = configname
self.name = self._relative_path(configname)
self.lc = 0
@@ -1413,13 +1431,12 @@ class file:
except:
config.close()
raise
-
- config.close()
-
- self.name = save_name
- self.lc = save_lc
-
- self.load_depth -= 1
+ finally:
+ config.close()
+ self.name = save_name
+ self.parent = save_parent
+ self.lc = save_lc
+ self.load_depth -= 1
def defined(self, name):
return name in self.macros
@@ -1456,7 +1473,7 @@ class file:
raise error.general('package "' + _package + '" not found')
if name not in self._packages[_package].directives:
raise error.general('directive "' + name + \
- '" not found in package "' + _package + '"')
+ '" not found in package "' + _package + '"')
return self._packages[_package].directives[name]
def abspath(self, rpath):