summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/builder.py59
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/imagedetailspage.py72
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 dcc4104262..457cadc77a 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):
1359 1359
1360 return kernel_path 1360 return kernel_path
1361 1361
1362 def show_load_run_script_dialog(self):
1363 dialog = gtk.FileChooserDialog("Select Run Script", self,
1364 gtk.FILE_CHOOSER_ACTION_OPEN)
1365 button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
1366 HobAltButton.style_button(button)
1367 button = dialog.add_button("Select", gtk.RESPONSE_YES)
1368 HobButton.style_button(button)
1369
1370 dialog.set_current_folder(self.parameters.image_addr)
1371
1372 response = dialog.run()
1373 run_script_path = ""
1374 if response == gtk.RESPONSE_YES:
1375 run_script_path = dialog.get_filename()
1376
1377 dialog.destroy()
1378
1379 return run_script_path
1380
1362 def runqemu_image(self, image_name, kernel_name): 1381 def runqemu_image(self, image_name, kernel_name):
1363 if not image_name or not kernel_name: 1382 if not image_name or not kernel_name:
1364 lbl = "<b>Please select %s to launch in QEMU.</b>" % ("a kernel" if image_name else "an image") 1383 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):
1397 dialog.run() 1416 dialog.run()
1398 dialog.destroy() 1417 dialog.destroy()
1399 1418
1419 def run_custom_image(self, image_name, custom_sim_path):
1420 if not image_name or not custom_sim_path:
1421 if not image_name:
1422 lbl = "<b>Please select an image to launch in the custom simulator.</b>"
1423 else:
1424 lbl = "<b>Please select a custom simulator for launching the selected image.</b>"
1425 dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO)
1426 button = dialog.add_button("Close", gtk.RESPONSE_OK)
1427 HobButton.style_button(button)
1428 dialog.run()
1429 dialog.destroy()
1430 return
1431
1432 image_path = os.path.join(self.parameters.image_addr, image_name)
1433
1434 source_env_path = os.path.join(self.parameters.core_base, "oe-init-build-env")
1435 tmp_path = self.parameters.tmpdir
1436 cmdline = bb.ui.crumbs.utils.which_terminal()
1437 if os.path.exists(image_path) and os.path.exists(custom_sim_path) \
1438 and os.path.exists(source_env_path) and os.path.exists(tmp_path) \
1439 and cmdline:
1440 cmdline += "\' bash -c \"export OE_TMPDIR=" + tmp_path + "; "
1441 cmdline += "source " + source_env_path + " " + os.getcwd() + "; "
1442 cmdline += custom_sim_path + " " + image_path + "\"\'"
1443 subprocess.Popen(shlex.split(cmdline))
1444 else:
1445 lbl = "<b>Path error</b>"
1446 msg = "One of your paths is wrong,"
1447 msg = msg + " please make sure the following paths exist:\n"
1448 msg = msg + "image path:" + image_path + "\n"
1449 msg = msg + "custom simulator path:" + custom_sim_path + "\n"
1450 msg = msg + "source environment path:" + source_env_path + "\n"
1451 msg = msg + "tmp path: " + tmp_path + "."
1452 msg = msg + "You may be missing either xterm or vte for terminal services."
1453 dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_ERROR, msg)
1454 button = dialog.add_button("Close", gtk.RESPONSE_OK)
1455 HobButton.style_button(button)
1456 dialog.run()
1457 dialog.destroy()
1458
1400 def show_packages(self): 1459 def show_packages(self):
1401 self.package_details_page.refresh_tables() 1460 self.package_details_page.refresh_tables()
1402 self.switch_page(self.PACKAGE_SELECTION) 1461 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 352e9489fd..32d4854166 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -303,7 +303,7 @@ class ImageDetailsPage (HobPage):
303 i = i + 1 303 i = i + 1
304 self.num_toggled += is_toggled 304 self.num_toggled += is_toggled
305 305
306 is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image) 306 self.is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image)
307 307
308 # Generated image files info 308 # Generated image files info
309 varlist = ["Name: ", "Files created: ", "Directory: "] 309 varlist = ["Name: ", "Files created: ", "Directory: "]
@@ -324,10 +324,23 @@ class ImageDetailsPage (HobPage):
324 self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button, button2=open_log_button) 324 self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button, button2=open_log_button)
325 self.box_group_area.pack_start(self.image_detail, expand=False, fill=True) 325 self.box_group_area.pack_start(self.image_detail, expand=False, fill=True)
326 326
327 # The default script path to run the image (runqemu)
328 self.run_script_path = os.path.join(self.builder.parameters.core_base, "scripts/runqemu")
329 self.run_script_detail = None
330 varlist = ["Run script: "]
331 vallist = []
332 vallist.append(self.run_script_path)
333
334 change_run_script_button = HobAltButton("Change")
335 change_run_script_button.connect("clicked", self.change_run_script_cb)
336 change_run_script_button.set_tooltip_text("Change run script")
337 self.run_script_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=change_run_script_button)
338 self.box_group_area.pack_start(self.run_script_detail, expand=False, fill=True)
339
327 # The default kernel box for the qemu images 340 # The default kernel box for the qemu images
328 self.sel_kernel = "" 341 self.sel_kernel = ""
329 self.kernel_detail = None 342 self.kernel_detail = None
330 if 'qemu' in image_name: 343 if self.test_mach_runnable(image_name):
331 self.sel_kernel = self.get_kernel_file_name() 344 self.sel_kernel = self.get_kernel_file_name()
332 345
333 # varlist = ["Kernel: "] 346 # varlist = ["Kernel: "]
@@ -401,8 +414,10 @@ class ImageDetailsPage (HobPage):
401 self.box_group_area.pack_start(self.details_bottom_buttons, expand=False, fill=False) 414 self.box_group_area.pack_start(self.details_bottom_buttons, expand=False, fill=False)
402 415
403 self.show_all() 416 self.show_all()
404 if self.kernel_detail and (not is_runnable): 417 if self.kernel_detail and (not self.is_runnable):
405 self.kernel_detail.hide() 418 self.kernel_detail.hide()
419 if self.run_script_detail and self.is_runnable:
420 self.run_script_detail.hide()
406 self.image_saved = False 421 self.image_saved = False
407 422
408 def view_files_clicked_cb(self, button, image_addr): 423 def view_files_clicked_cb(self, button, image_addr):
@@ -484,7 +499,9 @@ class ImageDetailsPage (HobPage):
484 if (action_attr == 'run' and primary_action == "Run image") \ 499 if (action_attr == 'run' and primary_action == "Run image") \
485 or (action_attr == 'deploy' and primary_action == "Deploy image"): 500 or (action_attr == 'deploy' and primary_action == "Deploy image"):
486 action_images.append(fileitem) 501 action_images.append(fileitem)
487 502 if (len(action_images) == 0 and primary_action == "Run image"):
503 # if there are no qemu runnable images, let the user choose any of the existing images for custom run
504 action_images = self.image_store
488 # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file. 505 # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
489 # assume that there does not both have 'deploy' and 'runnable' files in the same building result 506 # assume that there does not both have 'deploy' and 'runnable' files in the same building result
490 # in possible as design. 507 # in possible as design.
@@ -499,7 +516,9 @@ class ImageDetailsPage (HobPage):
499 for fileitem in action_images: 516 for fileitem in action_images:
500 sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type']) 517 sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
501 sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn 518 sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
502 sel_btn.set_active(fileitem['is_toggled']) 519 if curr_row == 0:
520 sel_btn.set_active(True)
521 self.toggled_image = fileitem['name']
503 sel_btn.connect('toggled', self.table_selected_cb, fileitem) 522 sel_btn.connect('toggled', self.table_selected_cb, fileitem)
504 if curr_row < 10: 523 if curr_row < 10:
505 table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24) 524 table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24)
@@ -523,13 +542,15 @@ class ImageDetailsPage (HobPage):
523 542
524 if response != gtk.RESPONSE_YES: 543 if response != gtk.RESPONSE_YES:
525 return 544 return
526 545 # perform the primary action on the image selected by the user
527 for fileitem in self.image_store: 546 for fileitem in self.image_store:
528 if fileitem['is_toggled']: 547 if fileitem['name'] == self.toggled_image:
529 if fileitem['action_attr'] == 'run': 548 if (fileitem['action_attr'] == 'run' and primary_action == "Run image"):
530 self.builder.runqemu_image(fileitem['name'], self.sel_kernel) 549 self.builder.runqemu_image(fileitem['name'], self.sel_kernel)
531 elif fileitem['action_attr'] == 'deploy': 550 elif (fileitem['action_attr'] == 'deploy' and primary_action == "Deploy image"):
532 self.builder.deploy_image(fileitem['name']) 551 self.builder.deploy_image(fileitem['name'])
552 elif (primary_action == "Run image"):
553 self.builder.run_custom_image(fileitem['name'], self.run_script_path)
533 554
534 def table_selected_cb(self, tbutton, image): 555 def table_selected_cb(self, tbutton, image):
535 image['is_toggled'] = tbutton.get_active() 556 image['is_toggled'] = tbutton.get_active()
@@ -541,9 +562,14 @@ class ImageDetailsPage (HobPage):
541 if kernel_path and self.kernel_detail: 562 if kernel_path and self.kernel_detail:
542 import os.path 563 import os.path
543 self.sel_kernel = os.path.basename(kernel_path) 564 self.sel_kernel = os.path.basename(kernel_path)
544 markup = self.kernel_detail.format_line("Kernel: ", self.sel_kernel) 565 self.kernel_detail.update_line_widgets("Kernel: ", self.sel_kernel);
545 label = ((self.kernel_detail.get_children()[0]).get_children()[0]).get_children()[0] 566
546 label.set_markup(markup) 567 def change_run_script_cb(self, widget):
568 self.run_script_path = self.builder.show_load_run_script_dialog()
569 if self.run_script_path and self.run_script_detail:
570 import os.path
571 self.sel_run_script = os.path.basename(self.run_script_path)
572 self.run_script_detail.update_line_widgets("Run script: ", self.run_script_path)
547 573
548 def create_bottom_buttons(self, buttonlist, image_name): 574 def create_bottom_buttons(self, buttonlist, image_name):
549 # Create the buttons at the bottom 575 # Create the buttons at the bottom
@@ -566,26 +592,33 @@ class ImageDetailsPage (HobPage):
566 packed = True 592 packed = True
567 593
568 name = "Run image" 594 name = "Run image"
569 if name in buttonlist and self.test_type_runnable(image_name) and self.test_mach_runnable(image_name): 595 if name in buttonlist:
596 name = "Run qemu image"
597 is_runnable = True
598 if not (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)):
599 name = "Run custom image"
600 is_runnable = False
570 if created == True: 601 if created == True:
571 # separator 602 # separator
572 #label = gtk.Label(" or ") 603 #label = gtk.Label(" or ")
573 #self.details_bottom_buttons.pack_end(label, expand=False, fill=False) 604 #self.details_bottom_buttons.pack_end(label, expand=False, fill=False)
574 605
575 # create button "Run image" 606 # create button "Run image"
576 run_button = HobAltButton("Run image") 607 run_button = HobAltButton(name)
577 else: 608 else:
578 # create button "Run image" as the primary button 609 # create button "Run image" as the primary button
579 run_button = HobButton("Run image") 610 run_button = HobButton(name)
580 #run_button.set_size_request(205, 49) 611 #run_button.set_size_request(205, 49)
581 run_button.set_flags(gtk.CAN_DEFAULT) 612 run_button.set_flags(gtk.CAN_DEFAULT)
582 packed = True 613 packed = True
583 run_button.set_tooltip_text("Start up an image with qemu emulator") 614 if is_runnable:
615 run_button.set_tooltip_text("Start up an image with qemu emulator")
616 else:
617 run_button.set_tooltip_text("Start up an image with custom simulator")
584 button_id = run_button.connect("clicked", self.run_button_clicked_cb) 618 button_id = run_button.connect("clicked", self.run_button_clicked_cb)
585 self.button_ids[button_id] = run_button 619 self.button_ids[button_id] = run_button
586 self.details_bottom_buttons.pack_end(run_button, expand=False, fill=False) 620 self.details_bottom_buttons.pack_end(run_button, expand=False, fill=False)
587 created = True 621 created = True
588 is_runnable = True
589 622
590 name = "Save image recipe" 623 name = "Save image recipe"
591 if name in buttonlist and self.builder.recipe_model.is_custom_image(): 624 if name in buttonlist and self.builder.recipe_model.is_custom_image():
@@ -628,7 +661,10 @@ class ImageDetailsPage (HobPage):
628 self.show_builded_images_dialog(None, "Run image") 661 self.show_builded_images_dialog(None, "Run image")
629 self.set_sensitive(True) 662 self.set_sensitive(True)
630 else: 663 else:
631 self.builder.runqemu_image(self.toggled_image, self.sel_kernel) 664 if self.is_runnable:
665 self.builder.runqemu_image(self.toggled_image, self.sel_kernel)
666 else:
667 self.builder.run_custom_image(self.toggled_image, self.run_script_path)
632 668
633 def save_button_clicked_cb(self, button): 669 def save_button_clicked_cb(self, button):
634 topdir = self.builder.get_topdir() 670 topdir = self.builder.get_topdir()