main: add --simulate (related to issue #33)

feature/tap-sh
William Pitcock 2012-08-08 10:19:39 -05:00
parent 3c157b78db
commit 56ba08b617
1 changed files with 29 additions and 0 deletions

29
main.c
View File

@ -43,6 +43,7 @@
#define PKG_LIST (1<<24) #define PKG_LIST (1<<24)
#define PKG_HELP (1<<25) #define PKG_HELP (1<<25)
#define PKG_PRINT_ERRORS (1<<26) #define PKG_PRINT_ERRORS (1<<26)
#define PKG_SIMULATE (1<<27)
static unsigned int global_traverse_flags = PKGF_NONE; static unsigned int global_traverse_flags = PKGF_NONE;
@ -351,6 +352,21 @@ apply_uninstalled(pkg_t *world, void *data, int maxdepth, unsigned int flags)
pkg_traverse(world, check_uninstalled, data, maxdepth, flags); pkg_traverse(world, check_uninstalled, data, maxdepth, flags);
} }
static void
print_graph_node(pkg_t *pkg, void *data, unsigned int flags)
{
(void) data;
(void) flags;
printf("Considering graph node '%s' (%p)\n", pkg->id, pkg);
}
static void
apply_simulate(pkg_t *world, void *data, int maxdepth, unsigned int flags)
{
pkg_traverse(world, print_graph_node, data, maxdepth, flags);
}
static void static void
version(void) version(void)
{ {
@ -386,6 +402,7 @@ usage(void)
printf(" --errors-to-stdout print all errors on stdout instead of stderr\n"); printf(" --errors-to-stdout print all errors on stdout instead of stderr\n");
printf(" --silence-errors explicitly be silent about errors\n"); printf(" --silence-errors explicitly be silent about errors\n");
printf(" --list-all list all known packages\n"); printf(" --list-all list all known packages\n");
printf(" --simulate simulate walking the calculated dependency graph\n");
printf("\nchecking specific pkg-config database entries:\n\n"); printf("\nchecking specific pkg-config database entries:\n\n");
@ -473,6 +490,7 @@ main(int argc, char *argv[])
{ "errors-to-stdout", no_argument, &want_flags, PKG_ERRORS_ON_STDOUT, }, { "errors-to-stdout", no_argument, &want_flags, PKG_ERRORS_ON_STDOUT, },
{ "silence-errors", no_argument, &want_flags, PKG_SILENCE_ERRORS, }, { "silence-errors", no_argument, &want_flags, PKG_SILENCE_ERRORS, },
{ "list-all", no_argument, &want_flags, PKG_LIST|PKG_PRINT_ERRORS, }, { "list-all", no_argument, &want_flags, PKG_LIST|PKG_PRINT_ERRORS, },
{ "simulate", no_argument, &want_flags, PKG_SIMULATE, },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -735,6 +753,17 @@ main(int argc, char *argv[])
} }
} }
if ((want_flags & PKG_SIMULATE) == PKG_SIMULATE)
{
want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkg_queue_apply(pkgq_head, apply_simulate, maximum_traverse_depth, global_traverse_flags, NULL))
{
ret = EXIT_FAILURE;
goto out;
}
}
if ((want_flags & PKG_MODVERSION) == PKG_MODVERSION) if ((want_flags & PKG_MODVERSION) == PKG_MODVERSION)
{ {
want_flags &= ~(PKG_CFLAGS|PKG_LIBS); want_flags &= ~(PKG_CFLAGS|PKG_LIBS);