pkg: add pkg_libs() for calculating the mergemaster set of linker flags (issue #11)

pull/29/head
William Pitcock 2012-05-11 20:16:22 -05:00
parent b8e538ecea
commit 2ecb181fe6
2 changed files with 26 additions and 0 deletions

25
pkg.c
View File

@ -669,3 +669,28 @@ pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags)
return head; 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;
}

1
pkg.h
View File

@ -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); pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
const char *pkg_get_comparator(pkg_dependency_t *pkgdep); 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_cflags(pkg_t *root, int maxdepth, unsigned int flags);
pkg_fragment_t *pkg_libs(pkg_t *root, int maxdepth, unsigned int flags);
/* parse.c */ /* parse.c */
pkg_t *pkg_new_from_file(const char *path, FILE *f); pkg_t *pkg_new_from_file(const char *path, FILE *f);