All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
@ 2016-01-21 15:52 Mirela Rabulea
  2016-01-27 14:03 ` Joshua G Lock
  0 siblings, 1 reply; 11+ messages in thread
From: Mirela Rabulea @ 2016-01-21 15:52 UTC (permalink / raw)
  To: bitbake-devel@lists.openembedded.org
  Cc: Roman, Alexandru CostinX, Voiculescu, BogdanX A


[-- Attachment #1.1.1: Type: text/plain, Size: 1304 bytes --]

Hi,
I have been told that Hob is deprecated and to be replaced by Toaster, still I have some changes already made on Hob, which I would like to push. Besides that, I understand that at this moment Toaster cannot run images at all, via a button push.
I would be happy if these changes make it into YP 2.1, M2 or at least M3.

The current behavior of Hob is that there is a "Run Image" button which becomes visible only for qemu images.

My suggested change is:
- if an image is selected and it is , let the "Run image" button be named "Run qemu image"
- if an image is selected and it is not qemu-compatible, let the same button show up with the name "Run custom image", and besides that, an option shows-up to allow the selection of the custom script (by default it points out to runqemu script) to be used for launching this custom image

Associated bug:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8940

Related bug (feaure request):
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8959


Thanks Belen, Bogdan and Alexandru for helping me on this.


Regards,

Mirela Rabulea
Simulation Software Engineer
NXP Semiconductors
Phone: +40-21-3052420
Mobile: +40-723-362518
Mirela.Rabulea@nxp.com<mailto:Mirela.Rabulea@nxp.com>

[cid:image002.png@01D13266.68FC4030]



[-- Attachment #1.1.2: Type: text/html, Size: 5338 bytes --]

[-- Attachment #1.2: image001.png --]
[-- Type: image/png, Size: 182 bytes --]

[-- Attachment #1.3: image002.png --]
[-- Type: image/png, Size: 22041 bytes --]

[-- Attachment #2: bug_8940.patch --]
[-- Type: application/octet-stream, Size: 10937 bytes --]

From 492fbe8b5d94f95c89b922f5ae2f0afbdac5a5aa Mon Sep 17 00:00:00 2001
From: Mirela Rabulea <mirela.rabulea@nxp.com>
Date: Tue, 19 Jan 2016 16:31:38 +0200
Subject: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator,
 other than qemu

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
---
 bitbake/lib/bb/ui/crumbs/builder.py          | 59 ++++++++++++++++++++++++++++
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 58 +++++++++++++++++++++------
 2 files changed, 105 insertions(+), 12 deletions(-)

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index dcc4104..80f329a 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -1359,6 +1359,25 @@ class Builder(gtk.Window):
 
         return kernel_path
 
+    def show_load_run_script_dialog(self):
+        dialog = gtk.FileChooserDialog("Load Run Script", self,
+                                       gtk.FILE_CHOOSER_ACTION_SAVE)
+        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
+        HobAltButton.style_button(button)
+        button = dialog.add_button("Open", gtk.RESPONSE_YES)
+        HobButton.style_button(button)
+
+        dialog.set_current_folder(self.parameters.image_addr)
+
+        response = dialog.run()
+        run_script_path = ""
+        if response == gtk.RESPONSE_YES:
+            run_script_path = dialog.get_filename()
+
+        dialog.destroy()
+
+        return run_script_path
+
     def runqemu_image(self, image_name, kernel_name):
         if not image_name or not kernel_name:
             lbl = "<b>Please select %s to launch in QEMU.</b>" % ("a kernel" if image_name else "an image")
@@ -1397,6 +1416,46 @@ class Builder(gtk.Window):
             dialog.run()
             dialog.destroy()
 
+    def run_custom_image(self, image_name, custom_sim_path):
+        if not image_name or not custom_sim_path:
+            if not image_name:
+                lbl = "<b>Please select an image to launch in the custom simulator.</b>"
+            else:
+                lbl = "<b>Please select a custom simulator for launching the selected image.</b>"
+            dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO)
+            button = dialog.add_button("Close", gtk.RESPONSE_OK)
+            HobButton.style_button(button)
+            dialog.run()
+            dialog.destroy()
+            return
+
+        image_path = os.path.join(self.parameters.image_addr, image_name)
+
+        source_env_path = os.path.join(self.parameters.core_base, "oe-init-build-env")
+        tmp_path = self.parameters.tmpdir
+        cmdline = bb.ui.crumbs.utils.which_terminal()
+        if os.path.exists(image_path) and os.path.exists(custom_sim_path) \
+           and os.path.exists(source_env_path) and os.path.exists(tmp_path) \
+           and cmdline:
+            cmdline += "\' bash -c \"export OE_TMPDIR=" + tmp_path + "; "
+            cmdline += "source " + source_env_path + " " + os.getcwd() + "; "
+            cmdline += custom_sim_path + " " + image_path + "\"\'"
+            subprocess.Popen(shlex.split(cmdline))
+        else:
+            lbl = "<b>Path error</b>"
+            msg = "One of your paths is wrong,"
+            msg = msg + " please make sure the following paths exist:\n"
+            msg = msg + "image path:" + image_path + "\n"
+            msg = msg + "custom simulator path:" + custom_sim_path + "\n"
+            msg = msg + "source environment path:" + source_env_path + "\n"
+            msg = msg + "tmp path: " + tmp_path + "."
+            msg = msg + "You may be missing either xterm or vte for terminal services."
+            dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_ERROR, msg)
+            button = dialog.add_button("Close", gtk.RESPONSE_OK)
+            HobButton.style_button(button)
+            dialog.run()
+            dialog.destroy()
+
     def show_packages(self):
         self.package_details_page.refresh_tables()
         self.switch_page(self.PACKAGE_SELECTION)
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index 352e948..e73827d 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -284,6 +284,8 @@ class ImageDetailsPage (HobPage):
             if not self.toggled_image:
                 if i == (len(image_names) - 1):
                     is_toggled = True
+                    # if there was no qemu runable image, let one image be custom run
+                    image_attr = "run_custom"
                 if is_toggled:
                     default_image_size = image_size
                     self.toggled_image = image_name
@@ -303,7 +305,7 @@ class ImageDetailsPage (HobPage):
             i = i + 1
             self.num_toggled += is_toggled
 
-        is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image)
+        self.is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image)
 
         # Generated image files info
         varlist = ["Name: ", "Files created: ", "Directory: "]
@@ -324,10 +326,23 @@ class ImageDetailsPage (HobPage):
         self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button, button2=open_log_button)
         self.box_group_area.pack_start(self.image_detail, expand=False, fill=True)
 
+        # The default script path to run the image (runqemu)
+        self.run_script_path = os.path.join(self.builder.parameters.core_base, "scripts/runqemu")
+        self.run_script_detail = None
+        varlist = ["Run script: "]
+        vallist = []
+        vallist.append(self.run_script_path)
+
+        change_run_script_button = HobAltButton("Change")
+        change_run_script_button.connect("clicked", self.change_run_script_cb)
+        change_run_script_button.set_tooltip_text("Change run script")
+        self.run_script_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=change_run_script_button)
+        self.box_group_area.pack_start(self.run_script_detail, expand=True, fill=True)
+
         # The default kernel box for the qemu images
         self.sel_kernel = ""
         self.kernel_detail = None
-        if 'qemu' in image_name:
+        if self.test_mach_runnable(image_name):
             self.sel_kernel = self.get_kernel_file_name()
 
         #    varlist = ["Kernel: "]
@@ -401,8 +416,10 @@ class ImageDetailsPage (HobPage):
             self.box_group_area.pack_start(self.details_bottom_buttons, expand=False, fill=False)
 
         self.show_all()
-        if self.kernel_detail and (not is_runnable):
+        if self.kernel_detail and (not self.is_runnable):
             self.kernel_detail.hide()
+        if self.run_script_detail and self.is_runnable:
+            self.run_script_detail.hide()
         self.image_saved = False
 
     def view_files_clicked_cb(self, button, image_addr):
@@ -528,6 +545,8 @@ class ImageDetailsPage (HobPage):
             if fileitem['is_toggled']:
                 if fileitem['action_attr'] == 'run':
                     self.builder.runqemu_image(fileitem['name'], self.sel_kernel)
+                elif fileitem['action_attr'] == 'run_custom':
+                    self.builder.run_custom_image(fileitem['name'], self.run_script_path)
                 elif fileitem['action_attr'] == 'deploy':
                     self.builder.deploy_image(fileitem['name'])
 
@@ -541,9 +560,14 @@ class ImageDetailsPage (HobPage):
         if kernel_path and self.kernel_detail:
             import os.path
             self.sel_kernel = os.path.basename(kernel_path)
-            markup = self.kernel_detail.format_line("Kernel: ", self.sel_kernel)
-            label = ((self.kernel_detail.get_children()[0]).get_children()[0]).get_children()[0]
-            label.set_markup(markup)
+            self.kernel_detail.update_line_widgets("Kernel: ", self.sel_kernel);
+
+    def change_run_script_cb(self, widget):
+        self.run_script_path = self.builder.show_load_run_script_dialog()
+        if self.run_script_path and self.run_script_detail:
+            import os.path
+            self.sel_run_script = os.path.basename(self.run_script_path)
+            self.run_script_detail.update_line_widgets("Run script: ", self.run_script_path)
 
     def create_bottom_buttons(self, buttonlist, image_name):
         # Create the buttons at the bottom
@@ -566,26 +590,33 @@ class ImageDetailsPage (HobPage):
             packed = True
 
         name = "Run image"
-        if name in buttonlist and self.test_type_runnable(image_name) and self.test_mach_runnable(image_name):
+        if name in buttonlist:
+            name = "Run qemu image"
+            is_runnable = True
+            if not (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)):
+                name = "Run custom image"
+                is_runnable = False
             if created == True:
                 # separator
                 #label = gtk.Label(" or ")
                 #self.details_bottom_buttons.pack_end(label, expand=False, fill=False)
 
                 # create button "Run image"
-                run_button = HobAltButton("Run image")
+                run_button = HobAltButton(name)
             else:
                 # create button "Run image" as the primary button
-                run_button = HobButton("Run image")
+                run_button = HobButton(name)
                 #run_button.set_size_request(205, 49)
                 run_button.set_flags(gtk.CAN_DEFAULT)
                 packed = True
-            run_button.set_tooltip_text("Start up an image with qemu emulator")
+            if is_runnable:
+                run_button.set_tooltip_text("Start up an image with qemu emulator")
+            else:
+                run_button.set_tooltip_text("Start up an image with custom simulator")
             button_id = run_button.connect("clicked", self.run_button_clicked_cb)
             self.button_ids[button_id] = run_button
             self.details_bottom_buttons.pack_end(run_button, expand=False, fill=False)
             created = True
-            is_runnable = True
 
         name = "Save image recipe"
         if name in buttonlist and self.builder.recipe_model.is_custom_image():
@@ -628,7 +659,10 @@ class ImageDetailsPage (HobPage):
                 self.show_builded_images_dialog(None, "Run image")
                 self.set_sensitive(True)
             else:
-                self.builder.runqemu_image(self.toggled_image, self.sel_kernel)
+                if self.is_runnable:
+                    self.builder.runqemu_image(self.toggled_image, self.sel_kernel)
+                else:
+                    self.builder.run_custom_image(self.toggled_image, self.run_script_path)
 
     def save_button_clicked_cb(self, button):
         topdir = self.builder.get_topdir()
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-02-16 22:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-21 15:52 [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu Mirela Rabulea
2016-01-27 14:03 ` Joshua G Lock
2016-02-04 15:22   ` Mirela Rabulea
2016-02-10 21:10     ` Joshua G Lock
2016-02-11 11:19       ` Mirela Rabulea
2016-02-12 22:43         ` Mirela Rabulea
2016-02-14 22:09           ` Mirela Rabulea
2016-02-15 16:54             ` Joshua G Lock
2016-02-15 16:59               ` Joshua G Lock
2016-02-16 16:07             ` Joshua G Lock
2016-02-16 22:09               ` Mirela Rabulea

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.