00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029 #include <string>
00030 #include "studio.h"
00031 #include "exult_constants.h"
00032 #include "utils.h"
00033 #include "execbox.h"
00034
00035 using std::cout;
00036 using std::endl;
00037 using std::string;
00038
00039
00040
00041
00042 C_EXPORT void on_compile_btn_clicked
00043 (
00044 GtkButton *btn,
00045 gpointer user_data
00046 )
00047 {
00048 ExultStudio::get_instance()->compile();
00049 }
00050
00051
00052
00053
00054 C_EXPORT void on_halt_compile_btn_clicked
00055 (
00056 GtkButton *btn,
00057 gpointer user_data
00058 )
00059 {
00060 ExultStudio::get_instance()->halt_compile();
00061 }
00062
00063
00064
00065
00066
00067 void Ucc_done
00068 (
00069 int exit_code,
00070 Exec_box *box,
00071 gpointer user_data
00072 )
00073 {
00074 if (exit_code == 0)
00075 {
00076 ExultStudio::get_instance()->reload_usecode();
00077 box->add_message("Reloaded usecode\n");
00078 }
00079 }
00080
00081
00082
00083
00084
00085 void ExultStudio::open_compile_window
00086 (
00087 )
00088 {
00089 if (!compilewin)
00090 {
00091 compilewin = glade_xml_get_widget( app_xml, "compile_win" );
00092 compile_box = new Exec_box(
00093 GTK_TEXT_VIEW(
00094 glade_xml_get_widget(app_xml, "compile_msgs")),
00095 GTK_STATUSBAR(
00096 glade_xml_get_widget(app_xml, "compile_status")),
00097 Ucc_done, 0);
00098 }
00099 gtk_widget_show(compilewin);
00100 }
00101
00102
00103
00104
00105
00106 void ExultStudio::compile
00107 (
00108 bool if_needed
00109 )
00110 {
00111
00112 string source("<PATCH>/usecode.uc");
00113 source = get_system_path(source);
00114 string obj("<PATCH>/usecode");
00115 obj = get_system_path(obj);
00116 if (!U7exists(source))
00117 {
00118 if (!if_needed)
00119 EStudio::Alert("Source '%s' doesn't exist",
00120 source.c_str());
00121 return;
00122 }
00123
00124 open_compile_window();
00125 const char *argv[8];
00126 argv[0] = "ucc";
00127 argv[1] = "-o";
00128 argv[2] = obj.c_str();
00129 argv[3] = source.c_str();
00130
00131 argv[4] = 0;
00132 if (!compile_box->exec("ucc", (char **) argv))
00133 EStudio::Alert("Error executing usecode compiler ('ucc')");
00134 }
00135
00136
00137
00138
00139
00140 void ExultStudio::halt_compile
00141 (
00142 )
00143 {
00144 if (compile_box)
00145 compile_box->kill_child();
00146 }