From 4a1b88fcc42a518251eb4d21de4e662e77cd34c6 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 24 Aug 2016 11:04:12 -0500 Subject: [PATCH] main: implement --print-provides, but not actual Provides support. It turns out pkg-config's provides support is incomplete (only --print-provides is implemented), so we are going to hold off on implementing support for Provides until 1.1. --- main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 30232be..17d98f0 100644 --- a/main.c +++ b/main.c @@ -250,6 +250,49 @@ print_requires_private(pkgconf_pkg_t *pkg) } } +static void +print_provides(pkgconf_pkg_t *pkg) +{ +#ifdef NOTYET + pkgconf_node_t *node; + + PKGCONF_FOREACH_LIST_ENTRY(pkg->provides.head, node) + { + pkgconf_dependency_t *dep = node->data; + + printf("%s", dep->package); + + if (dep->version != NULL) + printf(" %s %s", pkgconf_pkg_get_comparator(dep), dep->version); + + printf("\n"); + } +#endif + + printf("%s = %s\n", pkg->id, pkg->version); +} + +static bool +apply_provides(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) +{ + pkgconf_node_t *iter; + (void) unused; + (void) maxdepth; + + PKGCONF_FOREACH_LIST_ENTRY(world->requires.head, iter) + { + pkgconf_pkg_t *pkg; + pkgconf_dependency_t *dep = iter->data; + + pkg = pkgconf_pkg_verify_dependency(dep, flags, NULL); + print_provides(pkg); + + pkgconf_pkg_free(pkg); + } + + return true; +} + static void print_digraph_node(pkgconf_pkg_t *pkg, void *unused, unsigned int flags) { @@ -937,10 +980,13 @@ main(int argc, char *argv[]) if ((want_flags & PKG_PROVIDES) == PKG_PROVIDES) { - fprintf(stderr, "pkgconf: warning: --print-provides requested which is intentionally unimplemented, along with\n"); - fprintf(stderr, " the rest of the Provides system. The Provides system is broken by design and requires loading every\n"); - fprintf(stderr, " package module to calculate the dependency graph. In practice, there are no consumers of this system\n"); - fprintf(stderr, " so it will remain unimplemented until such time that something actually uses it.\n"); + want_flags &= ~(PKG_CFLAGS|PKG_LIBS); + + if (!pkgconf_queue_apply(&pkgq, apply_provides, maximum_traverse_depth, global_traverse_flags, NULL)) + { + ret = EXIT_FAILURE; + goto out; + } } if ((want_flags & PKG_DIGRAPH) == PKG_DIGRAPH)