Re: scaffold & gnome-build patch



On ven, 2004-01-16 at 19:15 +0100, aurelien naldi wrote:
[..]
> so here is a new version of the gnome-build patch and also a little change to the scaffold one.

Oops, REALLY join the file now :)
-- 
aurelien
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	16 Jan 2004 18:06:36 -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	16 Jan 2004 18:06:37 -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	16 Jan 2004 18:06:37 -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	16 Jan 2004 18:06:38 -0000
@@ -133,9 +133,20 @@
 
 static void
 build_target_cb (BonoboUIComponent *component,
-		 gpointer           user_data)
+		 gpointer          user_data)
 {
-	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 +195,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 +816,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 +848,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 +903,7 @@
 static void
 run_default_cb (BonoboUIComponent *uic, ScaffoldTool *tool)
 {
+	g_message("run_default_cb");
 }
 
 static void
@@ -1205,6 +1239,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;
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	16 Jan 2004 17:17:17 -0000
@@ -220,21 +220,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;
+	char *argv[5];
+	char *build_dir;
 	BuildInfo *info;
 	char *tmp, *msg;
 	int output, err, pid;
@@ -242,32 +238,75 @@
 	reg_syntax_t old_options;
 	GError *error = NULL;
 	const char *charset;
+	GNode *g_node;
+	GbfAmNode *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");
-		return -1;
+	/* default targets  */
+	if ( 0 == strcmp (id, "ALL") ) {
+		argv[0] = g_strdup (project->make_command);
+		argv[1] = g_strdup ("all");
+		argv[2] = NULL;
+		build_dir = g_strdup (project_dir);
+	} else if ( 0 == strcmp (id, "CLEAN") ) {
+		argv[0] = g_strdup (project->make_command);
+		argv[1] = g_strdup ("clean");
+		argv[2] = NULL;
+		build_dir = g_strdup (project_dir);
+	} else if ( 0 == strcmp (id, "INSTALL") ) {
+		argv[0] = g_strdup (project->make_command);
+		argv[1] = g_strdup ("install");
+		argv[2] = NULL;
+		build_dir = g_strdup (project_dir);
+	} else if ( 0 == strcmp (id, "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 (id, "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 { 
+		/* user's target */
+		/* id is like: "USER:real_id"  */
+		g_node = g_hash_table_lookup (project->targets, id+5);
+		if (!g_node) {
+			g_warning ("Invalid build: %s", id);
+			g_free (id);
+			return -1;
+		}
+		node = GBF_AM_NODE (g_node);
+	
+		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+5;
+			while( *cur != '\0' && *cur != ':') {
+				if ('/' == *cur) {
+					last = cur;
+				}
+				cur++;
+			}
+			*last = '\0';
+			*cur = '\0';
+			build_dir = g_strdup_printf ("%s%s", project_dir, id+5);
+
+			argv[0] = g_strdup (project->make_command);
+			argv[1] = g_strdup (last+1);
+			argv[2] = NULL;
+		} else {
+			g_warning ("Invalid build type : %s", node->detail);
+			g_free (id);
+			return -1;
+		}
 	}
+	g_free (id);
 
-	if (!g_spawn_async_with_pipes (project_dir,
+	if (!g_spawn_async_with_pipes (build_dir,
 				       (char**)argv, NULL,
 				       0,
 				       NULL, NULL,
@@ -275,8 +314,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 +342,6 @@
 
 	info = g_new0 (BuildInfo, 1);
 	info->project = project;
-	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	16 Jan 2004 17:17:17 -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	16 Jan 2004 17:17:17 -0000
@@ -71,7 +71,7 @@
 typedef struct {
 	GbfAmProject       *project;
 	GbfAmProjectOpType  type;
-	GbfBuildType        build_type;
+	gchar 		   *build_id;
 } GbfAmProjectOp;
 
 
@@ -303,7 +303,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,10 +2341,9 @@
 	project = GBF_AM_PROJECT (_project);
 	op = g_new0 (GbfAmProjectOp, 1);
 	op->project = project;
-	// FIXME
 	op->type = BUILD;
-	//op->build_type = type;
 
+	op->build_id = g_strdup (id);
 	queue_push_op (project, op);
 }
 
@@ -2353,10 +2352,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 = g_strdup ("CLEAN");
+
+	queue_push_op (project, op);
 }
 
 static gboolean
@@ -2411,6 +2417,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_printf ("USER:%s", key);
+		target->label = g_strdup (node->name);
+		target->description = g_strdup_printf ("%s: %s", _("Build specific target"), node->name);
+
+		*targets = g_list_append (*targets, target);
+	}
+}
+
+
 static GList *
 impl_get_build_targets (GbfProject *_project,
 			GError    **error)
@@ -2424,20 +2453,37 @@
 	project = GBF_AM_PROJECT (_project);
 
 	/* FIXME: these targets should be gotten from the Makefile.am files */
-	/* "make" */
+	/* "autogen" */
+	target = g_new0 (GbfBuildTarget, 1);
+	target->id = g_strdup ("AUTOGEN");
+	target->label = g_strdup (_("Generate"));
+	target->description = g_strdup (_("Generate Makefile"));
+	targets = g_list_append (targets, target);
+
+	/* "configure" */
 	target = g_new0 (GbfBuildTarget, 1);
-	target->id = g_strdup (_("ALL"));
+	target->id = g_strdup ("CONFIGURE");
+	target->label = g_strdup (_("Configure"));
+	target->description = g_strdup (_("Configure the project"));
+	targets = g_list_append (targets, target);
+
+	/* "make all" */
+	target = g_new0 (GbfBuildTarget, 1);
+	target->id = g_strdup ("ALL");
 	target->label = g_strdup (_("All"));
 	target->description = g_strdup (_("Build the entire project"));
 	targets = g_list_append (targets, target);
 
 	/* "make install" */
 	target = g_new0 (GbfBuildTarget, 1);
-	target->id = g_strdup (_("INSTALL"));
+	target->id = g_strdup ("INSTALL");
 	target->label = g_strdup (_("Install"));
 	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 +3219,12 @@
 	
 	/* initialize build callbacks */
 	project->callbacks = NULL;
+
+	/* FIXME: those path should be configurable */
+	project->make_command = g_strdup ("/usr/bin/make");
+	project->configure_command = g_strdup ("./configure");
+	project->autogen_command = g_strdup ("./autogen.sh");
+	project->install_prefix = g_strdup ("/gnome");
 }
 
 static void
@@ -3195,7 +3247,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));
 }
 
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	16 Jan 2004 17:17:17 -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	16 Jan 2004 17:17:18 -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;
 		}
 	}
 


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