[rtems-source-builder commit] sb/config: Add paths checks to %{path ...}

Chris Johns chrisj at rtems.org
Tue Mar 3 02:01:22 UTC 2020


Module:    rtems-source-builder
Branch:    master
Commit:    4295d3d37779226158d729f21c7f7ca515f4f734
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=4295d3d37779226158d729f21c7f7ca515f4f734

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Mar  2 14:49:28 2020 +1100

sb/config: Add paths checks to %{path ...}

Updates #3893

---

 source-builder/sb/config.py | 48 ++++++++++++++++++++++++++++++++++-----------
 1 file 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



More information about the vc mailing list