cli: add integration for --print-variables with --env
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
c84223616a
commit
ca2a06898f
48
cli/main.c
48
cli/main.c
|
@ -525,6 +525,51 @@ maybe_add_module_definitions(pkgconf_client_t *client, pkgconf_pkg_t *world, pkg
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
apply_env_variables(pkgconf_client_t *client, pkgconf_pkg_t *world, const char *env_prefix)
|
||||
{
|
||||
(void) client;
|
||||
pkgconf_node_t *world_iter;
|
||||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(world->required.head, world_iter)
|
||||
{
|
||||
pkgconf_dependency_t *dep = world_iter->data;
|
||||
pkgconf_pkg_t *pkg = dep->match;
|
||||
pkgconf_node_t *tuple_iter;
|
||||
|
||||
if ((dep->flags & PKGCONF_PKG_DEPF_QUERY) != PKGCONF_PKG_DEPF_QUERY)
|
||||
continue;
|
||||
|
||||
if (dep->match == NULL)
|
||||
continue;
|
||||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(pkg->vars.head, tuple_iter)
|
||||
{
|
||||
pkgconf_tuple_t *tuple = tuple_iter->data;
|
||||
char havebuf[PKGCONF_ITEM_SIZE];
|
||||
char *p;
|
||||
|
||||
snprintf(havebuf, sizeof havebuf, "%s_%s", env_prefix, tuple->key);
|
||||
|
||||
for (p = havebuf; *p; p++)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case ' ':
|
||||
case '-':
|
||||
*p = '_';
|
||||
break;
|
||||
|
||||
default:
|
||||
*p = toupper((unsigned char) *p);
|
||||
}
|
||||
}
|
||||
|
||||
printf("%s='%s'\n", havebuf, tuple->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
apply_env(pkgconf_client_t *client, pkgconf_pkg_t *world, void *env_prefix_p, int maxdepth)
|
||||
{
|
||||
|
@ -544,6 +589,9 @@ apply_env(pkgconf_client_t *client, pkgconf_pkg_t *world, void *env_prefix_p, in
|
|||
if (!apply_env_var(workbuf, client, world, maxdepth, pkgconf_pkg_libs, filter_libs, NULL))
|
||||
return false;
|
||||
|
||||
if ((want_flags & PKG_VARIABLES) == PKG_VARIABLES)
|
||||
apply_env_variables(client, world, want_env_prefix);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue