[asterisk-commits] branch russell/autoconf_and_menuselect - r8459 /team/russell/autoconf_and_men...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Jan 22 23:44:27 MST 2006


Author: russell
Date: Mon Jan 23 00:44:26 2006
New Revision: 8459

URL: http://svn.digium.com/view/asterisk?rev=8459&view=rev
Log:
process module dependencies

Modified:
    team/russell/autoconf_and_menuselect/build_tools/menuselect.c

Modified: team/russell/autoconf_and_menuselect/build_tools/menuselect.c
URL: http://svn.digium.com/view/asterisk/team/russell/autoconf_and_menuselect/build_tools/menuselect.c?rev=8459&r1=8458&r2=8459&view=diff
==============================================================================
--- team/russell/autoconf_and_menuselect/build_tools/menuselect.c (original)
+++ team/russell/autoconf_and_menuselect/build_tools/menuselect.c Mon Jan 23 00:44:26 2006
@@ -71,12 +71,19 @@
 };
 
 struct member {
+	/*! What will be sent to the makeopts file */
 	const char *name;
+	/*! The name to be shown in menus */
 	const char *displayname;
+	/*! The description */
 	const char *desc;
+	/*! This module is currently selected */
 	int enabled;
-	int depsmet;
-	AST_LIST_HEAD_NOLOCK(, depend) depends;
+	/*! This module has failed dependencies */
+	int depsfailed;
+	/*! dependencies of this module */
+	AST_LIST_HEAD_NOLOCK(, depend) deps;
+	/*! for making a list of modules */
 	AST_LIST_ENTRY(member) list;
 };
 
@@ -256,7 +263,7 @@
 					return -1;
 				if (!strlen_zero(cur3->child->value.opaque)) {
 					dep->name = cur3->child->value.opaque;
-					AST_LIST_INSERT_HEAD(&mem->depends, dep, list);
+					AST_LIST_INSERT_HEAD(&mem->deps, dep, list);
 				} else
 					free(dep);
 			}
@@ -271,14 +278,53 @@
 	return 0;
 }
 
+int process_deps(void)
+{
+	struct category *cat;
+	struct member *mem;
+	struct depend *dep;
+	mxml_node_t *root, *curnode;
+	FILE *f;
+
+	if (!(f = fopen(MENUSELECT_DEPS, "r"))) {
+		fprintf(stderr, "Unable to open '%s' for reading!  Did you run ./configure ?\n", MENUSELECT_DEPS);
+		return -1;
+	}
+
+	if (!(root = mxmlLoadFile(NULL, f, MXML_OPAQUE_CALLBACK))) {
+		close(f);
+		return -1;
+	}
+
+	AST_LIST_TRAVERSE(&categories, cat, list) {
+		AST_LIST_TRAVERSE(&cat->members, mem, list) {
+			AST_LIST_TRAVERSE(&mem->deps, dep, list) {
+				mem->depsfailed = 1;
+				curnode = mxmlFindElement(root, root, dep->name, NULL, NULL, MXML_DESCEND);
+				if (curnode && curnode->child && !strcasecmp("1", curnode->child->value.opaque)) {
+					mem->depsfailed = 0;
+					continue; /* This dependency is matched, so keep checking */
+				}
+				break; /* This depencency is not met, no need to keep checking */
+			}
+		}
+	}
+
+	mxmlDelete(root);
+
+	return 0;
+}
+
 int build_member_list(void)
 {
 	int i;
 	int res = -1;
 
 	for (i = 0; makeopts_files[i]; i++) {
-		if ((res = parse_makeopts_xml(makeopts_files[i])))
-			break;
+		if ((res = parse_makeopts_xml(makeopts_files[i]))) {
+			fprintf(stderr, "Error parsing '%s'!\n", makeopts_files[i]);
+			break;
+		}
 	}
 
 	return res;
@@ -411,8 +457,10 @@
 			fprintf(stderr, "   ==>> Member: '%s'  (%s)\n", mem->name, mem->enabled ? "Enabled" : "Disabled");
 			if (!strlen_zero(mem->desc))
 				fprintf(stderr, "      --> Description: '%s'\n", mem->desc);
-			AST_LIST_TRAVERSE(&mem->depends, dep, list)
+			AST_LIST_TRAVERSE(&mem->deps, dep, list)
 				fprintf(stderr, "      --> Depends on: '%s'\n", dep->name);
+			if (!AST_LIST_EMPTY(&mem->deps))
+				fprintf(stderr, "      --> Dependencies Met: %s\n", mem->depsfailed ? "No" : "Yes");	
 		}
 	}
 }
@@ -674,13 +722,15 @@
 
 int main(int argc, char *argv[])
 {
-	int res = 1;
+	int res;
 
 	/* Parse the input XML files to build the list of available options */
-	if (build_member_list()) {
-		fprintf(stderr, "Unable to build the list of available makeopts!\n");
+	if ((res = build_member_list()))
 		exit(res);
-	}
+
+	/* Process module dependencies */
+	if ((res = process_deps()))
+		exit(res);
 
 	/* Read in the existing makeopts, if they exist */
 	parse_existing_config();
@@ -692,11 +742,8 @@
 #endif
 
 	/* Run the menu to let the user enable/disable options */
-	res = run_menu();
-
-	/* If all is good, save the new config */
-	if (!res)
-		res = generate_makeopts_file();
+	if (!(res = run_menu()))
+		res = generate_makeopts_file(); /* If all is good, save the new config */
 
 	/* free everything we allocated */	
 	free_trees();



More information about the asterisk-commits mailing list