summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2020-03-02 14:49:28 +1100
committerChris Johns <chrisj@rtems.org>2020-03-03 11:18:05 +1100
commit4295d3d37779226158d729f21c7f7ca515f4f734 (patch)
tree3cc22f09700d1b7e1c831c5662598d5ab7a729af
parent175ce0bcb0618c22d67735f4c83b0ab140a1f609 (diff)
sb/config: Add paths checks to %{path ...}
Updates #3893
-rw-r--r--source-builder/sb/config.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index e781b8e..4856088 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -472,6 +472,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: test=%s' % (test))
if type(test) == str:
test = test.split()
if not self._cross_compile() or self.pkgconfig_crosscompile:
@@ -667,28 +671,50 @@ class file:
elif m.startswith('%{path '):
pl = m[7:-1].strip().split()
ok = False
- if len(pl) == 2:
- ok = True
- epl = []
- for p in pl[1:]:
- epl += [self._expand(p)]
- p = ' '.join(epl)
- if pl[0].lower() == 'prepend':
+ result = ''
+ pl_0 = pl[0].lower()
+ if pl_0 == 'prepend':
+ if len(pl) == 2:
+ ok = True
+ p = ' '.join([self._expand(pp) for pp in pl[1:]])
if len(self.macros['_pathprepend']):
self.macros['_pathprepend'] = \
'%s:%s' % (p, self.macros['_pathprepend'])
else:
self.macros['_pathprepend'] = p
- elif pl[0].lower() == 'postpend':
+ elif pl_0 == 'postpend':
+ if len(pl) == 2:
+ ok = True
+ p = ' '.join([self._expand(pp) for pp in pl[1:]])
if len(self.macros['_pathprepend']):
self.macros['_pathprepend'] = \
'%s:%s' % (self.macros['_pathprepend'], p)
else:
self.macros['_pathprepend'] = p
- else:
- ok = False
+ elif pl_0 == 'check':
+ if len(pl) == 3:
+ pl_1 = pl[1].lower()
+ p = ' '.join([self._expand(pp) for pp in pl[2:]])
+ if pl_1 == 'exists':
+ ok = True
+ if path.exists(p):
+ result = '1'
+ else:
+ result = '0'
+ elif pl_1 == 'isdir':
+ ok = True
+ if path.isdir(p):
+ result = '1'
+ else:
+ result = '0'
+ elif pl_1 == 'isfile':
+ ok = True
+ if path.isfile(p):
+ result = '1'
+ else:
+ result = '0'
if ok:
- s = s.replace(m, '')
+ s = s.replace(m, result)
else:
self._error('path error: %s' % (' '.join(pl)))
mn = None