mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2025-12-20 20:40:02 +01:00
Consistently resolve requires depth-first to fix non-l flag ordering
recursive_fill_list() is used to order Requires and Requires.private, but it relied on fill_one_level() to make the list adjustments as it descended the package tree. There were two issues with this approach: 1. It added all the dependencies from a package immediately rather than descending through each dependency first. This made it sort of mix between depth- and breadth-first resolving. 2. It did not add the requested package to the list, forcing the caller to add it. This simplifies the code so that it descends all the way to the least dependent package and prepends them as it unwinds. This ensures the ordering will be sorted from most dependent to least dependent package. Ordering of -l flags is corrected by a later sorting, but this fixes ordering on non-l flags. Add a new test specifically for non-l Libs flags. Freedesktop #34504
This commit is contained in:
parent
02ca585fa6
commit
6ecf318c92
7 changed files with 40 additions and 16 deletions
|
|
@ -4,6 +4,7 @@ TESTS_ENVIRONMENT = PKG_CONFIG='$(TESTS_PKG_CONFIG)' $(TESTS_SHELL)
|
|||
TESTS = \
|
||||
check-cflags \
|
||||
check-libs \
|
||||
check-non-l-flags \
|
||||
check-define-variable \
|
||||
check-libs-private \
|
||||
check-requires-private \
|
||||
|
|
@ -42,4 +43,6 @@ EXTRA_DIST = \
|
|||
other.pc \
|
||||
requires-version-1.pc \
|
||||
requires-version-2.pc \
|
||||
requires-version-3.pc
|
||||
requires-version-3.pc \
|
||||
non-l.pc \
|
||||
non-l-required.pc
|
||||
|
|
|
|||
17
check/check-non-l-flags
Executable file
17
check/check-non-l-flags
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
. ${srcdir}/common
|
||||
|
||||
RESULT="-I/non-l/include -I/non-l-required/include"
|
||||
run_test --cflags non-l-required non-l
|
||||
|
||||
RESULT="-I/non-l/include -I/non-l-required/include"
|
||||
run_test --cflags --static non-l-required non-l
|
||||
|
||||
RESULT="/non-l.a /non-l-required.a -pthread"
|
||||
run_test --libs non-l-required non-l
|
||||
|
||||
RESULT="/non-l.a /non-l-required.a -pthread"
|
||||
run_test --libs --static non-l-required non-l
|
||||
|
|
@ -5,21 +5,21 @@ set -e
|
|||
. ${srcdir}/common
|
||||
|
||||
# expect cflags from requires-test and public-dep
|
||||
RESULT="-I/requires-test/include -I/private-dep/include -I/public-dep/include"
|
||||
RESULT="-I/requires-test/include -I/public-dep/include -I/private-dep/include"
|
||||
run_test --cflags requires-test
|
||||
|
||||
# still expect those cflags for static linking case
|
||||
RESULT="-I/requires-test/include -I/private-dep/include -I/public-dep/include"
|
||||
RESULT="-I/requires-test/include -I/public-dep/include -I/private-dep/include"
|
||||
run_test --static --cflags requires-test
|
||||
|
||||
# expect libs for just requires-test and public-dep
|
||||
if [ "$list_indirect_deps" = "yes" ]; then
|
||||
RESULT="-L/requires-test/lib -L/private-dep/lib -L/public-dep/lib -lrequires-test -lprivate-dep -lpublic-dep"
|
||||
RESULT="-L/requires-test/lib -L/public-dep/lib -L/private-dep/lib -lrequires-test -lpublic-dep -lprivate-dep"
|
||||
else
|
||||
RESULT="-L/requires-test/lib -L/public-dep/lib -lrequires-test -lpublic-dep"
|
||||
fi
|
||||
run_test --libs requires-test
|
||||
|
||||
# expect libs for requires-test, public-dep and private-dep in static case
|
||||
RESULT="-L/requires-test/lib -L/private-dep/lib -L/public-dep/lib -lrequires-test -lprivate-dep -lpublic-dep"
|
||||
RESULT="-L/requires-test/lib -L/public-dep/lib -L/private-dep/lib -lrequires-test -lpublic-dep -lprivate-dep"
|
||||
run_test --static --libs requires-test
|
||||
|
|
|
|||
5
check/non-l-required.pc
Normal file
5
check/non-l-required.pc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Name: Non-l flags required test package
|
||||
Description: Test package for checking order of non-L Libs & Cflags
|
||||
Version: 1.0.0
|
||||
Libs: /non-l-required.a -pthread
|
||||
Cflags: -I/non-l-required/include
|
||||
6
check/non-l.pc
Normal file
6
check/non-l.pc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
Name: Non-l flags test package
|
||||
Description: Test package for checking order of non-L Libs & Cflags
|
||||
Version: 1.0.0
|
||||
Requires: non-l-required
|
||||
Libs: /non-l.a
|
||||
Cflags: -I/non-l/include
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
Name: Requires test package
|
||||
Description: Dummy pkgconfig test package for testing Requires/Requires.private
|
||||
Version: 1.0.0
|
||||
Requires.private:
|
||||
Libs: -L/public-dep/lib -lpublic-dep
|
||||
Cflags: -I/public-dep/include
|
||||
|
|
|
|||
14
pkg.c
14
pkg.c
|
|
@ -580,16 +580,10 @@ recursive_fill_list (Package *pkg, GetListFunc func, GSList **listp)
|
|||
*/
|
||||
g_assert (func == get_requires || func == get_requires_private);
|
||||
|
||||
fill_one_level (pkg, func, listp);
|
||||
|
||||
tmp = (*func) (pkg);
|
||||
for (tmp = (*func) (pkg); tmp != NULL; tmp = g_slist_next (tmp))
|
||||
recursive_fill_list (tmp->data, func, listp);
|
||||
|
||||
while (tmp != NULL)
|
||||
{
|
||||
recursive_fill_list (tmp->data, func, listp);
|
||||
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
*listp = g_slist_prepend (*listp, pkg);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -603,7 +597,6 @@ fill_list (GSList *packages, GetListFunc func,
|
|||
tmp = packages;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
expanded = g_slist_append (expanded, tmp->data);
|
||||
recursive_fill_list (tmp->data,
|
||||
include_private ? get_requires_private : get_requires,
|
||||
&expanded);
|
||||
|
|
@ -727,7 +720,6 @@ verify_package (Package *pkg)
|
|||
/* Make sure we didn't drag in any conflicts via Requires
|
||||
* (inefficient algorithm, who cares)
|
||||
*/
|
||||
|
||||
recursive_fill_list (pkg, get_requires_private, &requires);
|
||||
conflicts = get_conflicts (pkg);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue