[anjuta] build-basic-autotools: bgo #674863 - No easy way to call make check



commit f8fed0875d7d2ce149026dcf9d1ada10c0bee98f
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Tue May 1 11:39:05 2012 +0200

    build-basic-autotools: bgo #674863 - No easy way to call make check

 libanjuta/interfaces/libanjuta.idl                 |    2 +
 .../anjuta-build-basic-autotools-plugin.xml        |    4 ++
 plugins/build-basic-autotools/build.c              |   37 +++++++++++++++--
 plugins/build-basic-autotools/build.h              |    6 +++
 plugins/build-basic-autotools/plugin.c             |   43 ++++++++++++++++++++
 5 files changed, 87 insertions(+), 5 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 1fa1aa1..6e4f137 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -863,6 +863,7 @@ interface IAnjutaBuildable
    * @IANJUTA_BUILDABLE_COMMAND_EXECUTE: ./hello
    * @IANJUTA_BUILDABLE_COMMAND_IS_BUILT: check whether object files are up-to-date
    * @IANJUTA_BUILDABLE_COMMAND_DISTCLEAN: make distclean
+   * @IANJUTA_BUILDABLE_COMMAND_CHECK: make check
    * @IANJUTA_BUILDABLE_N_COMMANDS: size of enum
    *
    * The enumeration is used to speficy the disered build operation
@@ -880,6 +881,7 @@ interface IAnjutaBuildable
 		COMMAND_IS_BUILT,
 		COMMAND_AUTORECONF,
 		COMMAND_DISTCLEAN,
+		COMMAND_CHECK,
 		N_COMMANDS
 	}
 
diff --git a/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.xml b/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.xml
index c573657..2b10cbf 100644
--- a/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.xml
+++ b/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.xml
@@ -9,6 +9,9 @@
 				<separator name="separator10"/>
 				<menuitem name="InstallModule" action="ActionBuildInstallModule"/>
 				<menuitem name="InstallProject" action="ActionBuildInstallProject"/>
+				<separator name="separator14"/>
+				<menuitem name="CheckModule" action="ActionBuildCheckModule"/>
+				<menuitem name="CheckProject" action="ActionBuildCheckProject"/>
 				<separator name="separator12"/>
 				<menuitem name="CleanModule" action="ActionBuildCleanModule"/>
 				<menuitem name="CleanProject" action="ActionBuildCleanProject"/>
@@ -43,6 +46,7 @@
 				<menuitem name="Compile" action="ActionPopupPMBuildCompile"/>
 				<menuitem name="Build" action="ActionPopupPMBuildBuild"/>
 				<menuitem name="Install" action="ActionPopupPMBuildInstall"/>
+				<menuitem name="Check" action="ActionPopupPMBuildCheck"/>
 				<menuitem name="Clean" action="ActionPopupPMBuildClean"/>
 			</menu>
 		</placeholder>
diff --git a/plugins/build-basic-autotools/build.c b/plugins/build-basic-autotools/build.c
index 03004bb..e315bb5 100644
--- a/plugins/build-basic-autotools/build.c
+++ b/plugins/build-basic-autotools/build.c
@@ -60,6 +60,7 @@ typedef struct
 #define DEFAULT_COMMAND_GENERATE "autogen.sh"
 #define DEFAULT_COMMAND_CLEAN "make clean"
 #define DEFAULT_COMMAND_DISTCLEAN "make distclean"
+#define DEFAULT_COMMAND_CHECK "make check"
 #define DEFAULT_COMMAND_AUTORECONF "autoreconf -i --force"
 
 #define CHOOSE_COMMAND(plugin,command) \
@@ -602,7 +603,7 @@ build_is_file_built (BasicAutotoolsPlugin *plugin, GFile *file,
 	{
 		return NULL;
 	}
-	
+
 	vars = build_configuration_get_variables (config);
 
 	build_dir = build_file_from_file (plugin, file, &target);
@@ -718,8 +719,8 @@ build_install_dir (BasicAutotoolsPlugin *plugin, GFile *dir,
 
 
 BuildContext*
-build_clean_dir (BasicAutotoolsPlugin *plugin, GFile *file,
-				 GError **err)
+build_clean_dir (BasicAutotoolsPlugin *plugin, GFile *dir,
+                 GError **err)
 {
 	BuildContext *context = NULL;
 	BuildProgram *prog;
@@ -727,12 +728,12 @@ build_clean_dir (BasicAutotoolsPlugin *plugin, GFile *file,
 	BuildConfiguration *config;
 	GList *vars;
 
-	if (is_configured (plugin, file))
+	if (is_configured (plugin, dir))
 	{
 		config = build_configuration_list_get_selected (plugin->configurations);
 		vars = build_configuration_get_variables (config);
 
-		build_dir = build_file_from_file (plugin, file, NULL);
+		build_dir = build_file_from_file (plugin, dir, NULL);
 
 		prog = build_program_new_with_command (build_dir,
 		                                       "%s",
@@ -746,7 +747,33 @@ build_clean_dir (BasicAutotoolsPlugin *plugin, GFile *file,
 	return context;
 }
 
+BuildContext*
+build_check_dir (BasicAutotoolsPlugin *plugin, GFile *dir,
+                 IAnjutaBuilderCallback callback, gpointer user_data,
+				 GError **err)
+{
+	BuildContext *context = NULL;
+	BuildProgram *prog;
+	GFile *build_dir;
+	BuildConfiguration *config;
+	GList *vars;
 
+	config = build_configuration_list_get_selected (plugin->configurations);
+	vars = build_configuration_get_variables (config);
+
+	build_dir = build_file_from_file (plugin, dir, NULL);
+
+	prog = build_program_new_with_command (build_dir,
+	                                       "%s",
+	                                       CHOOSE_COMMAND (plugin, CHECK)),
+	build_program_set_callback (prog, callback, user_data);
+	build_program_add_env_list (prog, vars);
+
+	context = build_execute_command (plugin, prog, TRUE, err);
+	g_object_unref (build_dir);
+
+	return context;
+}
 
 static void
 build_remove_build_dir (GObject *sender,
diff --git a/plugins/build-basic-autotools/build.h b/plugins/build-basic-autotools/build.h
index ee340e3..44b20c1 100644
--- a/plugins/build-basic-autotools/build.h
+++ b/plugins/build-basic-autotools/build.h
@@ -62,6 +62,12 @@ BuildContext* build_clean_dir (BasicAutotoolsPlugin *plugin,
                                GFile *file,
                                GError **err);
 
+BuildContext* build_check_dir (BasicAutotoolsPlugin *plugin,
+                               GFile *dir,
+                               IAnjutaBuilderCallback callback,
+                               gpointer user_data,
+                               GError **err);
+
 BuildContext* build_distclean (BasicAutotoolsPlugin *plugin);
 
 BuildContext* build_tarball (BasicAutotoolsPlugin *plugin);
diff --git a/plugins/build-basic-autotools/plugin.c b/plugins/build-basic-autotools/plugin.c
index fcfdbd3..4008f5c 100644
--- a/plugins/build-basic-autotools/plugin.c
+++ b/plugins/build-basic-autotools/plugin.c
@@ -1438,6 +1438,15 @@ on_clean_project (GtkAction *action, BasicAutotoolsPlugin *plugin)
 }
 
 static void
+on_check_project (GtkAction *action, BasicAutotoolsPlugin *plugin)
+{
+	if (plugin->project_root_dir)
+	{
+		build_configure_and_build (plugin, build_check_dir,  plugin->project_root_dir, NULL, NULL, NULL);
+	}
+}
+
+static void
 on_configure_project (GtkAction *action, BasicAutotoolsPlugin *plugin)
 {
 	build_configure_dialog (plugin, NULL, NULL, NULL, NULL, NULL);
@@ -1481,6 +1490,14 @@ on_clean_module (GtkAction *action, BasicAutotoolsPlugin *plugin)
 }
 
 static void
+on_check_module (GtkAction *action, BasicAutotoolsPlugin *plugin)
+{
+	g_return_if_fail (plugin->current_editor_file != NULL);
+
+	build_configure_and_build (plugin, build_check_dir,  plugin->current_editor_file, NULL, NULL, NULL);
+}
+
+static void
 on_compile_file (GtkAction *action, BasicAutotoolsPlugin *plugin)
 {
 	g_return_if_fail (plugin->current_editor_file != NULL);
@@ -1591,6 +1608,14 @@ pm_install (GtkAction *action, BasicAutotoolsPlugin *plugin)
 }
 
 static void
+pm_check (GtkAction *action, BasicAutotoolsPlugin *plugin)
+{
+	g_return_if_fail (plugin->pm_current_file != NULL);
+
+	build_configure_and_build (plugin, build_check_dir,  plugin->pm_current_file, NULL, NULL, NULL);
+}
+
+static void
 pm_clean (GtkAction *action, BasicAutotoolsPlugin *plugin)
 {
 	g_return_if_fail (plugin->pm_current_file != NULL);
@@ -1651,6 +1676,12 @@ static GtkActionEntry build_actions[] =
 		G_CALLBACK (on_install_project)
 	},
 	{
+		"ActionBuildCheckProject", NULL,
+		N_("_Check Project"), NULL,
+		N_("Check whole project"),
+		G_CALLBACK (on_check_project)
+	},
+	{
 		"ActionBuildCleanProject", NULL,
 		N_("_Clean Project"), NULL,
 		N_("Clean whole project"),
@@ -1681,6 +1712,12 @@ static GtkActionEntry build_actions[] =
 		G_CALLBACK (on_install_module)
 	},
 	{
+		"ActionBuildCheckModule", NULL,
+		N_("_Check Module"), NULL,
+		N_("Check module associated with current file"),
+		G_CALLBACK (on_check_module)
+	},
+	{
 		"ActionBuildCleanModule", NULL,
 		N_("_Clean Module"), NULL,
 		N_("Clean module associated with current file"),
@@ -1759,6 +1796,12 @@ static GtkActionEntry build_popup_actions[] =
 		G_CALLBACK (pm_install)
 	},
 	{
+		"ActionPopupPMBuildCheck", NULL,
+		N_("_Check"), NULL,
+		N_("Check module"),
+		G_CALLBACK (pm_check)
+	},
+	{
 		"ActionPopupPMBuildClean", NULL,
 		N_("_Clean"), NULL,
 		N_("Clean module"),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]