compile.cc

Go to the documentation of this file.
00001 
00007 /*
00008 Copyright (C) 2002 The Exult Team
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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  *  "Compile" button
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  *  "Halt" button.
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  *  Called when UCC is done.
00065  */
00066 
00067 void Ucc_done
00068   (
00069   int exit_code,
00070   Exec_box *box,      // Box that called this.
00071   gpointer user_data    // Not used.
00072   )
00073   {
00074   if (exit_code == 0)   // Success?
00075     {
00076     ExultStudio::get_instance()->reload_usecode();
00077     box->add_message("Reloaded usecode\n");
00078     }
00079   }
00080 
00081 /*
00082  *  Open the compile window.
00083  */
00084 
00085 void ExultStudio::open_compile_window
00086   (
00087   )
00088   {
00089   if (!compilewin)    // First time?
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  *  Compile.
00104  */
00105 
00106 void ExultStudio::compile
00107   (
00108   bool if_needed      // Means check timestamps.
00109   )
00110   {
00111           // Get source (fixed, for now).
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;     // No source.
00122     }
00123           // ++++++Check timestamps.
00124   open_compile_window();    // Make sure it's open.
00125   const char *argv[8];    // Set up args.
00126   argv[0] = "ucc";    // Program to run.
00127   argv[1] = "-o";     // Specify output.
00128   argv[2] = obj.c_str();
00129   argv[3] = source.c_str(); // What to compile.
00130           // ++++++Which game type (SI/BG)?
00131   argv[4] = 0;      // NULL.
00132   if (!compile_box->exec("ucc", (char **) argv))
00133     EStudio::Alert("Error executing usecode compiler ('ucc')");
00134   }
00135 
00136 /*
00137  *  Halt compilation.
00138  */
00139 
00140 void ExultStudio::halt_compile
00141   (
00142   )
00143   {
00144   if (compile_box)
00145     compile_box->kill_child();
00146   }

Generated on Mon Jul 9 14:42:47 2007 for ExultEngine by  doxygen 1.5.1