summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Only strip duplicate arguments when they appear consecutivelyflag-order-fixesDan Nicholson2012-12-043-39/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Output -l and other Libs flags in the order they appearDan Nicholson2012-12-045-34/+27
| | | | | | | | | | | | | | | 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)
* Keep Libs and Cflags together to maintain orderingDan Nicholson2012-12-043-102/+112
| | | | | | Instead of splitting to -l/-L/other and -I/other, keep the args together and mark each argument with its type. Then we can maintain order all the way through.
* Output -L Libs flags before other Libs flagsDan Nicholson2012-12-047-25/+25
| | | | | | | 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.
* Pass around flags types instead of function pointersDan Nicholson2012-12-041-80/+46
| | | | | This makes the code uglier in the short term, but prepares for using merged lists of Cflags and Libs in one go.
* Limit merging of packages and flags to path or dependency orderDan Nicholson2012-12-041-23/+14
| | | | | | | | | | | | | | Unify the get_multi_merged functions since there are only two valid ways to do the merging of packages and flags. 1. Packages are sorted by their position in the pkg-config path and then duplicate flags are stripped from the beginning of the list. This pertains to -I and -L flags. 2. Packages are sorted by dependency with most required last and then duplicate flags are stripped from the end of the list. This ensures that flags that come from packages required by multiple others come later in the output. This applies to all non-L/I flags.
* Unify string list stripping functions and operate on list in placeDan Nicholson2012-12-041-37/+20
| | | | | | There were two string list stripping functions, when the only difference was to operate from the beginning or end of the list. Also, the function was copying the list and operating on that unnecessarily.
* Cleanup prototypes for list operating functionsDan Nicholson2012-12-041-13/+18
| | | | | Instead of having a list as an out parameter when it they have no elements, just return the list to the caller. Cleans up some code a bit.
* Sort -other Libs and Cflags by package order instead of path orderDan Nicholson2012-12-043-15/+14
| | | | | | | | 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.
* Fix one hash table optimization to use key=valueDan Nicholson2012-12-041-1/+1
| | | | | | Commit 428335e changed some hash tables to be used as sets where the key equals the value since glib has some optimization for that. Unfortunately, the package list stripping table wasn't fixed corectly.
* Optimize hash table when usage is only as a setDan Nicholson2012-12-031-6/+6
| | | | | | | | | When searching for duplicate strings in the output list, a hash table is used to keep track of which strings have been seen. This usage as a set can be optimized as described in the documentation to not allocate or free the hash table values: http://developer.gnome.org/glib/stable/glib-Hash-Tables.html#glib-Hash-Tables.description
* Remove duplicate string list elements in placeDan Nicholson2012-12-031-43/+26
| | | | | | Similar to the removal of duplicate packages, this can be more efficient if we don't build a new list and instead just remove the elements in place.
* Start from end of package lists when processing RequiresDan Nicholson2012-12-034-32/+26
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Traverse list backwards instead of copying and reversingDan Nicholson2012-12-031-7/+2
| | | | | | Walking a GSList backwards involved copying and reversing it so that the the original list could remain undisturbed. This is wasteful with a GList where we can just start at the end of the list and work backwards.
* Remove duplicate packages after resolving requiresDan Nicholson2012-12-033-5/+47
| | | | | | | | | 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).
* Convert to doubly-linked GListDan Nicholson2012-12-035-161/+161
| | | | | | | | Using a doubly-linked list allows it to be easily traversed in both directions and makes removing nodes in place much simpler. This adds an extra pointer to each node and associated manipulation during any list processing, but this trade seems acceptable over the repeated hacks to work with singly-linked lists.
* Always use --static test results for indirect depencency resultsDan Nicholson2012-11-294-25/+31
| | | | | | | 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.
* Use standard GSList functions to merge package listsDan Nicholson2012-11-291-11/+3
| | | | | | Using the GSList functions instead of manually adjusting the list pointers seems safer and allows an easier path to using another glib list type if necessary.
* Add a gtk testcase to provide something with complex interactionsDan Nicholson2012-11-2828-2/+406
| | | | | | | | 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.
* Test stripping of duplicate flagsDan Nicholson2012-11-284-1/+40
| | | | | | | 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.
* Test ordering of flags based on package depth and pathDan Nicholson2012-11-2811-1/+301
| | | | | | | | 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.
* Remove extra spaces from list debugging outputDan Nicholson2012-11-281-6/+4
| | | | | Also, make pre- and post-sorting output aligned to easily ordering differences.
* Use package filename rather than Name in debuggingDan Nicholson2012-11-281-12/+12
| | | | | | | The Package key member corresponds to the module filename with the .pc stripped off while the name member corresponds to the Name field in the .pc file. The latter is almost never used in practice and just makes debugging more difficult.
* Allow all combinations of --cflags and --libs variantsDan Nicholson2012-11-037-143/+184
| | | | | | | | | 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)
* Remove pkg-config.in scriptDan Nicholson2012-10-311-306/+0
| | | | | | | A relic from the past, the pkg-config.in script exists from a time when pkg-config was implemented as a shell script. This time is long since gone and the script is far different than the C implementation. Find it in git if you want to see how a shell script once did pkg-config.
* Move --print-variables handling after --exists for consistencyDan Nicholson2012-10-301-16/+15
| | | | | | | | | The --print-variables output is inconsistent with other printing options when --exists is supplied or not. Move the handling after --exists like --print-requires and others requiring a valid package list so that --exists is given it takes priority and exits early. Freedesktop #54384 (https://bugs.freedesktop.org/show_bug.cgi?id=54384)
* Nest copying and merging of flags to avoid repeated traversalsDan Nicholson2012-10-301-18/+34
| | | | | | | | | | | When merging the flags from all the packages together, each flags list was being copied and then concatenated to then end of the combined list. This was extremely inefficient because it caused the combined list to be traversed multiple times to find the end. Instead, nest the copying and merging of the flags together so the last element is always tracked and can easily be appended to. Freedesktop #54716 (https://bugs.freedesktop.org/show_bug.cgi?id=54716)
* Only match uninstalled packages that end in "-uninstalled" with hyphenDan Nicholson2012-10-131-3/+3
| | | | | | | | | pkg-config(1) states that installed packages should be appended with "-uninstalled". However, the code was checking only for trailing "uninstalled" without the hyphen. Make the code consistent with the documentation. Freedesktop #54379
* Don't crash on --print-variables when there are no variablesDan Nicholson2012-10-134-5/+13
| | | | | | | | 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
* remove the .cvsignore fileAdrian Bunk2012-10-131-9/+0
| | | | No longer needed after the switch to git.
* Support circular Requires loopsDan Nicholson2012-10-136-1/+64
| | | | | | | | | | | 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
* Delay converting Requires entries to Packages until after parsingDan Nicholson2012-10-133-77/+64
| | | | | | | | | | | | | | When the parser encounters Requires or Requires.private, it immediately tries to sees if we have a parsed package for that entry. If not it tries to locate the needed file and parse it out. If there's a circular dependency, this will eventually error opening too many files. Instead, just store the requires entries so the parsing completes and the package is added to the database. After parsing, the entries can be resolved into Packages and any circular requires entries will find the first package in the database. This is a partial fix for Freedesktop #7331.
* Consistently resolve requires depth-first to fix non-l flag orderingDan Nicholson2012-10-137-16/+40
| | | | | | | | | | | | | | | | | | | | | | | 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
* Make sure recursion only happens with requiresDan Nicholson2012-10-131-0/+6
| | | | | | The function recursive_fill_list() is designed to descend lists of packages, so it only makes sense to use with Requires and Requires.private. Ensure it to make later code additions simpler.
* Install pkg-config link with $host- prefixDan Nicholson2012-10-132-0/+19
| | | | | | | | | | | | | | | | | | | If pkg-config is used in a multiarch or cross-compiling scenario it's likely pkg-config needs to behave differently for each of them. It's possible to handle this through environment variables with one pkg-config, but another option is to have one pkg-config per platform, each with the host alias prefixed to the program. PKG_PROG_PKG_CONFIG supports this type of installation, and this is also how autoconf/libtool handle other build tools like compilers and linkers. The host-prefixed tool is installed as a hardlink where supported and a copy otherwise. This is how gcc handles it's host-prefixed versions. This feature can be turned off by passing --disable-host-tool to configure. Freedesktop #130
* check: Test version comparisons within Requires fieldsDan Nicholson2012-10-035-1/+36
| | | | | Verification of versions in Requires and friends happens differently than the version comparison for command-line packages.
* Kill a bunch of unused codeDan Nicholson2012-10-032-154/+0
| | | | | | From what I can tell, these single package variants have never been used going back to pkg-config-0.4.0. pkg-config always uses the multipackage versions that loop over the list of supplied packages.
* check: Test all variants of --cflags and --libsDan Nicholson2012-10-034-1/+33
| | | | | | 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.
* check: Ensure unknown options failDan Nicholson2012-10-031-0/+5
|
* check: Ensure debugging output works correctlyDan Nicholson2012-10-032-1/+24
| | | | | This might be a little fragile, but it makes sure to exercise the debug_spew function.
* check: Test -uninstalled functionalityDan Nicholson2012-10-034-2/+73
| | | | | | | 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.
* Fix formatting for --print-provides in man pageDan Nicholson2012-10-031-1/+1
|
* check: Test sysroot supportDan Nicholson2012-10-032-1/+25
| | | | | Checks that pkg-config prepends PKG_CONFIG_SYSROOT_DIR to -I and -L when they don't point to system directories.
* check: Test pkg-config versionDan Nicholson2012-10-023-0/+13
| | | | | Test that --version prints the current version and --atleast-pkgconfig-version validates it.
* check: Enhance --print-requires testsDan Nicholson2012-10-022-6/+6
| | | | | Make the --print-requires and --print-requires-private tests actually resolve Requires and output a specific version test.
* check: Check path handlingDan Nicholson2012-10-023-2/+34
| | | | | | | | | | | 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.
* check: Exercise all printing optionsDan Nicholson2012-09-294-2/+47
| | | | | | | 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.
* check: Test --define-variable corner casesDan Nicholson2012-09-291-0/+9
|
* check: Pass args to test function instead of setting in variableDan Nicholson2012-09-2913-113/+56
| | | | | | | | 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 "$@".
* Add optional usage of gcov for test coverageDan Nicholson2012-09-283-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | Use gcov to find how much code coverage our current testing gets. This can be enabled by passing --with-gcov to configure and running "make gcov". This is limited to gcc. Here's a run from the current code (for some reason, gcov insists on profiling gstring.h). /usr/bin/gcov pkg.h pkg.c parse.h parse.c main.c File 'pkg.c' Lines executed:73.16% of 611 pkg.c:creating 'pkg.c.gcov' File '/usr/include/glib-2.0/glib/gstring.h' Lines executed:100.00% of 6 /usr/include/glib-2.0/glib/gstring.h:creating 'gstring.h.gcov' File 'parse.c' Lines executed:79.67% of 492 parse.c:creating 'parse.c.gcov' File 'main.c' Lines executed:57.34% of 293 main.c:creating 'main.c.gcov'