Compare commits

...

6 Commits

Author SHA1 Message Date
William Pitcock 188ea09eeb pkgconf 1.1.1. 2017-01-07 15:26:46 -06:00
William Pitcock 1cefedf92e manpage: document --path option 2017-01-07 15:23:00 -06:00
William Pitcock d288ff89c7 main: add --path option to show the exact filename of each .pc file used 2017-01-07 15:22:47 -06:00
William Pitcock 7a2d93c01f fragment: handle oddball fragments like -framework more accurately 2017-01-07 15:09:10 -06:00
Baptiste Daroussin 8d99aab517 Fix gcc warnings 2017-01-07 14:30:28 -06:00
Baptiste Daroussin f89e2d2a80 inode cache: ensure we never use an unitilized struct stat 2017-01-07 14:30:20 -06:00
7 changed files with 75 additions and 8 deletions

11
NEWS
View File

@ -1,6 +1,17 @@
Changes from previous version of pkgconf
========================================
Changes from 1.1.0 to 1.1.1:
----------------------------
* Features:
- new --path option lists the .pc files which provided the requested dependencies
* Bug fixes:
- fragments: fix even more edge cases involving token concatenation
- path lists: don't attempt to collect path inodes if the filter is disabled
- path lists: explicitly avoid uninitialised data for the path inode cache
Changes from 1.0.1 to 1.1.0:
----------------------------

View File

@ -12,7 +12,7 @@ dnl implied. In no event shall the authors be liable for any damages arising
dnl from the use of this software.
AC_PREREQ([2.68])
AC_INIT([pkgconf], [1.1.0], [http://github.com/pkgconf/pkgconf/issues])
AC_INIT([pkgconf], [1.1.1], [http://github.com/pkgconf/pkgconf/issues])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([libpkgconf/config.h])
AC_CHECK_FUNCS([strlcpy strlcat strndup])

View File

@ -47,6 +47,10 @@ pkgconf_fragment_is_unmergeable(const char *string)
if (!strncmp(string, check_fragments[i].token, check_fragments[i].len))
return true;
/* only one pair of {-flag, arg} may be merged together */
if (strchr(string, ' ') != NULL)
return false;
return false;
}
@ -145,7 +149,8 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const
{
pkgconf_fragment_t *parent = list->tail->data;
if (pkgconf_fragment_is_unmergeable(parent->data))
/* only attempt to merge 'special' fragments together */
if (!parent->type && pkgconf_fragment_is_unmergeable(parent->data))
{
size_t len;
char *newdata;
@ -162,6 +167,14 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const
free(parent->data);
parent->data = newdata;
/* use a copy operation to force a dedup */
pkgconf_node_delete(&parent->iter, list);
pkgconf_fragment_copy(list, parent, 0, false);
/* the fragment list now (maybe) has the copied node, so free the original */
free(parent->data);
free(parent);
return;
}
}
@ -261,7 +274,7 @@ pkgconf_fragment_should_merge(const pkgconf_fragment_t *base)
case 'I':
return true;
default:
return parent->type == base->type;
return !base->type || parent->type == base->type;
}
}

View File

@ -35,7 +35,7 @@ path_list_contains_entry(const char *text, pkgconf_list_t *dirlist)
pkgconf_path_t *pn = n->data;
#ifdef PKGCONF_CACHE_INODES
if (((dev_t) pn->handle_device) == st->st_dev && ((ino_t) pn->handle_path) == st->st_ino)
if (pn->handle_device == (void *)(intptr_t)st->st_dev && pn->handle_path == (void *)(intptr_t)st->st_ino)
return true;
#endif
@ -89,8 +89,10 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter)
node = calloc(sizeof(pkgconf_path_t), 1);
node->path = strdup(text);
#ifdef PKGCONF_CACHE_INODES
if (filter) {
node->handle_path = (void *)(intptr_t) st.st_ino;
node->handle_device = (void *)(intptr_t) st.st_dev;
}
#endif
pkgconf_node_insert_tail(&node->lnode, node, dirlist);

37
main.c
View File

@ -51,6 +51,7 @@
#define PKG_LIST_PACKAGE_NAMES (((uint64_t) 1) << 31)
#define PKG_NO_PROVIDES (((uint64_t) 1) << 32)
#define PKG_PURE (((uint64_t) 1) << 33)
#define PKG_PATH (((uint64_t) 1) << 34)
static unsigned int global_traverse_flags = PKGCONF_PKG_PKGF_NONE;
@ -301,6 +302,29 @@ apply_variables(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, in
return true;
}
static void
print_path(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{
(void) client;
(void) data;
(void) flags;
printf("%s\n", pkg->filename);
}
static bool
apply_path(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{
int eflag;
eflag = pkgconf_pkg_traverse(client, world, print_path, unused, maxdepth, flags);
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
return true;
}
typedef struct {
const char *variable;
char buf[PKGCONF_BUFSIZE];
@ -591,6 +615,7 @@ usage(void)
printf(" --digraph print entire dependency graph in graphviz 'dot' format\n");
printf(" --keep-system-cflags keep -I%s entries in cflags output\n", SYSTEM_INCLUDEDIR);
printf(" --keep-system-libs keep -L%s entries in libs output\n", SYSTEM_LIBDIR);
printf(" --path show the exact filenames for any matching .pc files\n");
printf("\nreport bugs to <%s>.\n", PACKAGE_BUGREPORT);
}
@ -655,6 +680,7 @@ main(int argc, char *argv[])
{ "debug", no_argument, &want_flags, 0, },
{ "validate", no_argument, NULL, 0 },
{ "log-file", required_argument, NULL, 40 },
{ "path", no_argument, &want_flags, PKG_PATH },
{ NULL, 0, NULL, 0 }
};
@ -989,6 +1015,17 @@ main(int argc, char *argv[])
}
}
if ((want_flags & PKG_PATH) == PKG_PATH)
{
want_flags &= ~(PKG_CFLAGS|PKG_LIBS);
if (!pkgconf_queue_apply(&pkg_client, &pkgq, apply_path, 2, global_traverse_flags | PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL, NULL))
{
ret = EXIT_FAILURE;
goto out;
}
}
if ((want_flags & PKG_VARIABLES) == PKG_VARIABLES)
{
want_flags &= ~(PKG_CFLAGS|PKG_LIBS);

View File

@ -130,6 +130,10 @@ field.
Dump the dependency resolver's solution as a graphviz
.Sq dot
file. This can be used with graphviz to visualize module interdependencies.
.It Fl -path
Display the filenames of the
.Sq .pc
files used by the dependency resolver for a given dependency set.
.El
.Sh ENVIRONMENT
.Bl -tag -width indent

View File

@ -12,9 +12,9 @@ libs_body()
-o inline:"-F/test/lib -framework framework-1 \n" \
pkgconf --libs framework-1
atf_check \
-o inline:"-F/test/lib -framework framework-2 -F/test/lib -framework framework-1 \n" \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1 \n" \
pkgconf --libs framework-2
atf_check \
-o inline:"-F/test/lib -framework framework-1 -F/test/lib -framework framework-2 \n" \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1 \n" \
pkgconf --libs framework-1 framework-2
}