scaffold & gnome-build patch



Hi,

happy new year :)

here is, as requested, a new attempt (not yet finished) to run "make"
from within scaffold.
those patch also fix some typo/crash

I'm waiting for comments :)

PS: it doesn't actually works for running "make all", "make install" or
"./configure" as those target ain't in the hash table for targets,
should they be inserted here, or should they been accepted anyway ?
inserting it in the hash table will certainly make them appear in the
project-browser...

-- 
aurelien
Index: src/backends/libgbf_am/gbf-am-build.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-build.c,v
retrieving revision 1.6
diff -u -r1.6 gbf-am-build.c
--- src/backends/libgbf_am/gbf-am-build.c	9 Sep 2003 11:11:21 -0000	1.6
+++ src/backends/libgbf_am/gbf-am-build.c	10 Jan 2004 13:38:09 -0000
@@ -220,21 +221,17 @@
 
 int
 gbf_build_run (GbfAmProject    *project,
-	       GbfBuildType     type,
+	       gchar	       *id,
 	       const char      *project_dir,
 	       GList           *callbacks)
 {
 	static const char *dir_regex = "Entering directory `([^']+)'";
 	static const char *warn_regex = "^([^:]+):([0-9]+): warning: (.+)$";
 	static const char *err_regex = "^([^:]+):([0-9]+): (.+)$";
-	/* TODO: These paths should come from a build configuration. */
-	static const char *prepare_argv[] = { "./autogen.sh", "--prefix=/gnome", NULL };
-	static const char *configure_argv[] = { "./configure", "--prefix=/gnome", NULL };
-	static const char *clean_argv[] = {"/usr/bin/make", "clean", NULL };
-	static const char *all_argv[] = { "/usr/bin/make", "all", NULL };
-	static const char *install_argv[] = {"/usr/bin/make", "install", NULL };
+
 	static int buildid = 0;
-	const char **argv = NULL;
+	const char *argv[5];
+	const char *build_dir;
 	BuildInfo *info;
 	char *tmp, *msg;
 	int output, err, pid;
@@ -242,32 +239,53 @@
 	reg_syntax_t old_options;
 	GError *error = NULL;
 	const char *charset;
+	GNode *g_node;
+	GbfAmNode *node;
+
+	g_node = g_hash_table_lookup(project->targets, id);
+	if (!g_node) {
+		g_warning ("Invalid build: %s", id);
+		return -1;
+	}
+	
+	node = GBF_AM_NODE (g_node);
 
-	switch (type) {
-	case GBF_BUILD_PREPARE:
-		argv = prepare_argv;
-		break;
-	case GBF_BUILD_CONFIGURE:
-		argv = configure_argv;
-		break;
-	case GBF_BUILD_CLEAN:
-		argv = clean_argv;
-		break;
-	case GBF_BUILD_ALL:
-		argv = all_argv;
-		break;
-	case GBF_BUILD_CURRENT:
-		g_warning ("No build for current");
-		break;
-	case GBF_BUILD_INSTALL:
-		argv = install_argv;
-		break;
-	default:
-		g_warning ("Invalid build type");
+	if ( 0 == strcmp(node->detail, "program") ||
+	     0 == strcmp(node->detail, "static_lib") ||
+	     0 == strcmp(node->detail, "shared_lib") ) {
+		/* find the right build dir and make argument */
+		/* FIXME: durty ?? */
+		gchar *cur, *last;
+		cur = id;
+		while( *cur != '\0' && *cur != ':') {
+			if ('/' == *cur) {
+				last = cur;
+			}
+			cur++;
+		}
+		*last = '\0';
+		*cur = '\0';
+		build_dir = g_strdup_printf("%s%s", project_dir, id);
+
+		argv[0] = g_strdup(project->make_command);
+		argv[1] = g_strdup(last+1);
+		argv[2] = NULL;
+	} else if ( 0 == strcmp(node->detail, "configure") ) {
+		argv[0] = g_strdup(project->configure_command);
+		argv[1] = g_strdup_printf("--prefix=%s",project->install_prefix);
+		argv[2] = NULL;
+		build_dir = g_strdup(project_dir);
+	} else if (0 == strcmp(node->detail, "autogen")) {
+		argv[0] = g_strdup(project->autogen_command);
+		argv[1] = g_strdup_printf("--prefix=%s",project->install_prefix);
+		argv[2] = NULL;
+		build_dir = g_strdup(project_dir);
+	} else {
+		g_warning ("Invalid build type : %s", node->detail);
 		return -1;
 	}
 
-	if (!g_spawn_async_with_pipes (project_dir,
+	if (!g_spawn_async_with_pipes (build_dir,
 				       (char**)argv, NULL,
 				       0,
 				       NULL, NULL,
@@ -275,8 +293,14 @@
 				       NULL, &output, &err,
 				       NULL)) {
 		g_warning ("Couldn't spawn '%s'", argv[0]);
+		g_free(build_dir);
+		g_free(argv[0]);
+		g_free(argv[1]);
 		return -1;
 	}
+	g_free(build_dir);
+	g_free(argv[0]);
+	g_free(argv[1]);
 
 	out_channel = g_io_channel_unix_new (output);
 	g_io_channel_set_close_on_unref (out_channel, TRUE);
@@ -297,7 +321,7 @@
 
 	info = g_new0 (BuildInfo, 1);
 	info->project = project;
-	info->type = type;
+	//info->type = type;
 	info->id = ++buildid;
 	info->num_channels = 2;
 	info->callbacks = callbacks;
Index: src/backends/libgbf_am/gbf-am-build.h
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-build.h,v
retrieving revision 1.1
diff -u -r1.1 gbf-am-build.h
--- src/backends/libgbf_am/gbf-am-build.h	18 Sep 2002 16:38:45 -0000	1.1
+++ src/backends/libgbf_am/gbf-am-build.h	10 Jan 2004 13:38:09 -0000
@@ -28,7 +28,7 @@
 G_BEGIN_DECLS
 
 int gbf_build_run (GbfAmProject    *project,
-		   GbfBuildType     type,
+		   gchar           *id,
 		   const char      *project_dir,
 		   GList           *callbacks);
 
Index: src/backends/libgbf_am/gbf-am-project.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-project.c,v
retrieving revision 1.47
diff -u -r1.47 gbf-am-project.c
--- src/backends/libgbf_am/gbf-am-project.c	14 Sep 2003 17:27:16 -0000	1.47
+++ src/backends/libgbf_am/gbf-am-project.c	10 Jan 2004 13:38:10 -0000
@@ -71,7 +71,7 @@
 typedef struct {
 	GbfAmProject       *project;
 	GbfAmProjectOpType  type;
-	GbfBuildType        build_type;
+	gchar 		   *build_id;
 } GbfAmProjectOp;
 
 
@@ -171,7 +171,11 @@
 
 enum {
 	PROP_0,
-	PROP_PROJECT_DIR
+	PROP_PROJECT_DIR,
+	PROP_PROJECT_MAKE_COMMAND,
+	PROP_PROJECT_CONFIGURE_COMMAND,
+	PROP_PROJECT_AUTOGEN_COMMAND,
+	PROP_PROJECT_INSTALL_PREFIX
 };
 
 static GbfProject *parent_class;
@@ -303,7 +307,7 @@
 			gchar *project_root = uri_to_path (project->project_root_uri);
 						
 			/* FIXME: gbf_build_run can be simpler */
-			gbf_build_run (project, op->build_type,
+			gbf_build_run (project, op->build_id,
 				       project_root,
 				       project->callbacks);
 
@@ -2341,11 +2345,15 @@
 	project = GBF_AM_PROJECT (_project);
 	op = g_new0 (GbfAmProjectOp, 1);
 	op->project = project;
-	// FIXME
 	op->type = BUILD;
-	//op->build_type = type;
 
-	queue_push_op (project, op);
+	/* FIXME this ain't nice, works for now ? */
+	g_hash_table_lookup (project->groups, id);
+	if (g_hash_table_lookup (project->targets, id))
+	{
+		op->build_id = id;
+		queue_push_op (project, op);
+	}
 }
 
 static void
@@ -2353,10 +2361,17 @@
 	    GError    **error)
 {
 	GbfAmProject *project;
+	GbfAmProjectOp *op;
 
 	g_return_if_fail (GBF_IS_AM_PROJECT (_project));
 
 	project = GBF_AM_PROJECT (_project);
+	op = g_new0 (GbfAmProjectOp, 1);
+	op->project = project;
+	op->type = BUILD;
+	op->build_id = "clean";
+
+	queue_push_op (project, op);
 }
 
 static gboolean
@@ -2411,6 +2426,29 @@
 		g_signal_emit_by_name (G_OBJECT (project), "project-updated");
 }
 
+
+static void
+foreach_build_target (gpointer key, gpointer value, gpointer data)
+{
+	GList **targets = data;
+	GbfAmNode *node;
+	GbfBuildTarget *target;
+
+	node = GBF_AM_NODE ((GNode *)value);
+
+	if ( 0 == strcmp(node->detail, "program") ||
+	     0 == strcmp(node->detail, "static_lib") ||
+	     0 == strcmp(node->detail, "shared_lib") ) {
+		target = g_new0 (GbfBuildTarget, 1);
+		target->id = g_strdup (key);
+		target->label = g_strdup (node->name);
+		target->description = g_strdup_printf("Build specific target: %s", node->name);
+
+		*targets = g_list_append (*targets, target);
+	}
+}
+
+
 static GList *
 impl_get_build_targets (GbfProject *_project,
 			GError    **error)
@@ -2438,6 +2476,9 @@
 	target->description = g_strdup (_("Build the entire project and install it"));
 	targets = g_list_append (targets, target);
 
+	/* other build targets */
+	g_hash_table_foreach (project->targets, foreach_build_target, &targets);
+
 	return targets;
 }
 
@@ -3173,6 +3214,12 @@
 	
 	/* initialize build callbacks */
 	project->callbacks = NULL;
+
+	project->make_command = g_strdup("/usr/bin/make");
+	project->configure_command = g_strdup("./configure");
+	project->autogen_command = g_strdup("./autogen");
+	project->install_prefix = g_strdup("/gnome");
 }
 
 static void
@@ -3195,7 +3242,11 @@
 
 	/* disconnect callbacks */
 	callbacks_destroy (project);
-
+	g_free(project->make_command);
+	g_free(project->configure_command);
+	g_free(project->autogen_command);
+	g_free(project->install_prefix);
+	
 	GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
 }
 
@@ -3210,6 +3261,18 @@
 	switch (prop_id) {
 		case PROP_PROJECT_DIR:
 			g_value_set_string (value, project->project_root_uri);
+			break;
+		case PROP_PROJECT_MAKE_COMMAND:
+			g_value_set_string (value, project->make_command);
+			break;
+		case PROP_PROJECT_CONFIGURE_COMMAND:
+			g_value_set_string (value, project->configure_command);
+			break;
+		case PROP_PROJECT_AUTOGEN_COMMAND:
+			g_value_set_string (value, project->autogen_command);
+			break;
+		case PROP_PROJECT_INSTALL_PREFIX:
+			g_value_set_string (value, project->install_prefix);
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Index: src/backends/libgbf_am/gbf-am-project.h
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-project.h,v
retrieving revision 1.14
diff -u -r1.14 gbf-am-project.h
--- src/backends/libgbf_am/gbf-am-project.h	26 Apr 2003 09:31:02 -0000	1.14
+++ src/backends/libgbf_am/gbf-am-project.h	10 Jan 2004 13:38:10 -0000
@@ -91,6 +91,12 @@
 
 	/* build callbacks */
 	GList              *callbacks;
+
+	/* build config */
+	gchar	 	   *make_command;
+	gchar 		   *configure_command;
+	gchar 		   *autogen_command;
+	gchar 		   *install_prefix;
 };
 
 struct _GbfAmProjectClass {
Index: src/gbf/gbf-project-view.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/gbf/gbf-project-view.c,v
retrieving revision 1.5
diff -u -r1.5 gbf-project-view.c
--- src/gbf/gbf-project-view.c	26 Dec 2003 05:30:35 -0000	1.5
+++ src/gbf/gbf-project-view.c	10 Jan 2004 13:38:10 -0000
@@ -323,7 +323,7 @@
 				    GBF_PROJECT_MODEL_COLUMN_DATA, &data,
 				    -1);
 		/* walk up the hierarchy searching for a node of the given type */
-		while (data->type != type) {
+		while (NULL != data && data->type != type) {
 			gbf_tree_data_free (data);
 			data = NULL;
 
@@ -333,6 +333,7 @@
 			gtk_tree_model_get (model, &iter2,
 					    GBF_PROJECT_MODEL_COLUMN_DATA, &data,
 					    -1);
+			iter = iter2;
 		}
 	}
 
Index: src/gbf/glue-factory.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/gbf/glue-factory.c,v
retrieving revision 1.3
diff -u -r1.3 glue-factory.c
--- src/gbf/glue-factory.c	9 Apr 2003 04:56:50 -0000	1.3
+++ src/gbf/glue-factory.c	10 Jan 2004 13:38:10 -0000
@@ -181,7 +181,7 @@
 	      goto move_to_next_dir;
 	    }
 
-	  if (!g_module_symbol (module, "glue_get_component_type", (gpointer *)&get_type_func))
+	  if (!g_module_symbol (module, "glue_get_component_type", (gpointer )&get_type_func))
 	    {
 	      g_module_close (module);
 	      goto move_to_next_dir;
Index: src/gbf/glue-plugin.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/gbf/glue-plugin.c,v
retrieving revision 1.2
diff -u -r1.2 glue-plugin.c
--- src/gbf/glue-plugin.c	9 Apr 2003 04:56:50 -0000	1.2
+++ src/gbf/glue-plugin.c	10 Jan 2004 13:38:10 -0000
@@ -56,7 +56,7 @@
       return FALSE;
     }
   
-  if (!g_module_symbol (plugin->module, "glue_register_components", (gpointer *)&func))
+  if (!g_module_symbol (plugin->module, "glue_register_components", (gpointer )&func))
     {
       g_warning ("could not load plugin: %s", g_module_error ());
       g_module_close (plugin->module);
Index: libscaffold/scaffold-session.c
===================================================================
RCS file: /cvs/gnome/scaffold/libscaffold/scaffold-session.c,v
retrieving revision 1.4
diff -u -r1.4 scaffold-session.c
--- libscaffold/scaffold-session.c	27 Dec 2003 03:58:43 -0000	1.4
+++ libscaffold/scaffold-session.c	10 Jan 2004 14:16:46 -0000
@@ -232,6 +232,7 @@
 	/* Parse nodes. */
 	root = xmlDocGetRootElement (doc);
 	for (node = root->xmlChildrenNode; node; node = node->next) {
+		node->doc = NULL;
 		if (node->type == XML_ELEMENT_NODE)
 			parse_node (session, node);
 	}
@@ -421,11 +422,7 @@
 		return;
 	}
 
-	/* Check if such a group already exists and remove it. */
-	if (g_hash_table_lookup (session->priv->groups, group->name)) {
-		g_hash_table_remove (session->priv->groups, group->name); 
-	}
-
+	/* insert the group,  g_hash_table_insert 'll remove it first if it already exists */
 	g_hash_table_insert (session->priv->groups,
 			     g_strdup (group->name), group);
 }
Index: plugins/document-manager/scaffold-document-manager.c
===================================================================
RCS file: /cvs/gnome/scaffold/plugins/document-manager/scaffold-document-manager.c,v
retrieving revision 1.36
diff -u -r1.36 scaffold-document-manager.c
--- plugins/document-manager/scaffold-document-manager.c	27 Dec 2003 04:00:30 -0000	1.36
+++ plugins/document-manager/scaffold-document-manager.c	10 Jan 2004 14:16:47 -0000
@@ -1163,6 +1163,7 @@
 	ScaffoldNotebookDocumentManager *docman = SCAFFOLD_NOTEBOOK_DOCUMENT_MANAGER (scaffold_docman);
 	ScaffoldDocument *document;
 	GnomeVFSURI *uri;
+	gchar* string_full_uri;
 	
 	uri = gnome_vfs_uri_new (string_uri);
 	if (!gnome_vfs_uri_exists (uri)) {
@@ -1175,16 +1176,21 @@
 
 		return NULL;
 	}
+	/* get the full path into string_full_uri: prevents conflicts beetwen 
+	 * file:///path/to/file and /path/to/file
+	 */
+	string_full_uri = gnome_vfs_uri_to_string(uri,GNOME_VFS_URI_HIDE_NONE);
 	gnome_vfs_uri_unref (uri);
 
 	/* Only open the file if its not already opened. */
 	document = scaffold_document_manager_get_document_for_uri (scaffold_docman,
-								 string_uri,
+								 string_full_uri,
 								 TRUE,
 								 NULL);
 	if (document) {
 		scaffold_document_manager_show_document (scaffold_docman, 
 						       document);
+		g_free(string_full_uri);
 		return document;
 	}
 
@@ -1193,7 +1199,7 @@
 	if (document != NULL && (!scaffold_bonobo_document_is_untitled (SCAFFOLD_BONOBO_DOCUMENT (document)) ||
 				 scaffold_bonobo_document_is_changed (SCAFFOLD_BONOBO_DOCUMENT (document)))) {
 		document = SCAFFOLD_DOCUMENT (scaffold_bonobo_document_new (docman->ui_container));
-		if (scaffold_bonobo_document_load_uri (SCAFFOLD_BONOBO_DOCUMENT (document), string_uri)) {
+		if (scaffold_bonobo_document_load_uri (SCAFFOLD_BONOBO_DOCUMENT (document), string_full_uri)) {
 			add_doc (docman, document);
 		} else {
 			g_object_unref (G_OBJECT (document));
@@ -1201,12 +1207,13 @@
 		}
 	} else {
 		scaffold_bonobo_document_load_uri
-			(SCAFFOLD_BONOBO_DOCUMENT (document), string_uri);
+			(SCAFFOLD_BONOBO_DOCUMENT (document), string_full_uri);
 		SCAFFOLD_BONOBO_DOCUMENT (document)->untitled = FALSE;
 		docman->priv->untitled_count--;
 		set_current_document(docman, document);
 	}
 
+	g_free(string_full_uri);
 	return document;
 }
 
Index: plugins/document-manager/scaffold-document.c
===================================================================
RCS file: /cvs/gnome/scaffold/plugins/document-manager/scaffold-document.c,v
retrieving revision 1.54
diff -u -r1.54 scaffold-document.c
--- plugins/document-manager/scaffold-document.c	31 Jul 2003 08:55:23 -0000	1.54
+++ plugins/document-manager/scaffold-document.c	10 Jan 2004 14:16:47 -0000
@@ -487,7 +487,7 @@
 		/* Prompt to save */
  	}
 
-	if (ret) {
+	else {
 		Bonobo_Stream_seek (bonobo_object_corba_objref (BONOBO_OBJECT (ret)),
 				    0, Bonobo_Stream_SeekSet, &ev);
 	}
Index: plugins/project-manager/project-tool.c
===================================================================
RCS file: /cvs/gnome/scaffold/plugins/project-manager/project-tool.c,v
retrieving revision 1.51
diff -u -r1.51 project-tool.c
--- plugins/project-manager/project-tool.c	27 Dec 2003 04:00:31 -0000	1.51
+++ plugins/project-manager/project-tool.c	10 Jan 2004 14:16:48 -0000
@@ -133,9 +133,21 @@
 static void
 build_target_cb (BonoboUIComponent *component,
 {
-	g_message ("build_target_cb"); 
+	GError *err = NULL;
+	gchar *str;
+	BuildTargetMenuData *md = user_data;
+	ProjectTool *proj_tool = (ProjectTool *)md->tool;
+
+	gbf_project_build (proj_tool->project, md->target->id, &err);
+	if (err != NULL) {
+		str = g_strdup_printf (_("An error occurred during building: '%s'"),
+				       err->message);
+		g_free (str);
+		g_error_free (err);
+	}
 }
 
 static void
@@ -184,7 +196,7 @@
 		closure = g_cclosure_new (G_CALLBACK (build_target_cb), md,
 					  build_menu_data_destroy_cb);
 
-		bonobo_ui_component_add_listener_full (uic, verb_name, closure);
+		bonobo_ui_component_add_verb_full (uic, verb_name, closure);
 
 		item_path = g_strconcat (menu_path, "/", verb_name, NULL);
 
@@ -805,6 +817,17 @@
 static void
 build_default_cb (BonoboUIComponent *uic, ScaffoldTool *tool)
 {
+	ProjectTool *proj_tool = (ProjectTool *)tool;
+	GError *err = NULL;
+	gchar *str;
+
+	gbf_project_build (proj_tool->project, "all", &err);
+	if (err != NULL) {
+		str = g_strdup_printf (_("An error occurred during building: '%s'"),
+				       err->message);
+		g_free (str);
+		g_error_free (err);
+	}
 }
 
 static void
@@ -826,6 +849,17 @@
 static void
 build_config_cb (BonoboUIComponent *uic, ScaffoldTool *tool)
 {
+	ProjectTool *proj_tool = (ProjectTool *)tool;
+	GError *err = NULL;
+	gchar *str;
+
+	gbf_project_build (proj_tool->project, "configure", &err);
+	if (err != NULL) {
+		str = g_strdup_printf (_("An error occurred during configuring: '%s'"),
+				       err->message);
+		g_free (str);
+		g_error_free (err);
+	}
 }
 
 static void
@@ -870,6 +904,7 @@
 static void
 run_default_cb (BonoboUIComponent *uic, ScaffoldTool *tool)
 {
+	g_message("run_default_cb");
 }
 
 static void
@@ -1205,6 +1240,13 @@
 	g_object_unref (G_OBJECT (client));
 	g_signal_connect (G_OBJECT (recent), "activate",
 			  G_CALLBACK (recent_project_cb), tool);
+
+	g_signal_connect (proj_tool->build_combo, "activate_default",
+	                  G_CALLBACK (build_default_cb), tool);
+	g_signal_connect (proj_tool->run_combo, "activate_default",
+	                  G_CALLBACK (run_default_cb), tool);
+	g_signal_connect (proj_tool->project_combo, "activate_default",
+	                  G_CALLBACK (project_open_cb), tool);
 	gdl_recent_set_ui_component (recent, tool->uic);
 
 	proj_tool->recent = recent;


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