forked from ariadne/pkgconf
libpkgconf: kill flags from top-level fragment API (ref #105)
parent
7b39c38408
commit
13cf74c7a3
|
@ -25,18 +25,18 @@ which is composable, mergeable and reorderable.
|
||||||
:return: true if the fragment contains a system path, else false
|
:return: true if the fragment contains a system path, else false
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
|
|
||||||
.. c:function:: void pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private)
|
.. c:function:: void pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_fragment_t *base, bool is_private)
|
||||||
|
|
||||||
Copies a `fragment` to another `fragment list`, possibly removing a previous copy of the `fragment`
|
Copies a `fragment` to another `fragment list`, possibly removing a previous copy of the `fragment`
|
||||||
in a process known as `mergeback`.
|
in a process known as `mergeback`.
|
||||||
|
|
||||||
|
:param pkgconf_client_t* client: The pkgconf client being accessed.
|
||||||
:param pkgconf_list_t* list: The list the fragment is being added to.
|
:param pkgconf_list_t* list: The list the fragment is being added to.
|
||||||
:param pkgconf_fragment_t* base: The fragment being copied.
|
:param pkgconf_fragment_t* base: The fragment being copied.
|
||||||
:param uint flags: A set of dependency resolver flags.
|
|
||||||
:param bool is_private: Whether the fragment list is a `private` fragment list (static linking).
|
:param bool is_private: Whether the fragment list is a `private` fragment list (static linking).
|
||||||
:return: nothing
|
:return: nothing
|
||||||
|
|
||||||
.. c:function:: void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, unsigned int flags)
|
.. c:function:: void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func)
|
||||||
|
|
||||||
Copies a `fragment list` to another `fragment list` which match a user-specified filtering function.
|
Copies a `fragment list` to another `fragment list` which match a user-specified filtering function.
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ which is composable, mergeable and reorderable.
|
||||||
:param pkgconf_list_t* src: The source list.
|
:param pkgconf_list_t* src: The source list.
|
||||||
:param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
:param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
||||||
:param void* data: Optional data to pass to the filter function.
|
:param void* data: Optional data to pass to the filter function.
|
||||||
:param uint flags: A set of dependency resolver flags.
|
|
||||||
:return: nothing
|
:return: nothing
|
||||||
|
|
||||||
.. c:function:: size_t pkgconf_fragment_render_len(const pkgconf_list_t *list)
|
.. c:function:: size_t pkgconf_fragment_render_len(const pkgconf_list_t *list)
|
||||||
|
|
|
@ -167,7 +167,7 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const
|
||||||
|
|
||||||
/* use a copy operation to force a dedup */
|
/* use a copy operation to force a dedup */
|
||||||
pkgconf_node_delete(&parent->iter, list);
|
pkgconf_node_delete(&parent->iter, list);
|
||||||
pkgconf_fragment_copy(list, parent, 0, false);
|
pkgconf_fragment_copy(client, list, parent, false);
|
||||||
|
|
||||||
/* the fragment list now (maybe) has the copied node, so free the original */
|
/* the fragment list now (maybe) has the copied node, so free the original */
|
||||||
free(parent->data);
|
free(parent->data);
|
||||||
|
@ -312,28 +312,28 @@ pkgconf_fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fr
|
||||||
/*
|
/*
|
||||||
* !doc
|
* !doc
|
||||||
*
|
*
|
||||||
* .. c:function:: void pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private)
|
* .. c:function:: void pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_fragment_t *base, bool is_private)
|
||||||
*
|
*
|
||||||
* Copies a `fragment` to another `fragment list`, possibly removing a previous copy of the `fragment`
|
* Copies a `fragment` to another `fragment list`, possibly removing a previous copy of the `fragment`
|
||||||
* in a process known as `mergeback`.
|
* in a process known as `mergeback`.
|
||||||
*
|
*
|
||||||
|
* :param pkgconf_client_t* client: The pkgconf client being accessed.
|
||||||
* :param pkgconf_list_t* list: The list the fragment is being added to.
|
* :param pkgconf_list_t* list: The list the fragment is being added to.
|
||||||
* :param pkgconf_fragment_t* base: The fragment being copied.
|
* :param pkgconf_fragment_t* base: The fragment being copied.
|
||||||
* :param uint flags: A set of dependency resolver flags.
|
|
||||||
* :param bool is_private: Whether the fragment list is a `private` fragment list (static linking).
|
* :param bool is_private: Whether the fragment list is a `private` fragment list (static linking).
|
||||||
* :return: nothing
|
* :return: nothing
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private)
|
pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_fragment_t *base, bool is_private)
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *frag;
|
pkgconf_fragment_t *frag;
|
||||||
|
|
||||||
if ((frag = pkgconf_fragment_exists(list, base, flags, is_private)) != NULL)
|
if ((frag = pkgconf_fragment_exists(list, base, client->flags, is_private)) != NULL)
|
||||||
{
|
{
|
||||||
if (pkgconf_fragment_should_merge(frag))
|
if (pkgconf_fragment_should_merge(frag))
|
||||||
pkgconf_fragment_delete(list, frag);
|
pkgconf_fragment_delete(list, frag);
|
||||||
}
|
}
|
||||||
else if (!is_private && !pkgconf_fragment_can_merge_back(base, flags, is_private) && (pkgconf_fragment_lookup(list, base) != NULL))
|
else if (!is_private && !pkgconf_fragment_can_merge_back(base, client->flags, is_private) && (pkgconf_fragment_lookup(list, base) != NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
frag = calloc(sizeof(pkgconf_fragment_t), 1);
|
frag = calloc(sizeof(pkgconf_fragment_t), 1);
|
||||||
|
@ -347,7 +347,7 @@ pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsi
|
||||||
/*
|
/*
|
||||||
* !doc
|
* !doc
|
||||||
*
|
*
|
||||||
* .. c:function:: void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, unsigned int flags)
|
* .. c:function:: void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func)
|
||||||
*
|
*
|
||||||
* Copies a `fragment list` to another `fragment list` which match a user-specified filtering function.
|
* Copies a `fragment list` to another `fragment list` which match a user-specified filtering function.
|
||||||
*
|
*
|
||||||
|
@ -356,11 +356,10 @@ pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsi
|
||||||
* :param pkgconf_list_t* src: The source list.
|
* :param pkgconf_list_t* src: The source list.
|
||||||
* :param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
* :param pkgconf_fragment_filter_func_t filter_func: The filter function to use.
|
||||||
* :param void* data: Optional data to pass to the filter function.
|
* :param void* data: Optional data to pass to the filter function.
|
||||||
* :param uint flags: A set of dependency resolver flags.
|
|
||||||
* :return: nothing
|
* :return: nothing
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data, unsigned int flags)
|
pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data)
|
||||||
{
|
{
|
||||||
pkgconf_node_t *node;
|
pkgconf_node_t *node;
|
||||||
|
|
||||||
|
@ -368,8 +367,8 @@ pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pk
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *frag = node->data;
|
pkgconf_fragment_t *frag = node->data;
|
||||||
|
|
||||||
if (filter_func(client, frag, data, flags))
|
if (filter_func(client, frag, data))
|
||||||
pkgconf_fragment_copy(dest, frag, flags, true);
|
pkgconf_fragment_copy(client, dest, frag, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,13 +231,13 @@ int pkgconf_argv_split(const char *src, int *argc, char ***argv);
|
||||||
void pkgconf_argv_free(char **argv);
|
void pkgconf_argv_free(char **argv);
|
||||||
|
|
||||||
/* fragment.c */
|
/* fragment.c */
|
||||||
typedef bool (*pkgconf_fragment_filter_func_t)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data, unsigned int flags);
|
typedef bool (*pkgconf_fragment_filter_func_t)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data);
|
||||||
void pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value);
|
void pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value);
|
||||||
void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string);
|
void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string);
|
||||||
void pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private);
|
void pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_fragment_t *base, bool is_private);
|
||||||
void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node);
|
void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node);
|
||||||
void pkgconf_fragment_free(pkgconf_list_t *list);
|
void pkgconf_fragment_free(pkgconf_list_t *list);
|
||||||
void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data, unsigned int flags);
|
void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data);
|
||||||
size_t pkgconf_fragment_render_len(const pkgconf_list_t *list);
|
size_t pkgconf_fragment_render_len(const pkgconf_list_t *list);
|
||||||
void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t len);
|
void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t len);
|
||||||
char *pkgconf_fragment_render(const pkgconf_list_t *list);
|
char *pkgconf_fragment_render(const pkgconf_list_t *list);
|
||||||
|
|
|
@ -1331,7 +1331,7 @@ pkgconf_pkg_cflags_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *d
|
||||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags.head, node)
|
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags.head, node)
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *frag = node->data;
|
pkgconf_fragment_t *frag = node->data;
|
||||||
pkgconf_fragment_copy(list, frag, client->flags, false);
|
pkgconf_fragment_copy(client, list, frag, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1344,7 +1344,7 @@ pkgconf_pkg_cflags_private_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg,
|
||||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags_private.head, node)
|
PKGCONF_FOREACH_LIST_ENTRY(pkg->cflags_private.head, node)
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *frag = node->data;
|
pkgconf_fragment_t *frag = node->data;
|
||||||
pkgconf_fragment_copy(list, frag, client->flags, true);
|
pkgconf_fragment_copy(client, list, frag, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1390,7 +1390,7 @@ pkgconf_pkg_libs_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *dat
|
||||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs.head, node)
|
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs.head, node)
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *frag = node->data;
|
pkgconf_fragment_t *frag = node->data;
|
||||||
pkgconf_fragment_copy(list, frag, client->flags, (client->flags & PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE) != 0);
|
pkgconf_fragment_copy(client, list, frag, (client->flags & PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client->flags & PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS)
|
if (client->flags & PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS)
|
||||||
|
@ -1398,7 +1398,7 @@ pkgconf_pkg_libs_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *dat
|
||||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs_private.head, node)
|
PKGCONF_FOREACH_LIST_ENTRY(pkg->libs_private.head, node)
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *frag = node->data;
|
pkgconf_fragment_t *frag = node->data;
|
||||||
pkgconf_fragment_copy(list, frag, client->flags, true);
|
pkgconf_fragment_copy(client, list, frag, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
main.c
10
main.c
|
@ -99,12 +99,11 @@ print_package_entry(const pkgconf_pkg_t *entry, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
filter_cflags(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data, unsigned int flags)
|
filter_cflags(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data)
|
||||||
{
|
{
|
||||||
int got_flags = 0;
|
int got_flags = 0;
|
||||||
(void) client;
|
(void) client;
|
||||||
(void) data;
|
(void) data;
|
||||||
(void) flags;
|
|
||||||
|
|
||||||
if (!(want_flags & PKG_KEEP_SYSTEM_CFLAGS) && pkgconf_fragment_has_system_dir(client, frag))
|
if (!(want_flags & PKG_KEEP_SYSTEM_CFLAGS) && pkgconf_fragment_has_system_dir(client, frag))
|
||||||
return false;
|
return false;
|
||||||
|
@ -118,12 +117,11 @@ filter_cflags(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, vo
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
filter_libs(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data, unsigned int flags)
|
filter_libs(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data)
|
||||||
{
|
{
|
||||||
int got_flags = 0;
|
int got_flags = 0;
|
||||||
(void) client;
|
(void) client;
|
||||||
(void) data;
|
(void) data;
|
||||||
(void) flags;
|
|
||||||
|
|
||||||
if (!(want_flags & PKG_KEEP_SYSTEM_LIBS) && pkgconf_fragment_has_system_dir(client, frag))
|
if (!(want_flags & PKG_KEEP_SYSTEM_LIBS) && pkgconf_fragment_has_system_dir(client, frag))
|
||||||
return false;
|
return false;
|
||||||
|
@ -378,7 +376,7 @@ apply_cflags(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int m
|
||||||
if (eflag != PKGCONF_PKG_ERRF_OK)
|
if (eflag != PKGCONF_PKG_ERRF_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_cflags, NULL, client->flags);
|
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_cflags, NULL);
|
||||||
|
|
||||||
if (filtered_list.head == NULL)
|
if (filtered_list.head == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
@ -406,7 +404,7 @@ apply_libs(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int max
|
||||||
if (eflag != PKGCONF_PKG_ERRF_OK)
|
if (eflag != PKGCONF_PKG_ERRF_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_libs, NULL, client->flags);
|
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_libs, NULL);
|
||||||
|
|
||||||
if (filtered_list.head == NULL)
|
if (filtered_list.head == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue