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 compile_file_with_make ()
44 if(app
->project_dbase
->is_saved
== FALSE
45 && app
->project_dbase
->project_is_open
==TRUE
)
48 ret
= project_dbase_save_project(app
->project_dbase
);
53 src_dir
= project_dbase_get_module_dir (app
->project_dbase
, MODULE_SOURCE
);
56 gchar
*prj_name
, *cmd
;
58 cmd
= command_editor_get_command (app
->command_editor
, COMMAND_BUILD_MODULE
);
61 anjuta_warning (_("Unable to build module. Check Settings->Commands."));
66 anjuta_set_execution_dir(src_dir
);
69 if (build_execute_command (cmd
) == FALSE
)
74 anjuta_update_app_status (TRUE
, _("Build Project"));
75 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
76 an_message_manager_append (app
->messages
, _("Building source directory of the Project: "),
78 prj_name
= project_dbase_get_proj_name (app
->project_dbase
);
79 an_message_manager_append (app
->messages
, prj_name
, MESSAGE_BUILD
);
80 an_message_manager_append (app
->messages
, "...\n", MESSAGE_BUILD
);
81 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
82 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
83 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
89 /* Single file build */
97 compile_file (gboolean use_make
)
99 gchar
*dirname
, *cmd
, *buff
;
102 te
= anjuta_get_current_text_editor ();
103 g_return_if_fail (te
!= NULL
);
105 if (te
->full_filename
== NULL
)
107 anjuta_warning (_("This file has not been saved. Save it first and then compile."));
110 if (text_editor_is_saved(te
) == FALSE
)
112 if (text_editor_save_file (te
, TRUE
) == FALSE
)
116 #if 0 /* Skipping dependency check for file */
117 filename
= g_strdup (te
->full_filename
);
118 ext
= get_file_extension (filename
);
124 stat (te
->full_filename
, &st1
);
125 flg
= stat (filename
, &st2
);
126 if ((flg
== 0) && (st2
.st_mtime
> st1
.st_mtime
))
128 anjuta_warning (_("The object file is up-to-date, there is no need to compile it again."));
135 anjuta_set_file_properties (te
->full_filename
);
136 cmd
= command_editor_get_command_file (app
->command_editor
,
137 use_make
?COMMAND_MAKE_FILE
:COMMAND_COMPILE_FILE
, te
->filename
);
140 anjuta_warning (_("No compile command has been specified for this type of file."));
143 dirname
= extract_directory (te
->full_filename
);
145 anjuta_set_execution_dir(dirname
);
148 if (build_execute_command (cmd
) == FALSE
)
153 anjuta_update_app_status (TRUE
, _("Compile"));
154 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
155 buff
= g_strdup_printf (_("Compiling file: %s...\n"), te
->filename
);
156 an_message_manager_append (app
->messages
, buff
, MESSAGE_BUILD
);
157 an_message_manager_append (app
->messages
, cmd
, MESSAGE_BUILD
);
158 an_message_manager_append (app
->messages
, "\n", MESSAGE_BUILD
);
159 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);