toolchain.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/python
  2. # Copyright (c) 2013 Daniele Bartolini, Michele Rossi
  3. # Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  4. #
  5. # Permission is hereby granted, free of charge, to any person
  6. # obtaining a copy of this software and associated documentation
  7. # files (the "Software"), to deal in the Software without
  8. # restriction, including without limitation the rights to use,
  9. # copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the
  11. # Software is furnished to do so, subject to the following
  12. # conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be
  15. # included in all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  19. # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  21. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. # OTHER DEALINGS IN THE SOFTWARE.
  25. import sys
  26. import os
  27. import subprocess
  28. from gi.repository import Gtk
  29. from pycrown import Repository
  30. class Toolchain:
  31. def __init__(self):
  32. self.m_current_platform = "linux"
  33. builder = Gtk.Builder()
  34. builder.add_from_file("ui/toolchain.glade")
  35. builder.connect_signals(self)
  36. self.m_run_button = builder.get_object("run_button")
  37. self.m_project_chooser = builder.get_object("project_chooser")
  38. self.m_window = builder.get_object("window1")
  39. self.m_window.set_title("Crown Toolchain")
  40. self.m_window.show_all()
  41. Gtk.main()
  42. # Callback
  43. def on_delete(self, *args):
  44. Gtk.main_quit(*args)
  45. def on_project_chooser_file_set(self, button):
  46. self.m_run_button.set_sensitive(True)
  47. self.m_root_path = button.get_filename()
  48. def on_platform_combobox_changed(self, combo):
  49. tree_iter = combo.get_active_iter()
  50. if tree_iter != None:
  51. model = combo.get_model()
  52. platform, name = model[tree_iter][:2]
  53. # Sets the current platform name
  54. self.m_current_platform = platform
  55. def on_target_combobox_changed(self, combo):
  56. print("Not implemented.")
  57. def on_run_button_clicked(self, button):
  58. root_path = str(self.m_root_path)
  59. dest_path = root_path + "_" + self.m_current_platform
  60. comp = subprocess.Popen(["python", "resource-compiler.py", str(self.m_root_path), self.m_current_platform])
  61. crown = subprocess.Popen(["../bin/crown-linux", "--root-path", dest_path, "--dev"])
  62. def on_browser_button_clicked(self, button):
  63. browser = subprocess.Popen(["python", "resource-browser.py", str(self.m_root_path)])
  64. def on_console_button_clicked(self, button):
  65. console = subprocess.Popen(["python", "console.py", "localhost"])
  66. #------------------------------------------------------------------------------
  67. def main():
  68. toolchain = Toolchain()
  69. main()