if no cflags or libs are defined in .pc just return 0 and output nothing

feature/tap-sh
Baptiste Daroussin 2012-08-20 22:47:10 +02:00
parent fbf13563ab
commit 4eedb041ed
6 changed files with 52 additions and 19 deletions

28
main.c
View File

@ -306,15 +306,19 @@ static bool
apply_cflags(pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
{
pkg_fragment_t **head = list_head;
pkg_fragment_t *list;
int eflag;
list = pkg_cflags(world, head, maxdepth, flags | PKGF_SEARCH_PRIVATE);
if (list == NULL)
eflag = pkg_cflags(world, head, maxdepth, flags | PKGF_SEARCH_PRIVATE);
if (eflag != PKG_ERRF_OK)
return false;
print_cflags(list);
if (*head == NULL)
return true;
print_cflags(*head);
pkg_fragment_free(*head);
pkg_fragment_free(list);
return true;
}
@ -322,14 +326,18 @@ static bool
apply_libs(pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
{
pkg_fragment_t **head = list_head;
pkg_fragment_t *list;
int eflag;
list = pkg_libs(world, head, maxdepth, flags);
if (list == NULL)
eflag = pkg_libs(world, head, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
return false;
print_libs(list);
pkg_fragment_free(list);
if (*head == NULL)
return true;
print_libs(*head);
pkg_fragment_free(*head);
return true;
}

15
pkg.c
View File

@ -853,7 +853,7 @@ pkg_cflags_collect(pkg_t *pkg, void *data, unsigned int flags)
*list = pkg_fragment_copy(*list, frag);
}
pkg_fragment_t *
int
pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags)
{
int eflag;
@ -863,10 +863,10 @@ pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags)
if (eflag != PKG_ERRF_OK)
{
pkg_fragment_free(*list);
return NULL;
*list = NULL;
}
return *list;
return eflag;
}
static void
@ -891,7 +891,7 @@ pkg_libs_private_collect(pkg_t *pkg, void *data, unsigned int flags)
*list = pkg_fragment_copy(*list, frag);
}
pkg_fragment_t *
int
pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags)
{
int eflag;
@ -901,7 +901,8 @@ pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags)
if (eflag != PKG_ERRF_OK)
{
pkg_fragment_free(*list);
return NULL;
*list = NULL;
return eflag;
}
if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS)
@ -910,9 +911,9 @@ pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags)
if (eflag != PKG_ERRF_OK)
{
pkg_fragment_free(*list);
return NULL;
*list = NULL;
}
}
return *list;
return eflag;
}

4
pkg.h
View File

@ -134,8 +134,8 @@ unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags);
int pkg_compare_version(const char *a, const char *b);
pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
const char *pkg_get_comparator(pkg_dependency_t *pkgdep);
pkg_fragment_t *pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags);
pkg_fragment_t *pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags);
int pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags);
int pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags);
/* parse.c */
pkg_t *pkg_new_from_file(const char *path, FILE *f);

9
tests/lib1/nocflag.pc Normal file
View File

@ -0,0 +1,9 @@
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: foo
Description: A testing pkg-config file
Version: 1.2.3
Libs: -L${libdir} -lfoo

9
tests/lib1/nolib.pc Normal file
View File

@ -0,0 +1,9 @@
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: foo
Description: A testing pkg-config file
Version: 1.2.3
Cflags: -fPIC -I${includedir}/foo

View File

@ -171,6 +171,12 @@ run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags missing-require; echo \$
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags quotes" \
"-DQUOTED=\\\"bla\\\""
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs nolib; echo \$?" \
'0'
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs nocflag; echo \$?" \
'0'
# 10) tests for internal getopt implementation with options at the end
if [ "x@STRICT_MODE@" = "xno" ]; then
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} foo --libs" \