Test stripping of duplicate flags

pkg-config aggressively strips all duplicate arguments from the final
output it builds. This is not only and optimization, but it also allows
the flag ordering to work correctly when a package on the command line
is required by another on the command line.
This commit is contained in:
Dan Nicholson 2012-11-13 05:51:18 -08:00
parent 3e54448158
commit f5b93bf1b1
4 changed files with 40 additions and 1 deletions

View file

@ -15,6 +15,7 @@ TESTS = \
check-missing \
check-idirafter \
check-sort-order \
check-duplicate-flags \
check-whitespace \
check-cmd-options \
check-version \
@ -61,4 +62,6 @@ EXTRA_DIST = \
sort/sort/sort-order-3-2.pc \
sort-order-1-3.pc \
sort/sort-order-2-3.pc \
sort/sort/sort-order-3-3.pc
sort/sort/sort-order-3-3.pc \
flag-dup-1.pc \
flag-dup-2.pc

15
check/check-duplicate-flags Executable file
View file

@ -0,0 +1,15 @@
#! /bin/sh
set -e
. ${srcdir}/common
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 \
-L/path/lib -lpath2 -lpath1 -lm"
run_test --libs flag-dup-1 flag-dup-2
run_test --libs flag-dup-2 flag-dup-1

10
check/flag-dup-1.pc Normal file
View file

@ -0,0 +1,10 @@
prefix=/path
exec_prefix=${prefix}
libdir="${exec_prefix}/lib"
includedir="${prefix}/include"
Name: Flag duplicate test 1
Description: Test package for checking stripping of duplicate flags
Version: 1.0.0
Libs: -L${libdir} -lpath1 -Wl,--whole-archive -lm --Wl,--no-whole-archive -Xlinker -R -Xlinker ${libdir}
Cflags: -I${includedir} -DPATH1 -DFOO

11
check/flag-dup-2.pc Normal file
View file

@ -0,0 +1,11 @@
prefix=/path
exec_prefix=${prefix}
libdir="${exec_prefix}/lib"
includedir="${prefix}/include"
Name: Flag duplicate test 2
Description: Test package for checking stripping of duplicate flags
Version: 1.0.0
Libs: -L${libdir} -lpath2 -Wl,--whole-archive -lm --Wl,--no-whole-archive -Xlinker -R -Xlinker ${libdir}
Cflags: -I${includedir} -DPATH2 -DFOO
Requires: flag-dup-1