Commit graph

84 commits

Author SHA1 Message Date
Dan Nicholson
abdbaba3e0 Ensure -isystem Cflags not compressed like -I
Treat -isystem specially like -idirafter so that multiple arguments
retain the preceding -isystem.

Freedesktop #72584 (https://bugs.freedesktop.org/show_bug.cgi?id=72584)
2013-12-14 10:47:56 -08:00
Dan Nicholson
860cab9a3e check: Rework dirafter test to handle all special cases
Expand the special flags test to check -framework usage and the handling
of multiple arguments.
2013-12-14 10:47:56 -08:00
Marek Kasik
50c2867f4a Unquote values of requested variables
If a --variable is requested, make sure to remove the quoting since it's
likely the value will be used verbatim in shell command substitution. If
the quotes remain in the value, they'd get embedded in the shell
variable, too.

Freedesktop #67904 (https://bugs.freedesktop.org/show_bug.cgi?id=67904)
2013-09-15 10:27:35 -07:00
Dan Nicholson
dbf1b7cd09 check: Convert paths to Windows format when using --define-prefix
When pkg-config redefines the .pc file's prefix variable, it will be in
the platform's native format. Convert the expected results as
necessary. This only affects the relocatable test because it explicitly
sets --define-prefix or uses .pc files in a pkgconfig/ directory. Other
tests do not have their prefixes redefined for this reason.
2013-05-31 05:31:02 -07:00
Dan Nicholson
719abc7910 check: Make relocatable script executable 2013-05-22 05:28:54 -07:00
Dan Nicholson
715cc306b0 Allow errors in .pc files for --list-all
Normally, the parser will exit immediately when it encounters errors in
.pc files. This is good most of the time, but for --list-all, the
purpose is to just get a quick list of packages and not to validate .pc
files. This is especially the case for pkg-config wrappers such as the
Ruby or Bash completion modules that scrape the output from --list-all
and don't expect to encounter errors there.

Freedesktop #26615 (https://bugs.freedesktop.org/show_bug.cgi?id=26615)
2013-05-17 05:53:13 -07:00
Dan Nicholson
2f41b2de42 Silence errors by default with --list-all
When listing all packages, the purpose is to get a quick look at what's
installed and not to scrutinize the validity of each .pc file. To see
errors from the parser during --list-all, the user can just add
--print-errors.
2013-05-17 05:49:02 -07:00
Dan Nicholson
32427bf2c6 check: Test relocatable features
Exercise the ${pcfiledir} and --define-prefix features for allowing
relocation of packages. The --define-prefix test .pc files are put in a
pkgconfig subdirectory since the feature will only be enabled in that
situation.
2013-05-17 05:13:15 -07:00
Dan Nicholson
e7238e823f check: Define all useful build directories in config.sh
Define all the autoconf build directories besides srcdir, which is
required to run the test scripts and set by "make check", and builddir,
which is always assumed to be ".".
2013-05-17 05:13:15 -07:00
Dan Nicholson
d04105f2e2 check: Make check-tilde executable like all other test scripts 2013-04-20 08:38:02 -07:00
Dan Nicholson
7328e6fc9e Run cmd through Wine when available
If we have Wine, it will provide cmd so we can build the pkg-config path
for the test.
2013-04-09 05:45:40 -07:00
Dan Nicholson
80c2777b22 Substitute TESTS_PKG_CONFIG from configure
This just paves the way to calculate more useful defaults in a shell.
2013-04-09 05:45:40 -07:00
Dan Nicholson
85dce61788 Adjust PKG_CONFIG_PATH for tests correctly on Windows
For native Windows, the PKG_CONFIG_PATH separator is ; rather than :.
2013-04-09 05:45:07 -07:00
Dan Nicholson
bfe139da8c Mangle expected sysroot output to match MSYS shell
MSYS mangles UNIX paths on execution such that it prepends its root in
Windows format. This affects PKG_CONFIG_SYSROOT_DIR and thus the
check-sysroot test. Detect MSYS from the OSTYPE environment variable and
adjust the expected test results to match. This likely means that
sysroot support doesn't actually work on MSYS, but there probably aren't
any toolchains that support sysroot there, anyway.
2013-04-09 05:43:24 -07:00
Dan Nicholson
f6212f6b97 Adjust expected path for native Windows test
When check-path is run on native Windows (MINGW), that path reported
by `pkg-config --variable=pc_path pkg-config` is adjusted to the
directory pkg-config is run from. Adjust the expected result based on
getting the current directory from cmd in Windows format.
2013-04-09 05:41:38 -07:00
Dan Nicholson
3da597804f Fix srcdir != builddir error in check-debug
Another fix for the fragile check-debug test where a message about
adding to the pkg-config path expected '.' to be the srcdir.
2013-01-23 11:11:21 -08:00
Dan Nicholson
1694230365 Merge branch 'flag-order-fixes' 2013-01-22 05:11:59 -08:00
Dan Nicholson
86c45f0422 Fix handling of --print/silence-errors for all output options
The intention was that errors would be printed for all output options
besides --exists and --atleast/exact/max-version, which are intended to
operate silently. Since want_exists is always set for these latter
options, we can simply use that as the condition and catch all other
output options automatically.

Freedesktop #54390 (https://bugs.freedesktop.org/show_bug.cgi?id=54390)
2012-12-11 12:00:26 -08:00
Dan Nicholson
9cd35c624f Enforce that only the first --atleast/exact/max-version option honored
This provides the user with output matching the behavior of the code.
When multiple --atleast/exact/max-version options are supplied, only the
first will be honored.
2012-12-11 11:59:40 -08:00
Dan Nicholson
548ba5b223 Imply --exists when --atleast/exact/max-version passed
The --atleast/exact/max-version help description implied that it would
return as --exists does. However, this would only occur if no other
output options were set.

Freedesktop #54389 (https://bugs.freedesktop.org/show_bug.cgi?id=54389)
2012-12-11 11:59:40 -08:00
Dan Nicholson
ec11c93ef8 Explicitly set --exists as the default option
This happened basically by accident before when "pkg-config foo" was run
because the code wouldn't find any options set and just fall through to
the end after processing the package arguments. However, it would act
differently in that Requires.private was only enabled with an explicit
--exists.
2012-12-11 11:59:40 -08:00
Dan Nicholson
d1b7dd42d1 Enforce exclusive output options
Currently, any output option (e.g., --version or --libs) will be set as
valid and what's output is at the mercy of the order of the output
handling code in main(). However, most combinations of output would make
no sense to be used together. For example, mixing --modversion and
--print-provides provides no way to differentiate between the output
from the options. Further, mixing --variable and --cflags currently
causes an error because there's no space separating the option outputs.

Instead, keep track of when an output option has been set and ignore
subsequent output options. There are currently two exceptions:

1. Any combination of --cflags* and --libs* are allowed.

2. Both --print-requires and --print-requires-private can be used
   together as the user may just not care which is private.

Freedesktop #54391 (https://bugs.freedesktop.org/show_bug.cgi?id=54391)
2012-12-11 11:59:40 -08:00
Dan Nicholson
cd2520a004 Fix hardcoded version if check-debug 2012-12-11 11:58:57 -08:00
Michał Sawicz
69beecddb5 Allow ~ through unescaped
freedesktop #57078 (https://bugs.freedesktop.org/show_bug.cgi?id=57078)
2012-12-08 12:11:55 -08:00
Dan Nicholson
9adfd9ebfc Only strip duplicate arguments when they appear consecutively
pkg-config strips all duplicate arguments from the flag output string.
This is done for 2 reasons:

1. When a package shows up twice in the final package list after
resolving all Requires, stripping was used to ensure it's flags only
showed up once at the correct location.

2. An optimization so that the output string is not excessively long.

Since commit c6ec7869, 1. is no longer necessary as the final package
list only contains each package once. 2. causes problems when applied
too aggressively since some arguments have different semantics depending
on the prior or subsequent arguments.

To keep a bit of optimization, the stripping is reduced to only removing
consecutive duplicate arguments. This should ensure that the semantics
are kept intact while removing obviously unnecessary arguments.

The drawback is that some arguments will now appear multiple times in
the output when they previously would have only appeared once. Here we
have to rely on the tools using these arguments to handle the duplicates
appropriately since there is no way for pkg-config to encode all the
semantics of those arguments. Another thing that can help this situation
is if pkg-config is used for all packages in the Requires chain so that
the Libs/Cflags of each package only pertain to itself and don't encode
the compiling/linking rules of a 3rd party package.

Freedesktop #16101 (https://bugs.freedesktop.org/show_bug.cgi?id=16101)
2012-12-04 13:04:57 -08:00
Dan Nicholson
5b6ec1b6e9 Output -l and other Libs flags in the order they appear
Often other Libs flags have semantics that are based on their context
with -l arguments. For example, the GNU linker options
-Bdynamic/-Bstatic pertain only to the objects or link options that
follow them. So, a valid link command containing these options would get
mangled by pkg-config since it separates -l flags from others..

-Bdynamic -la -Bstatic -lb -> -Bdynamic -Bstatic -la -lb

Instead, output -l and other Libs flags in a single pass so they mantain
their ordering.

Freedesktop #19950 (https://bugs.freedesktop.org/show_bug.cgi?id=19950)
2012-12-04 13:04:57 -08:00
Dan Nicholson
05f319d3e5 Output -L Libs flags before other Libs flags
Outputting other Libs flags such as -Wl,foo just prior to the -l Libs
flags gives a better chance the --libs output will be correct. This
should be no change in the usage of the output since pkg-config
currently groups all flag types together.
2012-12-04 13:04:57 -08:00
Dan Nicholson
e0d3ce93a0 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.
2012-12-04 13:04:57 -08:00
Dan Nicholson
360a614af8 Start from end of package lists when processing Requires
Prior to commit 6ecf318, the resolved list of required packages was
built in an appending way where each package on the command line or in
Requires would appear in the list in the order they appeared. With
6ecf318, that list building was changed to prepending, which had a
subtle change on the resolved order.

For example, suppose package a has "Requires: b c d". Previously, the
list would be built as a->b->c->d by appending each as they were
encountered. Now, the list is built by walking all the way down the
dependency chain for each package in a depth first manner and prepending
packages while unwinding. This would result in the package ilst being
a->d->c->b. This same effect happens with the command line packages
where previously requesting packages x and y would create a package list
of x->y and now produces a list of y->x.

While technically these should be the same since there are no
interdependencies, it's causes flags to be output in different order
than previously in pkg-config. This can be seen most readily in the
check-gtk test.

Instead, operate on the package lists backwards when building the
resolved package list.
2012-12-03 07:08:20 -08:00
Dan Nicholson
428362266e Remove duplicate packages after resolving requires
Makes the resolved package list be correctly serialized with each
package only appearing once. This provides more consistency between the
various flag outputs by ensuring that the flags from each package are
only grabbed once. This makes a difference since the duplicate flag
stripping happens from the end of the output (-l) or the beginning of
the output (-L/-I/other).
2012-12-03 07:05:43 -08:00
Dan Nicholson
d6337ec986 Always use --static test results for indirect depencency results
Often the expected results for the indirect dependency tests fell behind
because it's not a typical test scenario. However, since the results are
always the same as --static, they can just use the same results and the
test can be run conditionally without --static based on configuration.
2012-11-29 19:18:41 -08:00
Dan Nicholson
160177d8d2 Add a gtk testcase to provide something with complex interactions
The pkg-config testsuite has pretty good coverage of the implementation,
but it lacks a complex case that tests the interactions of non-trivial
.pc files. gtk is a very common package that meets this goal. This is a
snapshot from my F16 system, and it should provide a good way to see how
changes in the implementation regress a real world case.
2012-11-28 05:59:49 -08:00
Dan Nicholson
f5b93bf1b1 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.
2012-11-28 05:52:13 -08:00
Dan Nicholson
3e54448158 Test ordering of flags based on package depth and path
The current tests are good at checking whether gathering the Cflags or
Libs from one or two packages works correctly, but they don't check the
sorting algorithm much at all. In particular, the interactions between
the package order in the Requires chain and in the path can make the
sorting of the flags subtly different.
2012-11-28 05:52:06 -08:00
Dan Nicholson
90ed8f193f Allow all combinations of --cflags and --libs variants
Use a bitmask to keep track of what Libs/Cflags to output. This makes it
simple to handle any combination of --cflags and --libs option variants.
A lot of excess code is removed in the process as all the flags options
can now be carried around in a single variable.

Freedesktop #54388 (https://bugs.freedesktop.org/show_bug.cgi?id=54388)
2012-11-03 11:07:59 -07:00
Dan Nicholson
1184d2085a Don't crash on --print-variables when there are no variables
Apparently g_hash_table_foreach doesn't check for NULL input, so make
sure we don't call it to print the variables if the variable list is
empty.

Freedesktop #54721
2012-10-13 09:06:18 -07:00
Dan Nicholson
6d6dd43e75 Support circular Requires loops
After the packages are parsed, pkg-config recurses through all the
required packages to generate one list. Before descending another level,
check to see if the package has already been handled and skip it. This
allows packages to require each other circularly by breaking the loop.

A test has been added resolving a two level deep circular dependency.

Freedesktop #7331
2012-10-13 08:14:35 -07:00
Dan Nicholson
6ecf318c92 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
2012-10-13 08:14:35 -07:00
Dan Nicholson
65e37fe303 check: Test version comparisons within Requires fields
Verification of versions in Requires and friends happens differently
than the version comparison for command-line packages.
2012-10-03 05:33:32 -07:00
Dan Nicholson
9a54c588a5 check: Test all variants of --cflags and --libs
Make sure that the --*-only-* variants of --cflags and --libs do the
right thing. This should probably be extended to cover a chain of
packages to get the ordering right, but this is good for now.
2012-10-03 05:33:31 -07:00
Dan Nicholson
0a5d54d091 check: Ensure unknown options fail 2012-10-03 05:33:31 -07:00
Dan Nicholson
d4c0c14ba8 check: Ensure debugging output works correctly
This might be a little fragile, but it makes sure to exercise the
debug_spew function.
2012-10-03 05:33:31 -07:00
Dan Nicholson
4f7d2a1b28 check: Test -uninstalled functionality
Test the usage of -uninstalled packages with two .pc files: inst.pc and
inst-uninstalled.pc. pkg-config should prefer the -uninstalled version
unless PKG_CONFIG_DISABLE_UNINSTALLED is set. It should also use the
default value of pc_top_builddir unless PKG_CONFIG_TOP_BUILD_DIR is set.
2012-10-03 05:33:31 -07:00
Dan Nicholson
4426d487eb check: Test sysroot support
Checks that pkg-config prepends PKG_CONFIG_SYSROOT_DIR to -I and -L when
they don't point to system directories.
2012-10-03 05:33:31 -07:00
Dan Nicholson
42f30aee2e check: Test pkg-config version
Test that --version prints the current version and
--atleast-pkgconfig-version validates it.
2012-10-02 05:51:22 -07:00
Dan Nicholson
aba2c047cf check: Enhance --print-requires tests
Make the --print-requires and --print-requires-private tests actually
resolve Requires and output a specific version test.
2012-10-02 05:51:22 -07:00
Dan Nicholson
0e6ea44d68 check: Check path handling
Add a test for pkg-config's path handling. The first test covers
PKG_CONFIG_PATH, and the second covers the built-in path. For this one
we need to unset the PKG_CONFIG_LIBDIR that normally is set during the
tests. Since we can't rely on the contents of the default path, we just
check to see that the built-in path matches what was specified in
configure. To do this, we need to add a bunch of variables to config.sh
so the variable resolves. These variables don't need to be exported,
though.
2012-10-02 05:51:22 -07:00
Dan Nicholson
c7e12356bc check: Exercise all printing options
Add tests for checking the output of various options that print
information. For --list-all, a subdirectory with only two packages has
been added so that its output doesn't change when more test packages are
added to the check directory.
2012-09-29 09:57:46 -07:00
Dan Nicholson
31a9f900e1 check: Test --define-variable corner cases 2012-09-29 09:09:30 -07:00
Dan Nicholson
397d414a6a check: Pass args to test function instead of setting in variable
The run_test shell function was running pkg-config with arguments stored
in an environment variable. This has problems when trying to pass shell
special characters with the proper escaping. Instead, pass the arguments
to the test where they can maintain correct formatting through use of
the special variable "$@".
2012-09-29 08:50:57 -07:00