forked from ariadne/pkgconf
pkg: add flags option to pkg_traverse() to optionally control what the depgraph traversal code does
parent
bea3c202de
commit
5ea52d4cae
12
main.c
12
main.c
|
@ -173,7 +173,7 @@ pkg_queue_walk(pkg_queue_t *head)
|
||||||
printf("edge [color=blue len=7.5 fontname=Sans fontsize=8]\n");
|
printf("edge [color=blue len=7.5 fontname=Sans fontsize=8]\n");
|
||||||
printf("node [fontname=Sans fontsize=8]\n");
|
printf("node [fontname=Sans fontsize=8]\n");
|
||||||
|
|
||||||
pkg_traverse(&world, print_digraph_node, NULL, maximum_traverse_depth);
|
pkg_traverse(&world, print_digraph_node, NULL, maximum_traverse_depth, PKGF_NONE);
|
||||||
|
|
||||||
printf("}\n");
|
printf("}\n");
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ pkg_queue_walk(pkg_queue_t *head)
|
||||||
want_cflags = 0;
|
want_cflags = 0;
|
||||||
want_libs = 0;
|
want_libs = 0;
|
||||||
|
|
||||||
pkg_traverse(&world, print_modversion, NULL, 2);
|
pkg_traverse(&world, print_modversion, NULL, 2, PKGF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (want_variables)
|
if (want_variables)
|
||||||
|
@ -195,7 +195,7 @@ pkg_queue_walk(pkg_queue_t *head)
|
||||||
want_cflags = 0;
|
want_cflags = 0;
|
||||||
want_libs = 0;
|
want_libs = 0;
|
||||||
|
|
||||||
pkg_traverse(&world, print_variables, NULL, 2);
|
pkg_traverse(&world, print_variables, NULL, 2, PKGF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (want_requires)
|
if (want_requires)
|
||||||
|
@ -218,19 +218,19 @@ pkg_queue_walk(pkg_queue_t *head)
|
||||||
if (want_cflags)
|
if (want_cflags)
|
||||||
{
|
{
|
||||||
wanted_something++;
|
wanted_something++;
|
||||||
pkg_traverse(&world, print_cflags, NULL, maximum_traverse_depth);
|
pkg_traverse(&world, print_cflags, NULL, maximum_traverse_depth, PKGF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (want_libs)
|
if (want_libs)
|
||||||
{
|
{
|
||||||
wanted_something++;
|
wanted_something++;
|
||||||
pkg_traverse(&world, print_libs, NULL, maximum_traverse_depth);
|
pkg_traverse(&world, print_libs, NULL, maximum_traverse_depth, PKGF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (want_variable)
|
if (want_variable)
|
||||||
{
|
{
|
||||||
wanted_something++;
|
wanted_something++;
|
||||||
pkg_traverse(&world, print_variable, NULL, 2);
|
pkg_traverse(&world, print_variable, NULL, 2, PKGF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wanted_something)
|
if (wanted_something)
|
||||||
|
|
42
pkg.c
42
pkg.c
|
@ -292,26 +292,20 @@ pkg_verify_dependency(pkg_dependency_t *pkgdep)
|
||||||
void
|
void
|
||||||
pkg_verify_graph(pkg_t *root, int depth)
|
pkg_verify_graph(pkg_t *root, int depth)
|
||||||
{
|
{
|
||||||
pkg_traverse(root, NULL, NULL, depth);
|
pkg_traverse(root, NULL, NULL, depth, PKGF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static inline void
|
||||||
* pkg_traverse(root, pkg_traverse_func, data, maxdepth)
|
pkg_walk_list(pkg_t *parent,
|
||||||
*
|
pkg_dependency_t *deplist,
|
||||||
* walk the dependency graph up to maxdepth levels. -1 means infinite recursion.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pkg_traverse(pkg_t *root,
|
|
||||||
void (*pkg_traverse_func)(pkg_t *package, void *data),
|
void (*pkg_traverse_func)(pkg_t *package, void *data),
|
||||||
void *data,
|
void *data,
|
||||||
int maxdepth)
|
int maxdepth,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
pkg_dependency_t *node;
|
pkg_dependency_t *node;
|
||||||
|
|
||||||
if (maxdepth == 0)
|
foreach_list_entry(deplist, node)
|
||||||
return;
|
|
||||||
|
|
||||||
foreach_list_entry(root->requires, node)
|
|
||||||
{
|
{
|
||||||
pkg_t *pkgdep;
|
pkg_t *pkgdep;
|
||||||
|
|
||||||
|
@ -328,8 +322,28 @@ pkg_traverse(pkg_t *root,
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_traverse(pkgdep, pkg_traverse_func, data, maxdepth - 1);
|
pkg_traverse(pkgdep, pkg_traverse_func, data, maxdepth - 1, flags);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* pkg_traverse(root, pkg_traverse_func, data, maxdepth)
|
||||||
|
*
|
||||||
|
* walk the dependency graph up to maxdepth levels. -1 means infinite recursion.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pkg_traverse(pkg_t *root,
|
||||||
|
void (*pkg_traverse_func)(pkg_t *package, void *data),
|
||||||
|
void *data,
|
||||||
|
int maxdepth,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
pkg_dependency_t *node;
|
||||||
|
|
||||||
|
if (maxdepth == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pkg_walk_list(root, root->requires, pkg_traverse_func, data, maxdepth - 1, flags);
|
||||||
|
|
||||||
if (pkg_traverse_func != NULL)
|
if (pkg_traverse_func != NULL)
|
||||||
pkg_traverse_func(root, data);
|
pkg_traverse_func(root, data);
|
||||||
|
|
5
pkg.h
5
pkg.h
|
@ -99,8 +99,11 @@ struct pkg_ {
|
||||||
pkg_tuple_t *vars;
|
pkg_tuple_t *vars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PKGF_NONE 0x0
|
||||||
|
#define PKGF_SEARCH_PRIVATE 0x1
|
||||||
|
|
||||||
pkg_t *pkg_find(const char *name);
|
pkg_t *pkg_find(const char *name);
|
||||||
void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth);
|
void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth, unsigned int flags);
|
||||||
void pkg_verify_graph(pkg_t *root, int depth);
|
void pkg_verify_graph(pkg_t *root, int depth);
|
||||||
int pkg_compare_version(const char *a, const char *b);
|
int pkg_compare_version(const char *a, const char *b);
|
||||||
pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep);
|
pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep);
|
||||||
|
|
Loading…
Reference in New Issue