main: separate CFLAGS and LIBS collection and printing steps into two phases.

feature/tap-sh
William Pitcock 2012-05-03 20:37:24 +00:00
parent d94ab7555d
commit a4a572f608
1 changed files with 51 additions and 46 deletions

67
main.c
View File

@ -93,15 +93,21 @@ print_fragment(pkg_fragment_t *frag)
}
static void
print_cflags(pkg_t *pkg, void *unused)
collect_cflags(pkg_t *pkg, void *data)
{
(void) unused;
if (pkg->cflags != NULL)
{
pkg_fragment_t **list = data;
pkg_fragment_t *frag;
foreach_list_entry(pkg->cflags, frag)
*list = pkg_fragment_copy(*list, frag);
}
static void
print_cflags(pkg_fragment_t *list)
{
pkg_fragment_t *frag;
foreach_list_entry(list, frag)
{
if (want_cflags == WANT_CFLAGS_ONLY_I && frag->type != 'I')
continue;
@ -110,19 +116,30 @@ print_cflags(pkg_t *pkg, void *unused)
print_fragment(frag);
}
}
static void
collect_libs(pkg_t *pkg, void *data)
{
pkg_fragment_t **list = data;
pkg_fragment_t *frag;
foreach_list_entry(pkg->libs, frag)
*list = pkg_fragment_copy(*list, frag);
if (want_static)
{
foreach_list_entry(pkg->libs_private, frag)
*list = pkg_fragment_copy(*list, frag);
}
}
static void
print_libs(pkg_t *pkg, void *unused)
print_libs(pkg_fragment_t *list)
{
(void) unused;
if (pkg->libs != NULL)
{
pkg_fragment_t *frag;
foreach_list_entry(pkg->libs, frag)
foreach_list_entry(list, frag)
{
if (want_libs == WANT_LIBS_ONLY_LDPATH && frag->type != 'L')
continue;
@ -133,24 +150,6 @@ print_libs(pkg_t *pkg, void *unused)
print_fragment(frag);
}
}
if (want_static && pkg->libs_private != NULL)
{
pkg_fragment_t *frag;
foreach_list_entry(pkg->libs_private, frag)
{
if (want_libs == WANT_LIBS_ONLY_LDPATH && frag->type != 'L')
continue;
else if (want_libs == WANT_LIBS_ONLY_LIBNAME && frag->type != 'l')
continue;
else if (want_libs == WANT_LIBS_ONLY_OTHER && (frag->type == 'l' || frag->type == 'L'))
continue;
print_fragment(frag);
}
}
}
static void
@ -345,14 +344,20 @@ pkg_queue_walk(pkg_queue_t *head)
if (want_cflags)
{
pkg_fragment_t *list = NULL;
wanted_something++;
pkg_traverse(&world, print_cflags, NULL, maximum_traverse_depth, global_traverse_flags | PKGF_SEARCH_PRIVATE);
pkg_traverse(&world, collect_cflags, &list, maximum_traverse_depth, global_traverse_flags | PKGF_SEARCH_PRIVATE);
print_cflags(list);
}
if (want_libs)
{
pkg_fragment_t *list = NULL;
wanted_something++;
pkg_traverse(&world, print_libs, NULL, maximum_traverse_depth, global_traverse_flags);
pkg_traverse(&world, collect_libs, &list, maximum_traverse_depth, global_traverse_flags);
print_libs(list);
}
if (want_variable)