Skip to contentSkip to conversation

Hob: Bug fixes

GIT PULL In review Dongxiao Xu 2 participants 6 messages Apr 12, 2012 – Apr 13, 2012

lore
Share & tools
lore
#0 lore raw

Hi Richard,

This pull request integrates your PoC into Hob. Please help to review and pull.

Thanks,
Dongxiao

The following changes since commit 3c2808b67384e92601cbd66877c36ca40df7c7ba:

Hob: fix the missing functions (2012-04-12 15:56:42 +0100)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib dxu4/hob-bugfix
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=dxu4/hob-bugfix

Dongxiao Xu (3):
command.py: Add a hook for config parsing
Hob: Implement Hob config parse hook
Hob: A minor fix on tooltip

 lib/bb/command.py                    |    7 +++++++
 lib/bb/parse/parse_py/ConfHandler.py |    5 +++++
 lib/bb/ui/crumbs/builder.py          |   26 ++++++++++++++++++++++++++
 lib/bb/ui/crumbs/hig.py              |    2 +-
 lib/bb/ui/crumbs/hobeventhandler.py  |   26 ++++++++++++++------------
 5 files changed, 53 insertions(+), 13 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/3 command.py: Add a hook for config parsing

To make the UI settings take effect, we need to hook at the end of each config file parsing and set UI specific values.

---
 lib/bb/command.py                    |    7 +++++++
 lib/bb/parse/parse_py/ConfHandler.py |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)
lib/bb/command.py +7 -0
index 73aaca0..fd8912a 100644
@@ -179,6 +179,13 @@ class CommandsSync:
         """
         return bb.utils.cpu_count()
 
+    def setConfFilter(self, command, params):
+        """
+        Set the configuration file parsing filter
+        """
+        filterfunc = params[0]
+        bb.parse.parse_py.ConfHandler.confFilters.append(filterfunc)
+
 class CommandsAsync:
     """
     A class of asynchronous commands
lib/bb/parse/parse_py/ConfHandler.py +5 -0
index fa811f3..f108c24 100644
@@ -71,6 +71,8 @@ def include(oldfn, fn, lineno, data, error_out):
             raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), oldfn, lineno)
         logger.debug(2, "CONF file '%s' not found", fn)
 
+confFilters = []
+
 def handle(fn, data, include):
     init(data)
 
@@ -107,6 +109,9 @@ def handle(fn, data, include):
     if oldfile:
         data.setVar('FILE', oldfile)
 
+    for f in confFilters:
+        f(fn, data)
+
     return data
 
 def feeder(lineno, s, fn, statements):
Signature · 1 line
1.7.4.1
#2 lore raw

Re: [PATCH 1/3] command.py: Add a hook for config parsing

Quoted 42 lines · Dongxiao Xu

To make the UI settings take effect, we need to hook at the end of each config file parsing and set UI specific values.

---
 lib/bb/command.py                    |    7 +++++++
 lib/bb/parse/parse_py/ConfHandler.py |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)
lib/bb/command.py +7 -0
index 73aaca0..fd8912a 100644
@@ -179,6 +179,13 @@ class CommandsSync:
         """
         return bb.utils.cpu_count()
 
+    def setConfFilter(self, command, params):
+        """
+        Set the configuration file parsing filter
+        """
+        filterfunc = params[0]
+        bb.parse.parse_py.ConfHandler.confFilters.append(filterfunc)
+
 class CommandsAsync:
     """
     A class of asynchronous commands
lib/bb/parse/parse_py/ConfHandler.py +2 -0
index fa811f3..f108c24 100644
@@ -71,6 +71,8 @@ def include(oldfn, fn, lineno, data, error_out):
             raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), oldfn, lineno)
         logger.debug(2, "CONF file '%s' not found", fn)
 
+confFilters = []
+
 def handle(fn, data, include):
     init(data)
 

lib/bb/parse/parse_py/ConfHandler.py def handle(fn, data, include): · line 117

Quoted 9 lines
lib/bb/parse/parse_py/ConfHandler.py +3 -0
@@ -107,6 +109,9 @@ def handle(fn, data, include):
     if oldfile:
         data.setVar('FILE', oldfile)
 
+    for f in confFilters:
+        f(fn, data)
+
     return data
 
 def feeder(lineno, s, fn, statements):

I've merged this but I added in a comment block about why we need to do this since its not immediately clear why we need to do something quite this nasty.

Cheers,

Richard

#3 lore raw

PATCH 2/3 Hob: Implement Hob config parse hook

In reply to Dongxiao Xu

To make Hob's specific variable settings take effect, we add a Hob config hook at the end of parsing for each configuration file, and in the hook function, Hob will set its own variables to the data store.

This fixes:
[YOCTO #2210]
[YOCTO #2254]

---
 lib/bb/ui/crumbs/builder.py         |   26 ++++++++++++++++++++++++++
 lib/bb/ui/crumbs/hobeventhandler.py |   26 ++++++++++++++------------
 2 files changed, 40 insertions(+), 12 deletions(-)
lib/bb/ui/crumbs/builder.py +26 -0
index 10b9a77..410ff5f 100755
@@ -210,6 +210,30 @@ class Parameters:
         self.tmpdir = params["tmpdir"]
         self.enable_proxy = False
 
+def hob_conf_filter(fn, data):
+    if fn.endswith("/local.conf"):
+        distro = data.getVar("DISTRO_HOB")
+        if distro:
+            if distro != "defaultsetup":
+                data.setVar("DISTRO", distro)
+            else:
+                data.delVar("DISTRO")
+
+        keys = ["MACHINE_HOB", "SDKMACHINE_HOB", "PACKAGE_CLASSES_HOB", \
+                "BB_NUMBER_THREADS_HOB", "PARALLEL_MAKE_HOB", "DL_DIR_HOB", \
+                "SSTATE_DIR_HOB", "SSTATE_MIRROR_HOB", "INCOMPATIBLE_LICENSE_HOB"]
+        for key in keys:
+            var_hob = data.getVar(key)
+            if var_hob:
+                data.setVar(key.split("_HOB")[0], var_hob)
+        return
+
+    if fn.endswith("/bblayers.conf"):
+        layers = data.getVar("BBLAYERS_HOB")
+        if layers:
+            data.setVar("BBLAYERS", layers)
+        return
+
 class Builder(gtk.Window):
 
     (MACHINE_SELECTION,
@@ -296,6 +320,8 @@ class Builder(gtk.Window):
         self.handler.connect("command-succeeded",        self.handler_command_succeeded_cb)
         self.handler.connect("command-failed",           self.handler_command_failed_cb)
 
+        self.handler.set_config_filter(hob_conf_filter)
+
         self.initiate_new_build_async()
 
     def create_visual_elements(self):
lib/bb/ui/crumbs/hobeventhandler.py +14 -12
index 1a7427a..292d905 100644
@@ -253,43 +253,42 @@ class HobHandler(gobject.GObject):
         self.server.runCommand(["setVariable", "INHERIT", inherits])
 
     def set_bblayers(self, bblayers):
-        self.server.runCommand(["setVariable", "BBLAYERS", " ".join(bblayers)])
+        self.server.runCommand(["setVariable", "BBLAYERS_HOB", " ".join(bblayers)])
 
     def set_machine(self, machine):
         if machine:
-            self.server.runCommand(["setVariable", "MACHINE", machine])
+            self.server.runCommand(["setVariable", "MACHINE_HOB", machine])
 
     def set_sdk_machine(self, sdk_machine):
-        self.server.runCommand(["setVariable", "SDKMACHINE", sdk_machine])
+        self.server.runCommand(["setVariable", "SDKMACHINE_HOB", sdk_machine])
 
     def set_image_fstypes(self, image_fstypes):
         self.server.runCommand(["setVariable", "IMAGE_FSTYPES", image_fstypes])
 
     def set_distro(self, distro):
-        if distro != "defaultsetup":
-            self.server.runCommand(["setVariable", "DISTRO", distro])
+        self.server.runCommand(["setVariable", "DISTRO_HOB", distro])
 
     def set_package_format(self, format):
         package_classes = ""
         for pkgfmt in format.split():
             package_classes += ("package_%s" % pkgfmt + " ")
-        self.server.runCommand(["setVariable", "PACKAGE_CLASSES", package_classes])
+        self.server.runCommand(["setVariable", "PACKAGE_CLASSES_HOB", package_classes])
 
     def set_bbthreads(self, threads):
-        self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", threads])
+        self.server.runCommand(["setVariable", "BB_NUMBER_THREADS_HOB", threads])
 
     def set_pmake(self, threads):
         pmake = "-j %s" % threads
-        self.server.runCommand(["setVariable", "PARALLEL_MAKE", pmake])
+        self.server.runCommand(["setVariable", "PARALLEL_MAKE_HOB", pmake])
 
     def set_dl_dir(self, directory):
-        self.server.runCommand(["setVariable", "DL_DIR", directory])
+        self.server.runCommand(["setVariable", "DL_DIR_HOB", directory])
 
     def set_sstate_dir(self, directory):
-        self.server.runCommand(["setVariable", "SSTATE_DIR", directory])
+        self.server.runCommand(["setVariable", "SSTATE_DIR_HOB", directory])
 
     def set_sstate_mirror(self, url):
-        self.server.runCommand(["setVariable", "SSTATE_MIRROR", url])
+        self.server.runCommand(["setVariable", "SSTATE_MIRROR_HOB", url])
 
     def set_extra_size(self, image_extra_size):
         self.server.runCommand(["setVariable", "IMAGE_ROOTFS_EXTRA_SPACE", str(image_extra_size)])
@@ -298,13 +297,16 @@ class HobHandler(gobject.GObject):
         self.server.runCommand(["setVariable", "IMAGE_ROOTFS_SIZE", str(image_rootfs_size)])
 
     def set_incompatible_license(self, incompat_license):
-        self.server.runCommand(["setVariable", "INCOMPATIBLE_LICENSE", incompat_license])
+        self.server.runCommand(["setVariable", "INCOMPATIBLE_LICENSE_HOB", incompat_license])
 
     def set_extra_config(self, extra_setting):
         for key in extra_setting.keys():
             value = extra_setting[key]
             self.server.runCommand(["setVariable", key, value])
 
+    def set_config_filter(self, config_filter):
+        self.server.runCommand(["setConfFilter", config_filter])
+
     def set_http_proxy(self, http_proxy):
         self.server.runCommand(["setVariable", "http_proxy", http_proxy])
 
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 3/3 Hob: A minor fix on tooltip

In reply to Dongxiao Xu
---
 lib/bb/ui/crumbs/hig.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/bb/ui/crumbs/hig.py +1 -1
index 5cc8a59..b0cfcaf 100644
@@ -392,7 +392,7 @@ class AdvancedSettingDialog (CrumbsDialog):
         j = 1
         for image_type in self.image_types:
             self.image_types_checkbuttons[image_type] = gtk.CheckButton(image_type)
-            self.image_types_checkbuttons[image_type].set_tooltip_text("Build an %s image" % image_type)
+            self.image_types_checkbuttons[image_type].set_tooltip_text("Build a(n) %s image" % image_type)
             table.attach(self.image_types_checkbuttons[image_type], j, j + 4, i, i + 1)
             if image_type in self.configuration.image_fstypes.split():
                 self.image_types_checkbuttons[image_type].set_active(True)
Signature · 1 line
1.7.4.1
#5 lore raw

Re: [PATCH 3/3] Hob: A minor fix on tooltip

Quoted 10 lines · Dongxiao Xu
---
 lib/bb/ui/crumbs/hig.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/bb/ui/crumbs/hig.py +0 -0
index 5cc8a59..b0cfcaf 100644

lib/bb/ui/crumbs/hig.py class AdvancedSettingDialog (CrumbsDialog): · line 398

Quoted 8 lines
lib/bb/ui/crumbs/hig.py +1 -1
@@ -392,7 +392,7 @@ class AdvancedSettingDialog (CrumbsDialog):
         j = 1
         for image_type in self.image_types:
             self.image_types_checkbuttons[image_type] = gtk.CheckButton(image_type)
-            self.image_types_checkbuttons[image_type].set_tooltip_text("Build an %s image" % image_type)
+            self.image_types_checkbuttons[image_type].set_tooltip_text("Build a(n) %s image" % image_type)
             table.attach(self.image_types_checkbuttons[image_type], j, j + 4, i, i + 1)
             if image_type in self.configuration.image_fstypes.split():
                 self.image_types_checkbuttons[image_type].set_active(True)

This change looks rather ugly to me. Whilst we're getting into a minefield of localisation issues, I'd suggest doing:

article = ""
if image_type.startswith(["a", "e", "i", "o", "h"]):
article = "n"
self.image_types_checkbuttons[image_type].set_tooltip_text("Build a%s %s image" % (article, image_type))

Whilst this isn't perfect, it should cover our common image types well enough.

Cheers,

Richard