From 2ecb181fe6394450a7a6a0272e98e6f4444e6689 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 11 May 2012 20:16:22 -0500 Subject: [PATCH] pkg: add pkg_libs() for calculating the mergemaster set of linker flags (issue #11) --- pkg.c | 25 +++++++++++++++++++++++++ pkg.h | 1 + 2 files changed, 26 insertions(+) diff --git a/pkg.c b/pkg.c index afd2a75..2b48f30 100644 --- a/pkg.c +++ b/pkg.c @@ -669,3 +669,28 @@ pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags) return head; } +static void +pkg_libs_collect(pkg_t *pkg, void *data, unsigned int flags) +{ + pkg_fragment_t **list = data; + pkg_fragment_t *frag; + + PKG_FOREACH_LIST_ENTRY(pkg->libs, frag) + *list = pkg_fragment_copy(*list, frag); + + if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS) + { + PKG_FOREACH_LIST_ENTRY(pkg->libs_private, frag) + *list = pkg_fragment_copy(*list, frag); + } +} + +pkg_fragment_t * +pkg_libs(pkg_t *root, int maxdepth, unsigned int flags) +{ + pkg_fragment_t *head = NULL; + + pkg_traverse(root, pkg_libs_collect, &head, maxdepth, flags); + + return head; +} diff --git a/pkg.h b/pkg.h index 820dc36..ce228c5 100644 --- a/pkg.h +++ b/pkg.h @@ -133,6 +133,7 @@ int pkg_compare_version(const char *a, const char *b); pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); const char *pkg_get_comparator(pkg_dependency_t *pkgdep); pkg_fragment_t *pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags); +pkg_fragment_t *pkg_libs(pkg_t *root, int maxdepth, unsigned int flags); /* parse.c */ pkg_t *pkg_new_from_file(const char *path, FILE *f);