[asterisk-commits] branch group/autoconf_and_menuselect r11042 - in
/team/group/autoconf_and_men...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Feb 24 18:26:05 MST 2006
Author: russell
Date: Fri Feb 24 19:26:03 2006
New Revision: 11042
URL: http://svn.digium.com/view/asterisk?rev=11042&view=rev
Log:
allow menuselect to do a dependency check on an existing menuselect-deps file
before running the Asterisk build. Move some of the things in the makeopts.xml
files to be attributes and update an existing makeopts.xml file that was used
for testing. All of the makeopts.xml files are going to go away shortly in favor
of an automagically generated one.
Modified:
team/group/autoconf_and_menuselect/Makefile
team/group/autoconf_and_menuselect/build_tools/menuselect.c
team/group/autoconf_and_menuselect/build_tools/menuselect.h
team/group/autoconf_and_menuselect/utils/makeopts.xml
Modified: team/group/autoconf_and_menuselect/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/autoconf_and_menuselect/Makefile?rev=11042&r1=11041&r2=11042&view=diff
==============================================================================
--- team/group/autoconf_and_menuselect/Makefile (original)
+++ team/group/autoconf_and_menuselect/Makefile Fri Feb 24 19:26:03 2006
@@ -450,8 +450,9 @@
all: cleantest depend asterisk subdirs
-menuselect-deps:
+menuselect-deps: _menuselect
@test -f autoconf/menuselect-deps || ( echo "You must run ./configure before building Asterisk!" && exit 1 )
+ @./build_tools/menuselect --check-deps
#ifneq ($(wildcard tags),)
ctags: tags
Modified: team/group/autoconf_and_menuselect/build_tools/menuselect.c
URL: http://svn.digium.com/view/asterisk/team/group/autoconf_and_menuselect/build_tools/menuselect.c?rev=11042&r1=11041&r2=11042&view=diff
==============================================================================
--- team/group/autoconf_and_menuselect/build_tools/menuselect.c (original)
+++ team/group/autoconf_and_menuselect/build_tools/menuselect.c Fri Feb 24 19:26:03 2006
@@ -18,15 +18,10 @@
/*
* \file
+ *
* \author Russell Bryant <russell at digium.com>
*
* \brief a generic 'make menuselect' system
- *
- * \todo Allow the output makeopts filename to be optionally specified as a command line argument
- * \todo Display the description of the category or member when the user hits a certain key
- * \todo Deprecate the displayname in the member structure when the description display gets implemented
- * \todo Allow nested categories for more organized menus - A single variable should be generated with values
- * from all of the members of child categories using the name of the top-level category.
*/
#include <stdlib.h>
@@ -71,10 +66,6 @@
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;
/*! This module has failed dependencies */
@@ -90,8 +81,6 @@
const char *name;
/*! the name displayed in the menu */
const char *displayname;
- /*! A description of this variable */
- const char *desc;
/*! the list of possible values to be set in this variable */
AST_LIST_HEAD_NOLOCK(, member) members;
/*! for linking */
@@ -127,6 +116,8 @@
char *output_makeopts = OUTPUT_MAKEOPTS_DEFAULT;
+int existing_config_exists = 0;
+
/*! \brief a wrapper for calloc() that generates an error message if the allocation fails */
static inline void *my_calloc(size_t num, size_t len)
{
@@ -236,24 +227,11 @@
cur;
cur = mxmlFindElement(cur, tree->root, "category", NULL, NULL, MXML_DESCEND))
{
- if (!(cur2 = mxmlFindElement(cur, cur, "name", NULL, NULL, MXML_DESCEND))) {
- fprintf(stderr, "category specified with no name in '%s'!\n", makeopts_xml);
- continue;
- }
- if (!cur2->child) {
- fprintf(stderr, "category with empty name!\n");
- continue;
- }
if (!(cat = my_calloc(1, sizeof(*cat))))
return -1;
- cat->name = cur2->child->value.opaque;
-
- if ((cur2 = mxmlFindElement(cur, cur, "displayname", NULL, NULL, MXML_DESCEND)) && cur2->child)
- cat->displayname = cur2->child->value.opaque;
-
- if ((cur2 = mxmlFindElement(cur, cur, "description", NULL, NULL, MXML_DESCEND)) && cur2->child)
- cat->desc = cur2->child->value.opaque;
+ cat->name = mxmlElementGetAttr(cur, "name");
+ cat->displayname = mxmlElementGetAttr(cur, "displayname");
if (add_category(cat)) {
free(cat);
@@ -264,22 +242,12 @@
cur2;
cur2 = mxmlFindElement(cur2, cur, "member", NULL, NULL, MXML_DESCEND))
{
- if (!(cur3 = mxmlFindElement(cur2, cur2, "name", NULL, NULL, MXML_DESCEND))) {
- fprintf(stderr, "Member listed in category '%s' with no name! Moving on ...\n", cat->name);
- continue;
- }
-
if (!(mem = my_calloc(1, sizeof(*mem))))
return -1;
/* Enabled by default */
mem->enabled = 1;
-
- mem->name = cur3->child->value.opaque;
- if ((cur3 = mxmlFindElement(cur2, cur2, "description", NULL, NULL, MXML_DESCEND)) && cur3->child)
- mem->desc = cur3->child->value.opaque;
- if ((cur3 = mxmlFindElement(cur2, cur2, "displayname", NULL, NULL, MXML_DESCEND)) && cur3->child)
- mem->displayname = cur3->child->value.opaque;
+ mem->name = mxmlElementGetAttr(cur2, "name");
for (cur3 = mxmlFindElement(cur2, cur2, "depend", NULL, NULL, MXML_DESCEND);
cur3 && cur3->child;
@@ -319,6 +287,7 @@
AST_LIST_HEAD_NOLOCK_STATIC(deps_file, dep_file);
char buf[80];
char *p;
+ int res = 0;
if (!(f = fopen(MENUSELECT_DEPS, "r"))) {
fprintf(stderr, "Unable to open '%s' for reading! Did you run ./configure ?\n", MENUSELECT_DEPS);
@@ -357,10 +326,24 @@
if (mem->depsfailed)
break; /* This dependency is not met, so we can stop now */
}
- if (mem->depsfailed)
+ if (mem->depsfailed) {
+ if (existing_config_exists && mem->enabled) {
+ /* Config already existed, but this module was not disabled.
+ * However, according to our current list of dependencies that
+ * have been met, this can not be built. */
+ res = -1;
+ fprintf(stderr, "\nThe existing menuselect.makeopts did not specify that %s should not be built\n", mem->name);
+ fprintf(stderr, "However, menuselect-deps indicates that dependencies for this module have not\n");
+ fprintf(stderr, "been met. So, either remove the existing menuselect.makeopts file, or run\n");
+ fprintf(stderr, "'make menuselect' to generate a file that is correct.\n\n");
+ goto deps_file_free;
+ }
mem->enabled = 0; /* Automatically disable it if dependencies not met */
- }
- }
+ }
+ }
+ }
+
+deps_file_free:
/* Free the dependency list we built from the file */
AST_LIST_TRAVERSE_SAFE_BEGIN(&deps_file, dep_file, list) {
@@ -368,7 +351,7 @@
}
AST_LIST_TRAVERSE_SAFE_END
- return 0;
+ return res;
}
/*! \brief Iterate through all of the input makeopts files and call the parse function on them */
@@ -442,6 +425,8 @@
return;
}
+ existing_config_exists = 1;
+
while (fgets(buf, sizeof(buf), f)) {
lineno++;
@@ -510,12 +495,8 @@
AST_LIST_TRAVERSE(&categories, cat, list) {
fprintf(stderr, "Category: '%s'\n", cat->name);
- if (!strlen_zero(cat->desc))
- fprintf(stderr, " --> Description: '%s'\n", cat->desc);
AST_LIST_TRAVERSE(&cat->members, mem, list) {
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->deps, dep, list)
fprintf(stderr, " --> Depends on: '%s'\n", dep->name);
if (!AST_LIST_EMPTY(&mem->deps))
@@ -651,9 +632,9 @@
}
wmove(menu, j++, max_x / 2 - 10);
if (mem->depsfailed)
- snprintf(buf, sizeof(buf), "XXX %d. %s", ++i, !strlen_zero(mem->displayname) ? mem->displayname : mem->name);
+ snprintf(buf, sizeof(buf), "XXX %d. %s", ++i, mem->name);
else
- snprintf(buf, sizeof(buf), "[%s] %d. %s", mem->enabled ? "*" : " ", ++i, !strlen_zero(mem->displayname) ? mem->displayname : mem->name);
+ snprintf(buf, sizeof(buf), "[%s] %d. %s", mem->enabled ? "*" : " ", ++i, mem->name);
waddstr(menu, buf);
if (i == end)
break;
@@ -824,31 +805,45 @@
int main(int argc, char *argv[])
{
- int res;
+ int res = 0;
/* Parse the input XML files to build the list of available options */
if ((res = build_member_list()))
exit(res);
+ /* Read in the existing makeopts, if they exist */
+ parse_existing_config();
+
/* Process module dependencies */
if ((res = process_deps()))
- exit(res);
-
- /* Read in the existing makeopts, if they exist */
- parse_existing_config();
+ goto cleanup_allocations;
#ifdef MENUSELECT_DEBUG
/* Dump the list produced by parsing the various input files */
dump_member_list();
#endif
+ if (argc == 2 || !strcmp(argv[1], "--check-deps")) {
+ /* Set to greater than 0 so that we won't run the menu
+ or write out a new file, but we will still exit with
+ a return code of 0 */
+ res = 1;
+ }
+
/* Run the menu to let the user enable/disable options */
- if (!(res = run_menu()))
+ if (!res)
+ res = run_menu();
+
+ if (!res)
res = generate_makeopts_file(); /* If all is good, save the new config */
+cleanup_allocations:
/* free everything we allocated */
free_trees();
free_member_list();
+ if (res > 0)
+ res = 0;
+
exit(res);
}
Modified: team/group/autoconf_and_menuselect/build_tools/menuselect.h
URL: http://svn.digium.com/view/asterisk/team/group/autoconf_and_menuselect/build_tools/menuselect.h?rev=11042&r1=11041&r2=11042&view=diff
==============================================================================
--- team/group/autoconf_and_menuselect/build_tools/menuselect.h (original)
+++ team/group/autoconf_and_menuselect/build_tools/menuselect.h Fri Feb 24 19:26:03 2006
@@ -16,7 +16,7 @@
* at the top of the source tree.
*/
-/*
+/*!
* \file
*
* \brief defaults for menuselect
@@ -41,15 +41,15 @@
"quit => q",
"save and quit => x",
"",
- "XXX means dependencies have not been met",
+ "XXX means dependencies have not been met"
};
const char * const makeopts_files[] = {
- "apps/makeopts.xml",
+ /*"apps/makeopts.xml",
"cdr/makeopts.xml",
"channels/makeopts.xml",
"formats/makeopts.xml",
"pbx/makeopts.xml",
- "res/makeopts.xml",
- "utils/makeopts.xml",
+ "res/makeopts.xml",*/
+ "utils/makeopts.xml"
};
Modified: team/group/autoconf_and_menuselect/utils/makeopts.xml
URL: http://svn.digium.com/view/asterisk/team/group/autoconf_and_menuselect/utils/makeopts.xml?rev=11042&r1=11041&r2=11042&view=diff
==============================================================================
--- team/group/autoconf_and_menuselect/utils/makeopts.xml (original)
+++ team/group/autoconf_and_menuselect/utils/makeopts.xml Fri Feb 24 19:26:03 2006
@@ -1,22 +1,16 @@
<?xml version="1.0"?>
-<category>
- <name>MENUSELECT_UTILS</name>
- <displayname>Utilities</displayname>
- <member>
- <name>astman</name>
+<category name="MENUSELECT_UTILS" displayname="Utilities">
+ <member name="astman">
<depend>libnewt</depend>
</member>
- <member>
- <name>smsq</name>
+ <member name="smsq">
<depend>libpopt</depend>
</member>
- <member>
- <name>streamplayer</name>
+ <member name="streamplayer">
<description>A utility for reading from a raw TCP stream and sending the data to stdout</description>
</member>
- <member>
- <name>stereorize</name>
+ <member name="stereorize">
<description>Merge two mono WAV-files to one stereo WAV-file.</description>
</member>
</category>
More information about the asterisk-commits
mailing list