libpkgconf: queue: add pkgconf_queue_push_dependency

Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
This commit is contained in:
Ariadne Conill 2025-12-24 20:38:23 -08:00
parent bb79dad5fe
commit d0823a14fc
2 changed files with 27 additions and 0 deletions

View File

@ -416,6 +416,7 @@ PKGCONF_API void pkgconf_tuple_define_global(pkgconf_client_t *client, const cha
/* queue.c */
PKGCONF_API void pkgconf_queue_push(pkgconf_list_t *list, const char *package);
PKGCONF_API void pkgconf_queue_push_dependency(pkgconf_list_t *list, const pkgconf_dependency_t *dep);
PKGCONF_API bool pkgconf_queue_compile(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list);
PKGCONF_API bool pkgconf_queue_solve(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_pkg_t *world, int maxdepth);
PKGCONF_API void pkgconf_queue_free(pkgconf_list_t *list);

View File

@ -29,6 +29,32 @@
* Using the `queue` module functions is the recommended way of working with dependency graphs.
*/
/*
* !doc
*
* .. c:function:: void pkgconf_queue_push_dependency(pkgconf_list_t *list, const pkgconf_dependency_t *dep)
*
* Pushes a requested dependency onto the dependency resolver's queue which is described by
* a pkgconf_dependency_t node.
*
* :param pkgconf_list_t* list: the dependency resolution queue to add the package request to.
* :param pkgconf_dependency_t* dep: the dependency requested
* :return: nothing
*/
void
pkgconf_queue_push_dependency(pkgconf_list_t *list, const pkgconf_dependency_t *dep)
{
pkgconf_buffer_t depbuf = PKGCONF_BUFFER_INITIALIZER;
pkgconf_queue_t *pkgq = calloc(1, sizeof(pkgconf_queue_t));
pkgconf_buffer_append(&depbuf, dep->package);
if (dep->version != NULL)
pkgconf_buffer_append_fmt(&depbuf, " %s %s", pkgconf_pkg_get_comparator(dep), dep->version);
pkgq->package = pkgconf_buffer_freeze(&depbuf);
pkgconf_node_insert_tail(&pkgq->iter, pkgq, list);
}
/*
* !doc
*