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; +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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Joshua G Lock @ 2016-01-27 14:03 UTC (permalink / raw)
  To: Mirela Rabulea, bitbake-devel
  Cc: Roman, Alexandru CostinX, Voiculescu, BogdanX A

Hi Mirela,

On Thu, 2016-01-21 at 15:52 +0000, Mirela Rabulea wrote:
> 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.

Thanks for taking the time to develop and submit this change.

Whilst Hob is not under active development I'm not aware of a timeline
for removing it from the repository, thus I'd welcome improvements and
bug fixes.

> 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"

I think you meant "and it is qemu-compatible,"?

> - 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.

On an initial look this change looks good, I have a couple of minor
comments on the UI:

FILE_CHOOSER_ACTION_SAVE seems wrong, I think this should use
FILE_CHOOSER_ACTION_OPEN as we only want to select existing files. 

See:
https://developer.gnome.org/pygtk/stable/gtk-constants.html#gtk-filecho
oser-action-constants

Also I think we'd probably want to use something other than "Open" to
confirm selection of the emulator, but that's more of a question for
Belen. Personally I think "Select" or "Choose" makes more sense.

When I ran Hob with your change I noticed the "Run script:" detail is
positioned vertically in the middle of its parent box, the other boxes
in the "Image details" page have their content at the top of the parent
box — could you change that?

When you submit your v2 could you send the patch directly, rather than
as an attachment. This allows us to perform any review in-line in an
email reply.

You can use either the scripts in the openembedded-core repository
(scripts/[create|send]-pull-request) or git send-email directly.

Furthermore as the patch, when ready, will be applied directly to the
bitbake repository it would be useful to improve the commit message in
line with the OpenEmbedded recommendations: 
http://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines

Specifically could you:
* include some detail in the commit message,
perhaps use the reasoning above?
* move the bug ID to the bottom of the
commit message, above the signed-off-by. It should be formatted as:
[YOCTO #8940]
* Fix the typo in the one-line description "Alow" ->
"Allow"

Of course having written this I realise we don't have a good resource
for BitBake contribution guidelines I've filed a bug in the Yocto
Project bugzilla to ensure we develop some guidelines for contributing
to the BitBake repository: 
https://bugzilla.yoctoproject.org/show_bug.cgi?id=9007

Thanks again for submitting this patch, I look forward to seeing v2!

Regards,

Joshua



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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-01-27 14:03 ` Joshua G Lock
@ 2016-02-04 15:22   ` Mirela Rabulea
  2016-02-10 21:10     ` Joshua G Lock
  0 siblings, 1 reply; 11+ messages in thread
From: Mirela Rabulea @ 2016-02-04 15:22 UTC (permalink / raw)
  To: Joshua G Lock, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

[-- Attachment #1: Type: text/plain, Size: 5741 bytes --]

Hi Joshua,
Please see my comments below, prefixed with [M.R.].
Thanks a lot for the review, v2 of the patch is attached (squashed version, sorry, but my git send-email is still not working).

Only the latest changes, for easier review:

From: Mirela Rabulea <mirela.rabulea@nxp.com>
Date: Thu, 4 Feb 2016 16:35:33 +0200
Subject: [PATCH] Allow Hob to run images on a custom simulator, other than
 qemu - changes after review

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

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 80f329a..457cadc 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -1360,11 +1360,11 @@ 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)
+        dialog = gtk.FileChooserDialog("Select Run Script", self,
+                                       gtk.FILE_CHOOSER_ACTION_OPEN)
         button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
         HobAltButton.style_button(button)
-        button = dialog.add_button("Open", gtk.RESPONSE_YES)
+        button = dialog.add_button("Select", gtk.RESPONSE_YES)
         HobButton.style_button(button)
 
         dialog.set_current_folder(self.parameters.image_addr)
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index e73827d..6cce8a1 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -337,7 +337,7 @@ class ImageDetailsPage (HobPage):
         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)
+        self.box_group_area.pack_start(self.run_script_detail, expand=False, fill=True)
 
         # The default kernel box for the qemu images
         self.sel_kernel = ""
-- 
1.9.1

Regards,
Mirela

-----Original Message-----
From: Joshua G Lock [mailto:joshua.g.lock@linux.intel.com] 
Sent: Wednesday, January 27, 2016 4:03 PM
To: Mirela Rabulea <mirela.rabulea@nxp.com>; bitbake-devel@lists.openembedded.org
Cc: Roman, Alexandru CostinX <alexandru.costinx.roman@intel.com>; Voiculescu, BogdanX A <bogdanx.a.voiculescu@intel.com>
Subject: Re: [bitbake-devel] [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu

> I think you meant "and it is qemu-compatible,"?
[M.R.] Yes, my bad. Added a comment to the bug also.


> On an initial look this change looks good, I have a couple of minor comments on the UI:

> FILE_CHOOSER_ACTION_SAVE seems wrong, I think this should use FILE_CHOOSER_ACTION_OPEN as we only want to select existing files. 

> See:
> https://developer.gnome.org/pygtk/stable/gtk-constants.html#gtk-filecho
> oser-action-constants

> Also I think we'd probably want to use something other than "Open" to confirm selection of the emulator, but that's more of a question for Belen. Personally I think "Select" or "Choose" makes more sense.

[M.R.] I agree, I patched show_load_run_script_dialog() with FILE_CHOOSER_ACTION_OPEN and "Select".

> When I ran Hob with your change I noticed the "Run script:" detail is positioned vertically in the middle of its parent box, the other boxes in the "Image details" page have their content at the top of the parent box — could you change that?


[M.R.] All the children in the dialog are added with pack_start(), what varies is the expand=True/False, fill=True/False. I changed for the run script expand=True => False, now it looks as the content is at the top because it is not expanded. I don't see an obvious way to position/center it. 

> When you submit your v2 could you send the patch directly, rather than as an attachment. This allows us to perform any review in-line in an email reply.
[M.R.] I tried to do that, but git send-email in my repo reported status ok, however I never got the email. I'll put the patch by hand in the email, for now (also I'll attach it, in case there's a problem with that).

> You can use either the scripts in the openembedded-core repository
> (scripts/[create|send]-pull-request) or git send-email directly.

> Furthermore as the patch, when ready, will be applied directly to the bitbake repository it would be useful to improve the commit message in line with the OpenEmbedded recommendations: 
> http://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines

> Specifically could you:
> * include some detail in the commit message, perhaps use the reasoning above?
> * move the bug ID to the bottom of the
> commit message, above the signed-off-by. It should be formatted as:
> [YOCTO #8940]
> * Fix the typo in the one-line description "Alow" -> "Allow"

[M.R.] Done. The squashed commit has a detailed message, fixed typo, bug ID as asked.

> Of course having written this I realise we don't have a good resource for BitBake contribution guidelines I've filed a bug in the Yocto Project bugzilla to ensure we develop some guidelines for contributing to the BitBake repository:
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=9007

[M.R.] Good idea, thanks!


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

From c1dc3e248e20b88c2c213373a7fb89251cd23633 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 v2] Allow Hob to run images on a custom simulator, other than
 qemu

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 qemu-compatible, 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

[YOCTO #8940]

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..457cadc 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("Select Run Script", self,
+                                       gtk.FILE_CHOOSER_ACTION_OPEN)
+        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
+        HobAltButton.style_button(button)
+        button = dialog.add_button("Select", 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..6cce8a1 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=False, 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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-02-04 15:22   ` Mirela Rabulea
@ 2016-02-10 21:10     ` Joshua G Lock
  2016-02-11 11:19       ` Mirela Rabulea
  0 siblings, 1 reply; 11+ messages in thread
From: Joshua G Lock @ 2016-02-10 21:10 UTC (permalink / raw)
  To: Mirela Rabulea, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

Hi Mirela,

On Thu, 2016-02-04 at 15:22 +0000, Mirela Rabulea wrote:
> Hi Joshua,
> Please see my comments below, prefixed with [M.R.].
> Thanks a lot for the review, v2 of the patch is attached (squashed
> version, sorry, but my git send-email is still not working).
> 
> Only the latest changes, for easier review:

These changes look good, thanks.

I've tested this patch a couple of ways. If I launch Hob and press
"Images" to load an existing image from somewhere in my filesystem
things seem to work as expected.

However if I build an image (core-image-minimal) for a non-qemu machine
(genericx86-64), once the build is done I can see 'Run custom image'
button (between 'Build new image' and 'Deploy image').

The 'Run script' box indicates that the script is pointing to 'runqemu'
but when I click 'Run custom image' I get a dialogue asking to 'Select
the image file you want to run:' with 'Cancel' and 'Run image' buttons
but nothing listing selectable images (I even tried resizing the
dialogue, to no avail). If I proceed to click 'Run image' button the
'Usb image maker' dialogue is presented.

Regards,

Joshua


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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-02-10 21:10     ` Joshua G Lock
@ 2016-02-11 11:19       ` Mirela Rabulea
  2016-02-12 22:43         ` Mirela Rabulea
  0 siblings, 1 reply; 11+ messages in thread
From: Mirela Rabulea @ 2016-02-11 11:19 UTC (permalink / raw)
  To: Joshua G Lock, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

Hi Joshua

> -----Original Message-----
> From: Joshua G Lock [mailto:joshua.g.lock@linux.intel.com]
> Sent: Wednesday, February 10, 2016 11:11 PM
> To: Mirela Rabulea <mirela.rabulea@nxp.com>; bitbake-
> devel@lists.openembedded.org
> Cc: Roman, Alexandru CostinX <alexandru.costinx.roman@intel.com>;
> Voiculescu, BogdanX A <bogdanx.a.voiculescu@intel.com>; Nicolae
> Manescu <nicu.manescu@nxp.com>; Alexandru Purice
> <alexandru.purice@nxp.com>
> Subject: Re: [bitbake-devel] [PATCH] Fix bug 8940 - Alow Hob to run images
> on a custom simulator, other than qemu
> 
> These changes look good, thanks.
> 

Thanks again for reviewing.

> I've tested this patch a couple of ways. If I launch Hob and press "Images" to
> load an existing image from somewhere in my filesystem things seem to
> work as expected.
> 

This is the way I used it too, at least for the "custom" case.

> However if I build an image (core-image-minimal) for a non-qemu machine
> (genericx86-64), once the build is done I can see 'Run custom image'
> button (between 'Build new image' and 'Deploy image').
> 

I never reached a scenario in which 'Deploy image' button became available, I hope this is ok, I mean run and deploy are not mutually exclusive...

> The 'Run script' box indicates that the script is pointing to 'runqemu'

Yes, this was my intention, although the user should pick-up here his own script, the 'runqemu' is served here as an example to start with.

> but when I click 'Run custom image' I get a dialogue asking to 'Select the
> image file you want to run:' with 'Cancel' and 'Run image' buttons but
> nothing listing selectable images (I even tried resizing the dialogue, to no
> avail). If I proceed to click 'Run image' button the 'Usb image maker'
> dialogue is presented.
> 

That must come from poky\bitbake\lib\bb\ui\crumbs\imagedetailspage.py, show_builded_images_dialog(). I'm not sure how I can reproduce this without waiting a day to build another image, and without some tens of GB which I don't know if I have. I will try it but it will take a while. In the meantime, if you still have the environment, could you add this print in your imagedetailspage.py, it will let us see how many toggled images you have (I suspect is more than 1), and which ones (it shows up in the terminal where hob was started):
            self.image_store.append({'name': image_name,
                                    'type': image_type,
                                    'size': image_size,
                                    'is_toggled': is_toggled,
                                    'action_attr': image_attr,})

            print "image_store.append(image_name=", image_name, " image_type=", image_type, " image_size=", image_size, " is_toggled=", is_toggled, " image_attr=", image_attr, ")" 

Thanks,
Mirela

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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-02-11 11:19       ` Mirela Rabulea
@ 2016-02-12 22:43         ` Mirela Rabulea
  2016-02-14 22:09           ` Mirela Rabulea
  0 siblings, 1 reply; 11+ messages in thread
From: Mirela Rabulea @ 2016-02-12 22:43 UTC (permalink / raw)
  To: Mirela Rabulea, Joshua G Lock, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

[-- Attachment #1: Type: text/plain, Size: 7470 bytes --]

Hi Joshua,
I got my own core-image-minimal for non-qemu machine (genericx86-64) and I can reproduce the same behavior you saw, please see more explaining below.
I have made a v3 patch to fix this, only v3 changes at the end of email, for easier review.
The squashed version of the patch is attached (initial changes+v2+v3), with updated comment:
	"Note: in case there is more than one toggled image (qemu runnable or deployable), when the user clicks the "Run custom image" button, a dialog will be presented, allowing to choose between any of the existing images."

> -----Original Message-----
> From: bitbake-devel-bounces@lists.openembedded.org [mailto:bitbake-
> devel-bounces@lists.openembedded.org] On Behalf Of Mirela Rabulea
> Sent: Thursday, February 11, 2016 1:19 PM
> To: Joshua G Lock <joshua.g.lock@linux.intel.com>; bitbake-
> devel@lists.openembedded.org
> Cc: Nicolae Manescu <nicu.manescu@nxp.com>; Alexandru Purice
> <alexandru.purice@nxp.com>; Roman, Alexandru CostinX
> <alexandru.costinx.roman@intel.com>; Voiculescu, BogdanX A
> <bogdanx.a.voiculescu@intel.com>
> Subject: Re: [bitbake-devel] [PATCH] Fix bug 8940 - Alow Hob to run images
> on a custom simulator, other than qemu
> 
> 
> > but when I click 'Run custom image' I get a dialogue asking to 'Select
> > the image file you want to run:' with 'Cancel' and 'Run image' buttons
> > but nothing listing selectable images (I even tried resizing the
> > dialogue, to no avail). If I proceed to click 'Run image' button the 'Usb
> image maker'
> > dialogue is presented.
> >
> 
> That must come from poky\bitbake\lib\bb\ui\crumbs\imagedetailspage.py,
> show_builded_images_dialog(). I'm not sure how I can reproduce this
> without waiting a day to build another image, and without some tens of GB
> which I don't know if I have. I will try it but it will take a while. In the
> meantime, if you still have the environment, could you add this print in your
> imagedetailspage.py, it will let us see how many toggled images you have (I
> suspect is more than 1), and which ones (it shows up in the terminal where
> hob was started):
>             self.image_store.append({'name': image_name,
>                                     'type': image_type,
>                                     'size': image_size,
>                                     'is_toggled': is_toggled,
>                                     'action_attr': image_attr,})
> 
>             print "image_store.append(image_name=", image_name, "
> image_type=", image_type, " image_size=", image_size, " is_toggled=",
> is_toggled, " image_attr=", image_attr, ")"
> 

So this was happening not only after the image build is done, but also after the same image was loaded. It depends on what types of files are created for the image. In the case of  core-image-minimal/genericx86-64, 4 files were created, 2 of them with the attribute "deploy" and the other 2 nor runnable (qemu way) or deployable. The 2 deployable files got marked as toggled, but since no runnable image was toggled, when the "Run custom image" button was pressed, no available file was presented. This issue was manifesting only when there was more than one toggled image, and I did not see this case with the images I had built so far, so thanks a lot for this testcase. The v3 patch that I made is fixing show_builded_images_dialog(), allowing the user to choose for custom run any of the existing files.


And here's the v3 patch:
From b6534c8b9166c4ba6f005df252cdb7c491fd1ee3 Mon Sep 17 00:00:00 2001
From: Mirela Rabulea <mirela.rabulea@nxp.com>
Date: Fri, 12 Feb 2016 23:37:28 +0200
Subject: [PATCH] Allow Hob to run images on a custom simulator, other than
 qemu - review feedback no. 2 Note: in case there is more than one toggled
 image (qemu runnable or deployable), when the user clicks the "Run custom
 image" button, a dialog will be presented, allowing to choose between any of
 the existing images.

[YOCTO #8940]

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
---
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index 6cce8a1..b22cf80 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -284,8 +284,6 @@ 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
@@ -501,7 +499,9 @@ class ImageDetailsPage (HobPage):
             if  (action_attr == 'run' and primary_action == "Run image") \
              or (action_attr == 'deploy' and primary_action == "Deploy image"):
                 action_images.append(fileitem)
-
+        if  (len(action_images) == 0 and primary_action == "Run image"):
+            # if there are no qemu runnable images, let the user choose any of the existing images for custom run
+            action_images = self.image_store
         # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
         # assume that there does not both have 'deploy' and 'runnable' files in the same building result
         # in possible as design.
@@ -516,7 +516,8 @@ class ImageDetailsPage (HobPage):
         for fileitem in action_images:
             sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
             sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
-            sel_btn.set_active(fileitem['is_toggled'])
+            if fileitem['name'] == self.toggled_image:
+                sel_btn.set_active(True)
             sel_btn.connect('toggled', self.table_selected_cb, fileitem)
             if curr_row < 10:
                 table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24)
@@ -540,15 +541,15 @@ class ImageDetailsPage (HobPage):
 
         if response != gtk.RESPONSE_YES:
             return
-
+        # perform the primary action on the image selected by the user
         for fileitem in self.image_store:
-            if fileitem['is_toggled']:
-                if fileitem['action_attr'] == 'run':
+            if fileitem['name'] == self.toggled_image:
+                if (fileitem['action_attr'] == 'run' and primary_action == "Run image"):
                     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':
+                elif (fileitem['action_attr'] == 'deploy' and primary_action == "Deploy image"):
                     self.builder.deploy_image(fileitem['name'])
+                elif (primary_action == "Run image"):
+                    self.builder.run_custom_image(fileitem['name'], self.run_script_path)
 
     def table_selected_cb(self, tbutton, image):
         image['is_toggled'] = tbutton.get_active()
-- 
1.9.1



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

From f1d231d2cf88e5bf70798acfc7871494a3079d59 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 v3] Allow Hob to run images on a custom simulator, other than
 qemu

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 qemu-compatible, 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

Note: in case there is more than one toggled image (qemu runnable or deployable), when the user clicks the "Run custom image" button, a dialog will be presented, allowing to choose between any of the existing images.

[YOCTO #8940]

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

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index dcc4104..457cadc 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("Select Run Script", self,
+                                       gtk.FILE_CHOOSER_ACTION_OPEN)
+        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
+        HobAltButton.style_button(button)
+        button = dialog.add_button("Select", 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..b22cf80 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -303,7 +303,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 +324,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=False, 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 +414,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):
@@ -484,7 +499,9 @@ class ImageDetailsPage (HobPage):
             if  (action_attr == 'run' and primary_action == "Run image") \
              or (action_attr == 'deploy' and primary_action == "Deploy image"):
                 action_images.append(fileitem)
-
+        if  (len(action_images) == 0 and primary_action == "Run image"):
+            # if there are no qemu runnable images, let the user choose any of the existing images for custom run
+            action_images = self.image_store
         # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
         # assume that there does not both have 'deploy' and 'runnable' files in the same building result
         # in possible as design.
@@ -499,7 +516,8 @@ class ImageDetailsPage (HobPage):
         for fileitem in action_images:
             sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
             sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
-            sel_btn.set_active(fileitem['is_toggled'])
+            if fileitem['name'] == self.toggled_image:
+                sel_btn.set_active(True)
             sel_btn.connect('toggled', self.table_selected_cb, fileitem)
             if curr_row < 10:
                 table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24)
@@ -523,13 +541,15 @@ class ImageDetailsPage (HobPage):
 
         if response != gtk.RESPONSE_YES:
             return
-
+        # perform the primary action on the image selected by the user
         for fileitem in self.image_store:
-            if fileitem['is_toggled']:
-                if fileitem['action_attr'] == 'run':
+            if fileitem['name'] == self.toggled_image:
+                if (fileitem['action_attr'] == 'run' and primary_action == "Run image"):
                     self.builder.runqemu_image(fileitem['name'], self.sel_kernel)
-                elif fileitem['action_attr'] == 'deploy':
+                elif (fileitem['action_attr'] == 'deploy' and primary_action == "Deploy image"):
                     self.builder.deploy_image(fileitem['name'])
+                elif (primary_action == "Run image"):
+                    self.builder.run_custom_image(fileitem['name'], self.run_script_path)
 
     def table_selected_cb(self, tbutton, image):
         image['is_toggled'] = tbutton.get_active()
@@ -541,9 +561,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 +591,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 +660,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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-02-12 22:43         ` Mirela Rabulea
@ 2016-02-14 22:09           ` Mirela Rabulea
  2016-02-15 16:54             ` Joshua G Lock
  2016-02-16 16:07             ` Joshua G Lock
  0 siblings, 2 replies; 11+ messages in thread
From: Mirela Rabulea @ 2016-02-14 22:09 UTC (permalink / raw)
  To: Joshua G Lock, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

[-- Attachment #1: Type: text/plain, Size: 10279 bytes --]

Hi Joshua,
I found one more issue with a corner case when commuting from "Run custom image" to "Deploy image". From the comments I found in the code, the case when there are both "runnable" and "deployable" present in the same build is not expected.
However, with the introduction of the "Run custom", I think this requires a fix, so here is the v4 of the patch (squashed version attached).
If you did not get to check the v3 patch, you may skip it and check the v4.

Only the v4 fix:
From 4e6c941d74a7b1e11fbd26085a6908b746f61536 Mon Sep 17 00:00:00 2001
From: Mirela Rabulea <mirela.rabulea@nxp.com>
Date: Sun, 14 Feb 2016 23:42:32 +0200
Subject: [PATCH] Allow Hob to run images on a custom simulator, other than
 qemu Fixed bug when commuting from deploy image to run custom image.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
---
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index b22cf80..32d4854 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -516,8 +516,9 @@ class ImageDetailsPage (HobPage):
         for fileitem in action_images:
             sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
             sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
-            if fileitem['name'] == self.toggled_image:
+            if curr_row == 0:
                 sel_btn.set_active(True)
+                self.toggled_image = fileitem['name']
             sel_btn.connect('toggled', self.table_selected_cb, fileitem)
             if curr_row < 10:
                 table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24)
-- 
1.9.1


> -----Original Message-----
> From: Mirela Rabulea
> Sent: Saturday, February 13, 2016 12:44 AM
> To: Mirela Rabulea <mirela.rabulea@nxp.com>; Joshua G Lock
> <joshua.g.lock@linux.intel.com>; bitbake-devel@lists.openembedded.org
> Cc: Nicolae Manescu <nicu.manescu@nxp.com>; Alexandru Purice
> <alexandru.purice@nxp.com>; Roman, Alexandru CostinX
> <alexandru.costinx.roman@intel.com>; Voiculescu, BogdanX A
> <bogdanx.a.voiculescu@intel.com>; Barros Pena, Belen
> <belen.barros.pena@intel.com>
> Subject: RE: [bitbake-devel] [PATCH] Fix bug 8940 - Alow Hob to run images
> on a custom simulator, other than qemu
> 
> Hi Joshua,
> I got my own core-image-minimal for non-qemu machine (genericx86-64)
> and I can reproduce the same behavior you saw, please see more explaining
> below.
> I have made a v3 patch to fix this, only v3 changes at the end of email, for
> easier review.
> The squashed version of the patch is attached (initial changes+v2+v3), with
> updated comment:
> 	"Note: in case there is more than one toggled image (qemu runnable
> or deployable), when the user clicks the "Run custom image" button, a dialog
> will be presented, allowing to choose between any of the existing images."
> 
> > -----Original Message-----
> > From: bitbake-devel-bounces@lists.openembedded.org [mailto:bitbake-
> > devel-bounces@lists.openembedded.org] On Behalf Of Mirela Rabulea
> > Sent: Thursday, February 11, 2016 1:19 PM
> > To: Joshua G Lock <joshua.g.lock@linux.intel.com>; bitbake-
> > devel@lists.openembedded.org
> > Cc: Nicolae Manescu <nicu.manescu@nxp.com>; Alexandru Purice
> > <alexandru.purice@nxp.com>; Roman, Alexandru CostinX
> > <alexandru.costinx.roman@intel.com>; Voiculescu, BogdanX A
> > <bogdanx.a.voiculescu@intel.com>
> > Subject: Re: [bitbake-devel] [PATCH] Fix bug 8940 - Alow Hob to run
> > images on a custom simulator, other than qemu
> >
> >
> > > but when I click 'Run custom image' I get a dialogue asking to
> > > 'Select the image file you want to run:' with 'Cancel' and 'Run
> > > image' buttons but nothing listing selectable images (I even tried
> > > resizing the dialogue, to no avail). If I proceed to click 'Run
> > > image' button the 'Usb
> > image maker'
> > > dialogue is presented.
> > >
> >
> > That must come from poky\bitbake\lib\bb\ui\crumbs\imagedetailspage.py,
> > show_builded_images_dialog(). I'm not sure how I can reproduce this
> > without waiting a day to build another image, and without some tens of
> > GB which I don't know if I have. I will try it but it will take a
> > while. In the meantime, if you still have the environment, could you
> > add this print in your imagedetailspage.py, it will let us see how
> > many toggled images you have (I suspect is more than 1), and which
> > ones (it shows up in the terminal where hob was started):
> >             self.image_store.append({'name': image_name,
> >                                     'type': image_type,
> >                                     'size': image_size,
> >                                     'is_toggled': is_toggled,
> >                                     'action_attr': image_attr,})
> >
> >             print "image_store.append(image_name=", image_name, "
> > image_type=", image_type, " image_size=", image_size, " is_toggled=",
> > is_toggled, " image_attr=", image_attr, ")"
> >
> 
> So this was happening not only after the image build is done, but also after
> the same image was loaded. It depends on what types of files are created for
> the image. In the case of  core-image-minimal/genericx86-64, 4 files were
> created, 2 of them with the attribute "deploy" and the other 2 nor runnable
> (qemu way) or deployable. The 2 deployable files got marked as toggled, but
> since no runnable image was toggled, when the "Run custom image" button
> was pressed, no available file was presented. This issue was manifesting only
> when there was more than one toggled image, and I did not see this case
> with the images I had built so far, so thanks a lot for this testcase. The v3
> patch that I made is fixing show_builded_images_dialog(), allowing the user
> to choose for custom run any of the existing files.
> 
> 
> And here's the v3 patch:
> From b6534c8b9166c4ba6f005df252cdb7c491fd1ee3 Mon Sep 17 00:00:00
> 2001
> From: Mirela Rabulea <mirela.rabulea@nxp.com>
> Date: Fri, 12 Feb 2016 23:37:28 +0200
> Subject: [PATCH] Allow Hob to run images on a custom simulator, other than
> qemu - review feedback no. 2 Note: in case there is more than one toggled
> image (qemu runnable or deployable), when the user clicks the "Run custom
> image" button, a dialog will be presented, allowing to choose between any
> of  the existing images.
> 
> [YOCTO #8940]
> 
> Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> ---
>  bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> index 6cce8a1..b22cf80 100755
> --- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> +++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> @@ -284,8 +284,6 @@ 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 @@ -501,7 +499,9 @@ class
> ImageDetailsPage (HobPage):
>              if  (action_attr == 'run' and primary_action == "Run image") \
>               or (action_attr == 'deploy' and primary_action == "Deploy image"):
>                  action_images.append(fileitem)
> -
> +        if  (len(action_images) == 0 and primary_action == "Run image"):
> +            # if there are no qemu runnable images, let the user choose any of
> the existing images for custom run
> +            action_images = self.image_store
>          # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there
> has no more than one file.
>          # assume that there does not both have 'deploy' and 'runnable' files in
> the same building result
>          # in possible as design.
> @@ -516,7 +516,8 @@ class ImageDetailsPage (HobPage):
>          for fileitem in action_images:
>              sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
>              sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
> -            sel_btn.set_active(fileitem['is_toggled'])
> +            if fileitem['name'] == self.toggled_image:
> +                sel_btn.set_active(True)
>              sel_btn.connect('toggled', self.table_selected_cb, fileitem)
>              if curr_row < 10:
>                  table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24)
> @@ -540,15 +541,15 @@ class ImageDetailsPage (HobPage):
> 
>          if response != gtk.RESPONSE_YES:
>              return
> -
> +        # perform the primary action on the image selected by the user
>          for fileitem in self.image_store:
> -            if fileitem['is_toggled']:
> -                if fileitem['action_attr'] == 'run':
> +            if fileitem['name'] == self.toggled_image:
> +                if (fileitem['action_attr'] == 'run' and primary_action == "Run
> image"):
>                      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':
> +                elif (fileitem['action_attr'] == 'deploy' and primary_action ==
> "Deploy image"):
>                      self.builder.deploy_image(fileitem['name'])
> +                elif (primary_action == "Run image"):
> +                    self.builder.run_custom_image(fileitem['name'],
> + self.run_script_path)
> 
>      def table_selected_cb(self, tbutton, image):
>          image['is_toggled'] = tbutton.get_active()
> --
> 1.9.1
> 


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

From 08b69a576aeee8d0f983c9c6e8c9553d264349ce 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 v4] Allow Hob to run images on a custom simulator, other than
 qemu

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 qemu-compatible, 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

Note: in case there is more than one toggled image (qemu runnable or deployable), when the user clicks the "Run custom image" button, a dialog will be presented, allowing to choose between any of the existing images.

[YOCTO #8940]

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

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index dcc4104..457cadc 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("Select Run Script", self,
+                                       gtk.FILE_CHOOSER_ACTION_OPEN)
+        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
+        HobAltButton.style_button(button)
+        button = dialog.add_button("Select", 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..32d4854 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -303,7 +303,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 +324,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=False, 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 +414,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):
@@ -484,7 +499,9 @@ class ImageDetailsPage (HobPage):
             if  (action_attr == 'run' and primary_action == "Run image") \
              or (action_attr == 'deploy' and primary_action == "Deploy image"):
                 action_images.append(fileitem)
-
+        if  (len(action_images) == 0 and primary_action == "Run image"):
+            # if there are no qemu runnable images, let the user choose any of the existing images for custom run
+            action_images = self.image_store
         # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
         # assume that there does not both have 'deploy' and 'runnable' files in the same building result
         # in possible as design.
@@ -499,7 +516,9 @@ class ImageDetailsPage (HobPage):
         for fileitem in action_images:
             sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
             sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
-            sel_btn.set_active(fileitem['is_toggled'])
+            if curr_row == 0:
+                sel_btn.set_active(True)
+                self.toggled_image = fileitem['name']
             sel_btn.connect('toggled', self.table_selected_cb, fileitem)
             if curr_row < 10:
                 table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24)
@@ -523,13 +542,15 @@ class ImageDetailsPage (HobPage):
 
         if response != gtk.RESPONSE_YES:
             return
-
+        # perform the primary action on the image selected by the user
         for fileitem in self.image_store:
-            if fileitem['is_toggled']:
-                if fileitem['action_attr'] == 'run':
+            if fileitem['name'] == self.toggled_image:
+                if (fileitem['action_attr'] == 'run' and primary_action == "Run image"):
                     self.builder.runqemu_image(fileitem['name'], self.sel_kernel)
-                elif fileitem['action_attr'] == 'deploy':
+                elif (fileitem['action_attr'] == 'deploy' and primary_action == "Deploy image"):
                     self.builder.deploy_image(fileitem['name'])
+                elif (primary_action == "Run image"):
+                    self.builder.run_custom_image(fileitem['name'], self.run_script_path)
 
     def table_selected_cb(self, tbutton, image):
         image['is_toggled'] = tbutton.get_active()
@@ -541,9 +562,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 +592,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 +661,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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  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
  1 sibling, 1 reply; 11+ messages in thread
From: Joshua G Lock @ 2016-02-15 16:54 UTC (permalink / raw)
  To: Mirela Rabulea, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

On Sun, 2016-02-14 at 22:09 +0000, Mirela Rabulea wrote:
> Hi Joshua,
> I found one more issue with a corner case when commuting from "Run
> custom image" to "Deploy image". From the comments I found in the
> code, the case when there are both "runnable" and "deployable"
> present in the same build is not expected.
> However, with the introduction of the "Run custom", I think this
> requires a fix, so here is the v4 of the patch (squashed version
> attached).
> If you did not get to check the v3 patch, you may skip it and check
> the v4.

With this patch applied I'm still seeing the same behaviour — after
building core-image-minimal for genericx86-64 runqemu is displayed as
the run script but clicking on "Run custom image" launches the "Usb
image maker".

Regards,

Joshua

> Only the v4 fix:
> From 4e6c941d74a7b1e11fbd26085a6908b746f61536 Mon Sep 17 00:00:00
> 2001
> From: Mirela Rabulea <mirela.rabulea@nxp.com>
> Date: Sun, 14 Feb 2016 23:42:32 +0200
> Subject: [PATCH] Allow Hob to run images on a custom simulator, other
> than
>  qemu Fixed bug when commuting from deploy image to run custom image.
> 
> Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> ---
>  bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> index b22cf80..32d4854 100755
> --- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> +++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
> @@ -516,8 +516,9 @@ class ImageDetailsPage (HobPage):
>          for fileitem in action_images:
>              sel_btn = gtk.RadioButton(sel_parent_btn,
> fileitem['type'])
>              sel_parent_btn = sel_btn if not sel_parent_btn else
> sel_parent_btn
> -            if fileitem['name'] == self.toggled_image:
> +            if curr_row == 0:
>                  sel_btn.set_active(True)
> +                self.toggled_image = fileitem['name']
>              sel_btn.connect('toggled', self.table_selected_cb,
> fileitem)
>              if curr_row < 10:
>                  table.attach(sel_btn, 0, 4, curr_row, curr_row + 1,
> xpadding=24)


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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-02-15 16:54             ` Joshua G Lock
@ 2016-02-15 16:59               ` Joshua G Lock
  0 siblings, 0 replies; 11+ messages in thread
From: Joshua G Lock @ 2016-02-15 16:59 UTC (permalink / raw)
  To: Mirela Rabulea, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

On Mon, 2016-02-15 at 16:54 +0000, Joshua G Lock wrote:
> On Sun, 2016-02-14 at 22:09 +0000, Mirela Rabulea wrote:
> > Hi Joshua,
> > I found one more issue with a corner case when commuting from "Run
> > custom image" to "Deploy image". From the comments I found in the
> > code, the case when there are both "runnable" and "deployable"
> > present in the same build is not expected.
> > However, with the introduction of the "Run custom", I think this
> > requires a fix, so here is the v4 of the patch (squashed version
> > attached).
> > If you did not get to check the v3 patch, you may skip it and check
> > the v4.
> 
> With this patch applied I'm still seeing the same behaviour — after
> building core-image-minimal for genericx86-64 runqemu is displayed as
> the run script but clicking on "Run custom image" launches the "Usb
> image maker".

Whoops, no I'm not — I was still running an older version of the patch.

I'll take a proper look at v4 tomorrow.

Apologies for the noise,

Joshua


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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-02-14 22:09           ` Mirela Rabulea
  2016-02-15 16:54             ` Joshua G Lock
@ 2016-02-16 16:07             ` Joshua G Lock
  2016-02-16 22:09               ` Mirela Rabulea
  1 sibling, 1 reply; 11+ messages in thread
From: Joshua G Lock @ 2016-02-16 16:07 UTC (permalink / raw)
  To: Mirela Rabulea, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

Hi Mirela,

On Sun, 2016-02-14 at 22:09 +0000, Mirela Rabulea wrote:
> Hi Joshua,
> I found one more issue with a corner case when commuting from "Run
> custom image" to "Deploy image". From the comments I found in the
> code, the case when there are both "runnable" and "deployable"
> present in the same build is not expected.
> However, with the introduction of the "Run custom", I think this
> requires a fix, so here is the v4 of the patch (squashed version
> attached).
> If you did not get to check the v3 patch, you may skip it and check
> the v4.

This version seems to work much better, thanks.

I've had another look over the patch and it looks OK to me. The only
thing which seems a little strange is that in several parts of the
patch you're accessing and setting a self.is_runnable property but at
Ln 217, Ln 220 & Ln 237 in ImageDetailsPage you're using a local
variable called is_runnable — is that correct/intended?

Thanks for your work on this,

Joshua


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

* Re: [PATCH] Fix bug 8940 - Alow Hob to run images on a custom simulator, other than qemu
  2016-02-16 16:07             ` Joshua G Lock
@ 2016-02-16 22:09               ` Mirela Rabulea
  0 siblings, 0 replies; 11+ messages in thread
From: Mirela Rabulea @ 2016-02-16 22:09 UTC (permalink / raw)
  To: Joshua G Lock, bitbake-devel
  Cc: Nicolae Manescu, Alexandru Purice, Roman, Alexandru CostinX,
	Voiculescu, BogdanX A

Hi Joshua,

> -----Original Message-----
> From: Joshua G Lock [mailto:joshua.g.lock@linux.intel.com]
> Sent: Tuesday, February 16, 2016 6:07 PM

> 
> This version seems to work much better, thanks.
> 
> I've had another look over the patch and it looks OK to me. The only thing
> which seems a little strange is that in several parts of the patch you're
> accessing and setting a self.is_runnable property but at Ln 217, Ln 220 & Ln
> 237 in ImageDetailsPage you're using a local variable called is_runnable — is
> that correct/intended?
> 

The local variable "is_runnable" was used in create_bottom_buttons(), I did not change this. I just saved the return value of create_bottom_buttons() in self.is_runnable property, instead of another local, so that I can use the property later, like in run_button_clicked_cb(). This was my intention.

Thanks,
Mirela

^ permalink raw reply	[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.