diff options
author | Dan Nicholson <dbn.lists@gmail.com> | 2012-11-19 10:40:10 -0800 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2012-12-04 13:04:57 -0800 |
commit | e0d3ce93a000fa50ebd2de3397314d23d3c9d439 (patch) | |
tree | c2a7f1698f1abcf6db9390e81bd550c37739d0d1 | |
parent | 43f20b96a3d35bdcc34ec7409acdfdb3149ff426 (diff) | |
download | pkg-config-e0d3ce93a000fa50ebd2de3397314d23d3c9d439.tar.gz |
Sort -other Libs and Cflags by package order instead of path order
For some flags, pkg-config will sort them by the depth of their .pc path
before outputting. The idea is that flags from a deeper path should come
earlier in the command line. This makes sense for -L and -I flags, but
not for generic linker and compiler flags. For these flags and -l flags,
it makes sense to sort them only by package order.
-rwxr-xr-x | check/check-duplicate-flags | 4 | ||||
-rwxr-xr-x | check/check-sort-order | 16 | ||||
-rw-r--r-- | pkg.c | 9 |
3 files changed, 14 insertions, 15 deletions
diff --git a/check/check-duplicate-flags b/check/check-duplicate-flags index c80f650..b6ac788 100755 --- a/check/check-duplicate-flags +++ b/check/check-duplicate-flags @@ -4,11 +4,11 @@ set -e . ${srcdir}/common -RESULT="-DPATH2 -DFOO -DPATH1 -I/path/include" +RESULT="-DPATH2 -DPATH1 -DFOO -I/path/include" run_test --cflags flag-dup-1 flag-dup-2 run_test --cflags flag-dup-2 flag-dup-1 -RESULT="-Wl,--whole-archive --Wl,--no-whole-archive -Xlinker -R /path/lib \ +RESULT="-Wl,--whole-archive --Wl,--no-whole-archive -R -Xlinker /path/lib \ -L/path/lib -lpath2 -lpath1 -lm" run_test --libs flag-dup-1 flag-dup-2 run_test --libs flag-dup-2 flag-dup-1 diff --git a/check/check-sort-order b/check/check-sort-order index ad1bad2..94b89ef 100755 --- a/check/check-sort-order +++ b/check/check-sort-order @@ -91,7 +91,7 @@ run_test --libs sort-order-1-2 sort-order-3-2 sort-order-2-2 run_test --libs sort-order-1-2 sort-order-2-2 sort-order-3-2 # Check package set -3 -RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path3/include -I/path2/include \ +RESULT="-DPATH1 -DPATH2 -DPATH3 -I/path3/include -I/path2/include \ -I/path1/include" run_test --cflags sort-order-1-3 run_test --cflags sort-order-1-3 sort-order-2-3 @@ -103,7 +103,7 @@ run_test --cflags sort-order-2-3 sort-order-1-3 sort-order-3-3 run_test --cflags sort-order-1-3 sort-order-3-3 sort-order-2-3 run_test --cflags sort-order-1-3 sort-order-2-3 sort-order-3-3 -RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path3/lib -L/path2/lib -L/path1/lib \ +RESULT="-Wl,-O1 -Wl,-O2 -Wl,-O3 -L/path3/lib -L/path2/lib -L/path1/lib \ -lpath1 -lpath2 -lpath3" run_test --libs sort-order-1-3 run_test --libs sort-order-1-3 sort-order-2-3 @@ -119,7 +119,7 @@ run_test --libs sort-order-1-3 sort-order-2-3 sort-order-3-3 PKG_CONFIG_PATH="$order2" # Check package set -1 -RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \ +RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path2/include -I/path3/include \ -I/path1/include" run_test --cflags sort-order-3-1 run_test --cflags sort-order-3-1 sort-order-2-1 @@ -131,7 +131,7 @@ run_test --cflags sort-order-2-1 sort-order-1-1 sort-order-3-1 run_test --cflags sort-order-1-1 sort-order-3-1 sort-order-2-1 run_test --cflags sort-order-1-1 sort-order-2-1 sort-order-3-1 -RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \ +RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \ -lpath3 -lpath2 -lpath1" run_test --libs sort-order-3-1 run_test --libs sort-order-3-1 sort-order-2-1 @@ -144,7 +144,7 @@ run_test --libs sort-order-1-1 sort-order-3-1 sort-order-2-1 run_test --libs sort-order-1-1 sort-order-2-1 sort-order-3-1 # Check package set -2 -RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \ +RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path2/include -I/path3/include \ -I/path1/include" run_test --cflags sort-order-3-2 run_test --cflags sort-order-3-2 sort-order-2-2 @@ -156,7 +156,7 @@ run_test --cflags sort-order-2-2 sort-order-1-2 sort-order-3-2 run_test --cflags sort-order-1-2 sort-order-3-2 sort-order-2-2 run_test --cflags sort-order-1-2 sort-order-2-2 sort-order-3-2 -RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \ +RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \ -lpath3 -lpath2 -lpath1" run_test --libs sort-order-3-2 run_test --libs sort-order-3-2 sort-order-2-2 @@ -169,7 +169,7 @@ run_test --libs sort-order-1-2 sort-order-3-2 sort-order-2-2 run_test --libs sort-order-1-2 sort-order-2-2 sort-order-3-2 # Check package set -3 -RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \ +RESULT="-DPATH1 -DPATH2 -DPATH3 -I/path2/include -I/path3/include \ -I/path1/include" run_test --cflags sort-order-1-3 run_test --cflags sort-order-1-3 sort-order-2-3 @@ -181,7 +181,7 @@ run_test --cflags sort-order-2-3 sort-order-1-3 sort-order-3-3 run_test --cflags sort-order-1-3 sort-order-3-3 sort-order-2-3 run_test --cflags sort-order-1-3 sort-order-2-3 sort-order-3-3 -RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \ +RESULT="-Wl,-O1 -Wl,-O2 -Wl,-O3 -L/path2/lib -L/path3/lib -L/path1/lib \ -lpath1 -lpath2 -lpath3" run_test --libs sort-order-1-3 run_test --libs sort-order-1-3 sort-order-2-3 @@ -1036,11 +1036,10 @@ packages_get_flags (GList *pkgs, FlagType flags) str = g_string_new (NULL); - - /* sort flags from beginning and in forward direction except for -l */ + /* sort packages in path order for -L/-I, dependency order otherwise */ if (flags & CFLAGS_OTHER) { - cur = get_multi_merged (pkgs, get_other_cflags, TRUE, TRUE); + cur = get_multi_merged_from_back (pkgs, get_other_cflags, FALSE, TRUE); debug_spew ("adding CFLAGS_OTHER string \"%s\"\n", cur); g_string_append (str, cur); g_free (cur); @@ -1054,8 +1053,8 @@ packages_get_flags (GList *pkgs, FlagType flags) } if (flags & LIBS_OTHER) { - cur = get_multi_merged (pkgs, get_other_libs, TRUE, - !ignore_private_libs); + cur = get_multi_merged_from_back (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); |