summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck/check-duplicate-flags1
-rwxr-xr-xcheck/check-gtk7
-rw-r--r--pkg.c44
3 files changed, 47 insertions, 5 deletions
diff --git a/check/check-duplicate-flags b/check/check-duplicate-flags
index b1ab54b..c80f650 100755
--- a/check/check-duplicate-flags
+++ b/check/check-duplicate-flags
@@ -6,7 +6,6 @@ set -e
RESULT="-DPATH2 -DFOO -DPATH1 -I/path/include"
run_test --cflags flag-dup-1 flag-dup-2
-RESULT="-DPATH1 -DFOO -DPATH2 -I/path/include"
run_test --cflags flag-dup-2 flag-dup-1
RESULT="-Wl,--whole-archive --Wl,--no-whole-archive -Xlinker -R /path/lib \
diff --git a/check/check-gtk b/check/check-gtk
index 9795a5e..3f9aae7 100755
--- a/check/check-gtk
+++ b/check/check-gtk
@@ -14,10 +14,9 @@ PKG_CONFIG_LIBDIR=${srcdir}/gtk
# -I/gtk/include/glib-2.0 -I/gtk/lib/glib-2.0/include -I/gtk/include/pixman-1 \
# -I/gtk/include -I/gtk/include/freetype2
RESULT="-DGSEAL_ENABLE -pthread -I/gtk/include/gtk-3.0 \
--I/gtk/include/pango-1.0 -I/gtk/include -I/gtk/include/freetype2 \
--I/gtk/include/glib-2.0 -I/gtk/lib/glib-2.0/include \
--I/gtk/include/gdk-pixbuf-2.0 -I/gtk/include/cairo -I/gtk/include/pixman-1 \
--I/gtk/include/atk-1.0"
+-I/gtk/include/pango-1.0 -I/gtk/include/atk-1.0 -I/gtk/include/cairo \
+-I/gtk/include/gdk-pixbuf-2.0 -I/gtk/include -I/gtk/include/freetype2 \
+-I/gtk/include/pixman-1 -I/gtk/include/glib-2.0 -I/gtk/lib/glib-2.0/include"
run_test --cflags gtk+-3.0
run_test --cflags --static gtk+-3.0
diff --git a/pkg.c b/pkg.c
index a6825ce..148b5aa 100644
--- a/pkg.c
+++ b/pkg.c
@@ -671,6 +671,43 @@ merge_flag_lists (GList *packages, GetListFunc func, GList **listp)
}
}
+/* Work backwards from the end of the package list to remove duplicate
+ * packages. This could happen because the package was specified multiple
+ * times on the command line, or because multiple packages require the same
+ * package. When we have duplicate dependencies, starting from the end of the
+ * list ensures that the dependency shows up later in the package list and
+ * Libs will come out correctly. */
+static GList *
+package_list_strip_duplicates (GList *packages)
+{
+ GList *cur;
+ GHashTable *requires;
+
+ requires = g_hash_table_new (g_str_hash, g_str_equal);
+ for (cur = g_list_last (packages); cur != NULL; cur = g_list_previous (cur))
+ {
+ Package *pkg = cur->data;
+
+ if (g_hash_table_lookup (requires, pkg->key) != NULL)
+ {
+ GList *dup = cur;
+
+ /* Remove the duplicate package from the list */
+ debug_spew ("Removing duplicate package %s\n", pkg->key);
+ cur = cur->next;
+ packages = g_list_delete_link (packages, dup);
+ }
+ else
+ {
+ /* Unique package. Track it and move to the next. */
+ g_hash_table_insert (requires, pkg->key, pkg);
+ }
+ }
+ g_hash_table_destroy (requires);
+
+ return packages;
+}
+
static void
fill_list (GList *packages, GetListFunc func,
GList **listp, gboolean in_path_order, gboolean include_private)
@@ -689,6 +726,13 @@ fill_list (GList *packages, GetListFunc func,
tmp = tmp->next;
}
+ /* Remove duplicate packages from the recursive list. This should provide a
+ * serialized package list where all interdependencies are resolved
+ * consistently. */
+ spew_package_list (" pre-remove", expanded);
+ expanded = package_list_strip_duplicates (expanded);
+ spew_package_list ("post-remove", expanded);
+
if (in_path_order)
{
spew_package_list ("original", expanded);