[jhbuild: 2/6] Parse <pkg-config> node



commit 19b2e015dfd28c92e1b1e8669eab364122c8fee3
Author: Colin Walters <walters verbum org>
Date:   Thu Jul 14 12:19:54 2011 -0400

    Parse <pkg-config> node
    
    https://bugzilla.gnome.org/show_bug.cgi?id=564373

 jhbuild/commands/base.py     |    1 +
 jhbuild/modtypes/__init__.py |   34 ++++++++++++++++++++++++++++------
 2 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index af629c5..1852660 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -349,6 +349,7 @@ class cmd_buildone(Command):
         for modname in args:
             try:
                 module = module_set.get_module(modname, ignore_case=True)
+                print module.pkg_config
             except KeyError, e:
                 default_repo = jhbuild.moduleset.get_default_repo()
                 if not default_repo:
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 0e2df03..b7fdcaf 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -86,14 +86,32 @@ def get_dependencies(node):
 
     return dependencies, after, suggests
 
+def get_node_content(node):
+    node.normalize()
+    value = ''
+    for child in node.childNodes:
+        if child.nodeType == child.TEXT_NODE:
+            value += child.nodeValue
+    return value
+
+def find_first_child_node(node, name):
+    for childnode in node.childNodes:
+        if (childnode.nodeType == childnode.ELEMENT_NODE and
+            childnode.nodeName == name):
+            return childnode
+    return None
+
+def find_first_child_node_content(node, name):
+    childnode = find_first_child_node(node, name)
+    if childnode is None:
+        return None
+    return get_node_content(childnode)
+
 def get_branch(node, repositories, default_repo, config):
     """Scan for a <branch> element and create a corresponding Branch object."""
     name = node.getAttribute('id')
-    for childnode in node.childNodes:
-        if (childnode.nodeType == childnode.ELEMENT_NODE and
-            childnode.nodeName == 'branch'):
-            break
-    else:
+    childnode = find_first_child_node(node, 'branch')
+    if childnode is None:
         raise FatalError(_('no <branch> element found for %s') % name)
 
     # look up the repository for this branch ...
@@ -126,12 +144,13 @@ class Package:
     type = 'base'
     PHASE_START = 'start'
     PHASE_DONE  = 'done'
-    def __init__(self, name, branch=None, dependencies = [], after = [], suggests = []):
+    def __init__(self, name, branch=None, dependencies = [], after = [], suggests = [], pkg_config=None):
         self.name = name
         self.branch = branch
         self.dependencies = dependencies
         self.after = after
         self.suggests = suggests
+        self.pkg_config = pkg_config
         self.tags = []
         self.moduleset_name = None
         self.supports_install_destdir = False
@@ -371,6 +390,9 @@ them into the prefix."""
         instance = cls(name)
         instance.branch = get_branch(node, repositories, default_repo, config)
         instance.dependencies, instance.after, instance.suggests = get_dependencies(node)
+        pkg_config = find_first_child_node_content(node, 'pkg-config')
+        if pkg_config != '':
+            instance.pkg_config = pkg_config
         return instance
 
 class DownloadableModule:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]