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>
33 #include "message-manager.h"
35 #include "build_file.h"
40 gchar
*dirname
, *cmd
, *buff
;
43 te
= anjuta_get_current_text_editor ();
46 if (te
->full_filename
== NULL
)
48 anjuta_warning (_("This file has not been saved. Save it first and then build."));
51 if (text_editor_is_saved (te
) == FALSE
)
53 if (text_editor_save_file (te
, TRUE
) == FALSE
)
57 #if 0 /* Skipping dependency check for file */
60 gchar
*ext
, *filename
;
64 filename
= g_strdup (te
->full_filename
);
65 ext
= get_file_extension (filename
);
68 stat (te
->full_filename
, &st1
);
69 flg
= stat (filename
, &st2
);
70 if ((flg
== 0) && (st2
.st_mtime
> st1
.st_mtime
))
73 ("The executable is up-to-date, there is no need to build it again."));
81 anjuta_set_file_properties (te
->full_filename
);
83 command_editor_get_command_file (app
->command_editor
,
88 ("No build command has been specified for this type of file."));
92 dirname
= extract_directory (te
->full_filename
);
94 anjuta_set_execution_dir(dirname
);
97 if (build_execute_command (cmd
) == FALSE
)
102 anjuta_update_app_status (TRUE
, _("Build"));
103 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
104 buff
= g_strdup_printf (_("Building file: %s...\n"), te
->filename
);
105 an_message_manager_append (app
->messages
, buff
, MESSAGE_BUILD
);
106 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
107 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
108 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
113 /* Launching the command */
115 on_build_mesg_arrived (AnjutaLauncher
*launcher
,
116 AnjutaLauncherOutputType output_type
,
117 const gchar
* mesg
, gpointer data
)
119 an_message_manager_append (app
->messages
, mesg
, MESSAGE_BUILD
);
123 on_build_terminated (AnjutaLauncher
*launcher
,
124 gint child_pid
, gint status
, gulong time_taken
,
129 g_signal_handlers_disconnect_by_func (launcher
,
130 G_CALLBACK (on_build_terminated
),
132 buff1
= g_strdup_printf (_("Total time taken: %lu secs\n"), time_taken
);
135 an_message_manager_append (app
->messages
,
136 _("Completed... unsuccessful\n"),
138 if (anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
139 DIALOG_ON_BUILD_COMPLETE
))
140 anjuta_warning (_("Completed... unsuccessful"));
144 an_message_manager_append (app
->messages
,
145 _("Completed... successful\n"),
147 if (anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
148 DIALOG_ON_BUILD_COMPLETE
))
149 anjuta_status (_("Completed... successful"));
151 an_message_manager_append (app
->messages
, buff1
, MESSAGE_BUILD
);
152 if (anjuta_preferences_get_int (ANJUTA_PREFERENCES (app
->preferences
),
153 BEEP_ON_BUILD_COMPLETE
))
156 anjuta_update_app_status (TRUE
, NULL
);
160 build_execute_command (const gchar
*command
)
162 g_signal_connect (G_OBJECT (app
->launcher
), "child-exited",
163 G_CALLBACK (on_build_terminated
), NULL
);
164 return anjuta_launcher_execute (app
->launcher
, command
,
165 on_build_mesg_arrived
, NULL
);