3 Copyright (C) 2000 Kh. Naba Kumar Singh
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <sys/types.h>
34 #include "build_file.h"
36 #include "build_project.h"
37 #include "clean_project.h"
40 static void install_as_root (GtkWidget
* button
, gpointer data
);
41 static void install_as_user (GtkWidget
* button
, gpointer data
);
48 if(app
->project_dbase
->is_saved
== FALSE
49 && app
->project_dbase
->project_is_open
==TRUE
)
52 ret
= project_dbase_save_project(app
->project_dbase
);
57 src_dir
= project_dbase_get_module_dir (app
->project_dbase
, MODULE_SOURCE
);
60 gchar
*prj_name
, *cmd
;
62 /* perform a clean, if required before the build */
63 if (app
->project_dbase
->clean_before_build
== TRUE
)
65 cmd
= command_editor_get_command (app
->command_editor
,
66 COMMAND_CLEAN_BUILD_MODULE
);
67 app
->project_dbase
->clean_before_build
= FALSE
;
71 cmd
= command_editor_get_command (app
->command_editor
,
72 COMMAND_BUILD_MODULE
);
76 anjuta_warning (_("Unable to build module. Check Settings->Commands."));
81 anjuta_set_execution_dir(src_dir
);
84 if(anjuta_preferences_get_int(ANJUTA_PREFERENCES (app
->preferences
),
85 BUILD_OPTION_AUTOSAVE
))
87 anjuta_save_all_files();
90 if (build_execute_command (cmd
) == FALSE
)
95 anjuta_update_app_status (TRUE
, _("Build Project"));
96 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
97 an_message_manager_append (app
->messages
, _("Building source directory of the Project: "),
99 prj_name
= project_dbase_get_proj_name (app
->project_dbase
);
100 an_message_manager_append (app
->messages
, prj_name
, MESSAGE_BUILD
);
101 an_message_manager_append (app
->messages
, " ...\n", MESSAGE_BUILD
);
102 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
103 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
104 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
110 /* Single file build */
118 gchar
*cmd
, *prj_name
;
120 if(app
->project_dbase
->is_saved
== FALSE
121 && app
->project_dbase
->project_is_open
==TRUE
)
124 ret
= project_dbase_save_project(app
->project_dbase
);
129 if (app
->project_dbase
->project_is_open
)
131 /* perform a clean, if required before the build */
132 if (app
->project_dbase
->clean_before_build
== TRUE
)
134 cmd
= command_editor_get_command (app
->command_editor
,
135 COMMAND_CLEAN_BUILD_PROJECT
);
136 app
->project_dbase
->clean_before_build
= FALSE
;
140 cmd
= command_editor_get_command (app
->command_editor
,
141 COMMAND_BUILD_PROJECT
);
145 anjuta_warning (_("Unable to build Project. Check Settings->Commands."));
148 chdir (app
->project_dbase
->top_proj_dir
);
149 anjuta_set_execution_dir(app
->project_dbase
->top_proj_dir
);
151 if(anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
152 BUILD_OPTION_AUTOSAVE
))
153 anjuta_save_all_files();
155 if (build_execute_command (cmd
) == FALSE
)
160 anjuta_update_app_status (TRUE
, _("Build Project"));
161 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
162 an_message_manager_append (app
->messages
,
163 _("Building the whole Project: "),
165 prj_name
= project_dbase_get_proj_name (app
->project_dbase
);
166 an_message_manager_append (app
->messages
, prj_name
, MESSAGE_BUILD
);
167 an_message_manager_append (app
->messages
, " ...\n", MESSAGE_BUILD
);
168 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
169 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
170 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
177 build_dist_project ()
179 gchar
*cmd
, *prj_name
;
181 if(app
->project_dbase
->is_saved
== FALSE
182 && app
->project_dbase
->project_is_open
==TRUE
)
185 ret
= project_dbase_save_project(app
->project_dbase
);
190 if (app
->project_dbase
->project_is_open
)
192 cmd
= command_editor_get_command (app
->command_editor
, COMMAND_BUILD_TARBALL
);
196 ("Unable to build tarball. Check Settings->Commands."));
199 chdir (app
->project_dbase
->top_proj_dir
);
200 anjuta_set_execution_dir(app
->project_dbase
->top_proj_dir
);
202 if(anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
203 BUILD_OPTION_AUTOSAVE
))
204 anjuta_save_all_files();
206 if (build_execute_command (cmd
) == FALSE
)
211 anjuta_update_app_status (TRUE
, _("Build Distribution"));
212 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
213 an_message_manager_append (app
->messages
,
215 ("Building the distribution package of the Project: "),
217 prj_name
= project_dbase_get_proj_name (app
->project_dbase
);
218 an_message_manager_append (app
->messages
, prj_name
, MESSAGE_BUILD
);
219 an_message_manager_append (app
->messages
, " ...\n", MESSAGE_BUILD
);
220 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
221 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
222 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
229 build_install_project ()
231 if(app
->project_dbase
->is_saved
== FALSE
232 && app
->project_dbase
->project_is_open
==TRUE
)
235 ret
= project_dbase_save_project(app
->project_dbase
);
240 if (app
->project_dbase
->project_is_open
) {
243 dialog
= gtk_message_dialog_new (GTK_WINDOW (app
),
244 GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT
,
245 GTK_MESSAGE_QUESTION
,
247 _("Do you prefer installing as root ?"));
249 if (gtk_dialog_run (GTK_DIALOG (dialog
)) == GTK_RESPONSE_YES
)
250 install_as_root (NULL
, NULL
);
252 install_as_user (NULL
, NULL
);
253 gtk_widget_destroy(dialog
);
258 build_autogen_project ()
260 gchar
*cmd
, *prj_name
;
262 if(app
->project_dbase
->is_saved
== FALSE
263 && app
->project_dbase
->project_is_open
==TRUE
)
266 ret
= project_dbase_save_project(app
->project_dbase
);
271 if (app
->project_dbase
->project_is_open
)
273 chdir (app
->project_dbase
->top_proj_dir
);
274 anjuta_set_execution_dir(app
->project_dbase
->top_proj_dir
);
275 if (file_is_executable ("./autogen.sh"))
277 cmd
= g_strdup ("./autogen.sh");
281 cmd
= command_editor_get_command (app
->command_editor
, COMMAND_BUILD_AUTOGEN
);
285 ("Unable to auto generate. Check Settings->Commands."));
290 if (anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
291 BUILD_OPTION_AUTOSAVE
))
292 anjuta_save_all_files();
294 if (build_execute_command (cmd
) == FALSE
)
299 anjuta_update_app_status (TRUE
, _("Auto generate Project"));
300 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
301 an_message_manager_append (app
->messages
,
302 _("Auto generating the Project: "),
304 prj_name
= project_dbase_get_proj_name (app
->project_dbase
);
305 an_message_manager_append (app
->messages
, prj_name
, MESSAGE_BUILD
);
306 an_message_manager_append (app
->messages
, " ...\n", MESSAGE_BUILD
);
307 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
308 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
309 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
316 install_as_root (GtkWidget
* button
, gpointer data
)
318 gchar
*cmd
, *build_cmd
, *prj_name
;
319 build_cmd
= command_editor_get_command (app
->command_editor
,
320 COMMAND_BUILD_INSTALL
);
321 if (build_cmd
== NULL
)
324 ("Unable to install Project. Check Settings->Commands."));
327 cmd
= g_strconcat ("su --command='", build_cmd
, "'", NULL
);
330 chdir (app
->project_dbase
->top_proj_dir
);
331 anjuta_set_execution_dir(app
->project_dbase
->top_proj_dir
);
333 if(anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
334 BUILD_OPTION_AUTOSAVE
))
336 anjuta_save_all_files();
339 anjuta_update_app_status (TRUE
, _("Install Project"));
340 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
341 an_message_manager_append (app
->messages
, _("Installing the Project: "),
343 prj_name
= project_dbase_get_proj_name (app
->project_dbase
);
344 an_message_manager_append (app
->messages
, prj_name
, MESSAGE_BUILD
);
345 an_message_manager_append (app
->messages
, " ...\n", MESSAGE_BUILD
);
346 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
347 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
348 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
350 build_execute_command (cmd
);
355 install_as_user (GtkWidget
* button
, gpointer data
)
357 gchar
*cmd
, *prj_name
;
358 cmd
= command_editor_get_command (app
->command_editor
, COMMAND_BUILD_INSTALL
);
362 ("Unable to install Project. Check Settings->Commands."));
365 chdir (app
->project_dbase
->top_proj_dir
);
366 anjuta_set_execution_dir(app
->project_dbase
->top_proj_dir
);
368 if(anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
369 BUILD_OPTION_AUTOSAVE
))
371 anjuta_save_all_files();
374 anjuta_update_app_status (TRUE
, _("Install Project"));
375 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
376 an_message_manager_append (app
->messages
, _("Installing the Project: "),
378 prj_name
= project_dbase_get_proj_name (app
->project_dbase
);
379 an_message_manager_append (app
->messages
, prj_name
, MESSAGE_BUILD
);
380 an_message_manager_append (app
->messages
, " ...\n", MESSAGE_BUILD
);
381 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
382 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
383 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
385 build_execute_command (cmd
);