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

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

53
main.c
View File

@ -93,15 +93,21 @@ print_fragment(pkg_fragment_t *frag)
} }
static void 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; pkg_fragment_t *frag;
foreach_list_entry(pkg->cflags, 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') if (want_cflags == WANT_CFLAGS_ONLY_I && frag->type != 'I')
continue; continue;
@ -111,35 +117,29 @@ print_cflags(pkg_t *pkg, void *unused)
print_fragment(frag); print_fragment(frag);
} }
} }
}
static void static void
print_libs(pkg_t *pkg, void *unused) collect_libs(pkg_t *pkg, void *data)
{
(void) unused;
if (pkg->libs != NULL)
{ {
pkg_fragment_t **list = data;
pkg_fragment_t *frag; pkg_fragment_t *frag;
foreach_list_entry(pkg->libs, frag) foreach_list_entry(pkg->libs, frag)
*list = pkg_fragment_copy(*list, frag);
if (want_static)
{ {
if (want_libs == WANT_LIBS_ONLY_LDPATH && frag->type != 'L') foreach_list_entry(pkg->libs_private, frag)
continue; *list = pkg_fragment_copy(*list, frag);
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);
} }
} }
if (want_static && pkg->libs_private != NULL) static void
print_libs(pkg_fragment_t *list)
{ {
pkg_fragment_t *frag; pkg_fragment_t *frag;
foreach_list_entry(pkg->libs_private, frag) foreach_list_entry(list, frag)
{ {
if (want_libs == WANT_LIBS_ONLY_LDPATH && frag->type != 'L') if (want_libs == WANT_LIBS_ONLY_LDPATH && frag->type != 'L')
continue; continue;
@ -151,7 +151,6 @@ print_libs(pkg_t *pkg, void *unused)
print_fragment(frag); print_fragment(frag);
} }
} }
}
static void static void
print_modversion(pkg_t *pkg, void *unused) print_modversion(pkg_t *pkg, void *unused)
@ -345,14 +344,20 @@ pkg_queue_walk(pkg_queue_t *head)
if (want_cflags) if (want_cflags)
{ {
pkg_fragment_t *list = NULL;
wanted_something++; 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) if (want_libs)
{ {
pkg_fragment_t *list = NULL;
wanted_something++; 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) if (want_variable)