summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-11-15 20:28:11 -0800
committerDan Nicholson <dbn.lists@gmail.com>2012-12-04 13:04:57 -0800
commit75a95f6f8b6cd8f43dd7467fdff0b4c9c5e44e19 (patch)
tree152eccd92a666c6f0cd3c9efbab9db466bac586e
parent8f354125d17bca2917badf2c49e6bd6995420159 (diff)
downloadpkg-config-75a95f6f8b6cd8f43dd7467fdff0b4c9c5e44e19.tar.gz
Limit merging of packages and flags to path or dependency order
Unify the get_multi_merged functions since there are only two valid ways to do the merging of packages and flags. 1. Packages are sorted by their position in the pkg-config path and then duplicate flags are stripped from the beginning of the list. This pertains to -I and -L flags. 2. Packages are sorted by dependency with most required last and then duplicate flags are stripped from the end of the list. This ensures that flags that come from packages required by multiple others come later in the output. This applies to all non-L/I flags.
-rw-r--r--pkg.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/pkg.c b/pkg.c
index 14a7e39..3891107 100644
--- a/pkg.c
+++ b/pkg.c
@@ -986,30 +986,22 @@ verify_package (Package *pkg)
}
}
-static char*
+/* Create a merged list of required packages and retrieve the flags from them.
+ * Strip the duplicates from the flags list. The sorting and stripping can be
+ * done in one of two ways: packages sorted by position in the pkg-config path
+ * and stripping done from the beginning of the list, or packages sorted from
+ * most dependent to least dependent and stripping from the end of the list.
+ * The former is done for -I/-L flags, and the latter for all others.
+ */
+static char *
get_multi_merged (GList *pkgs, GetListFunc func, gboolean in_path_order,
- gboolean include_private)
-{
- GList *list;
- char *retval;
-
- list = fill_list (pkgs, func, in_path_order, include_private);
- list = string_list_strip_duplicates (list, TRUE);
- retval = string_list_to_string (list);
- g_list_free (list);
-
- return retval;
-}
-
-static char*
-get_multi_merged_from_back (GList *pkgs, GetListFunc func,
- gboolean in_path_order, gboolean include_private)
+ gboolean include_private)
{
GList *list;
char *retval;
list = fill_list (pkgs, func, in_path_order, include_private);
- list = string_list_strip_duplicates (list, FALSE);
+ list = string_list_strip_duplicates (list, in_path_order);
retval = string_list_to_string (list);
g_list_free (list);
@@ -1027,7 +1019,7 @@ packages_get_flags (GList *pkgs, FlagType flags)
/* sort packages in path order for -L/-I, dependency order otherwise */
if (flags & CFLAGS_OTHER)
{
- cur = get_multi_merged_from_back (pkgs, get_other_cflags, FALSE, TRUE);
+ cur = get_multi_merged (pkgs, get_other_cflags, FALSE, TRUE);
debug_spew ("adding CFLAGS_OTHER string \"%s\"\n", cur);
g_string_append (str, cur);
g_free (cur);
@@ -1041,8 +1033,8 @@ packages_get_flags (GList *pkgs, FlagType flags)
}
if (flags & LIBS_OTHER)
{
- cur = get_multi_merged_from_back (pkgs, get_other_libs, FALSE,
- !ignore_private_libs);
+ cur = get_multi_merged (pkgs, get_other_libs, FALSE,
+ !ignore_private_libs);
debug_spew ("adding LIBS_OTHER string \"%s\"\n", cur);
g_string_append (str, cur);
g_free (cur);
@@ -1056,8 +1048,7 @@ packages_get_flags (GList *pkgs, FlagType flags)
}
if (flags & LIBS_l)
{
- cur = get_multi_merged_from_back (pkgs, get_l_libs, FALSE,
- !ignore_private_libs);
+ cur = get_multi_merged (pkgs, get_l_libs, FALSE, !ignore_private_libs);
debug_spew ("adding LIBS_l string \"%s\"\n", cur);
g_string_append (str, cur);
g_free (cur);