add Cflags.private fragment

pull/50/head
Tony Theodore 2013-08-14 15:36:43 +10:00
parent 595e0965b2
commit 1c658f0383
4 changed files with 29 additions and 0 deletions

25
pkg.c
View File

@ -248,6 +248,8 @@ pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
pkg->version = pkg_tuple_parse(&pkg->vars, value);
else if (!strcasecmp(key, "CFLAGS"))
pkg_fragment_parse(&pkg->cflags, &pkg->vars, value);
else if (!strcasecmp(key, "CFLAGS.private"))
pkg_fragment_parse(&pkg->cflags_private, &pkg->vars, value);
else if (!strcasecmp(key, "LIBS"))
pkg_fragment_parse(&pkg->libs, &pkg->vars, value);
else if (!strcasecmp(key, "LIBS.private"))
@ -295,6 +297,7 @@ pkg_free(pkg_t *pkg)
pkg_dependency_free(&pkg->conflicts);
pkg_fragment_free(&pkg->cflags);
pkg_fragment_free(&pkg->cflags_private);
pkg_fragment_free(&pkg->libs);
pkg_fragment_free(&pkg->libs_private);
@ -1000,6 +1003,21 @@ pkg_cflags_collect(pkg_t *pkg, void *data, unsigned int flags)
}
}
static void
pkg_cflags_private_collect(pkg_t *pkg, void *data, unsigned int flags)
{
pkg_list_t *list = data;
pkg_node_t *node;
(void) flags;
PKG_FOREACH_LIST_ENTRY(pkg->cflags_private.head, node)
{
pkg_fragment_t *frag = node->data;
pkg_fragment_copy(list, frag);
}
}
int
pkg_cflags(pkg_t *root, pkg_list_t *list, int maxdepth, unsigned int flags)
{
@ -1009,6 +1027,13 @@ pkg_cflags(pkg_t *root, pkg_list_t *list, int maxdepth, unsigned int flags)
if (eflag != PKG_ERRF_OK)
pkg_fragment_free(list);
if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS)
{
eflag = pkg_traverse(root, pkg_cflags_private_collect, list, maxdepth, flags);
if (eflag != PKG_ERRF_OK)
pkg_fragment_free(list);
}
return eflag;
}

1
pkg.h
View File

@ -95,6 +95,7 @@ struct pkg_ {
pkg_list_t libs;
pkg_list_t libs_private;
pkg_list_t cflags;
pkg_list_t cflags_private;
pkg_list_t requires;
pkg_list_t requires_private;

View File

@ -8,3 +8,4 @@ Description: A testing pkg-config file
Version: 1.2.3
Libs: -L${libdir} -lfoo
Cflags: -fPIC -I${includedir}/foo
Cflags.private: -DFOO_STATIC

View File

@ -114,6 +114,8 @@ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --libs baz" \
'-lfoo' '-lbaz' '-lzee'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --libs argv-parse-2" \
'-pthread '
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --cflags baz" \
'-fPIC' '-I/usr/include/foo' '-DFOO_STATIC'
# 4) tests for parser bugs
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs dos-lineendings" \