cli: implement --exists-cflags support for --env
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
d5cd2a4f28
commit
b24f3dfd8f
50
cli/main.c
50
cli/main.c
|
@ -454,7 +454,8 @@ apply_variable(pkgconf_client_t *client, pkgconf_pkg_t *world, void *variable, i
|
||||||
static bool
|
static bool
|
||||||
apply_env_var(const char *prefix, pkgconf_client_t *client, pkgconf_pkg_t *world, int maxdepth,
|
apply_env_var(const char *prefix, pkgconf_client_t *client, pkgconf_pkg_t *world, int maxdepth,
|
||||||
unsigned int (*collect_fn)(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth),
|
unsigned int (*collect_fn)(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth),
|
||||||
bool (*filter_fn)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data))
|
bool (*filter_fn)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data),
|
||||||
|
void (*postprocess_fn)(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *fragment_list))
|
||||||
{
|
{
|
||||||
pkgconf_list_t unfiltered_list = PKGCONF_LIST_INITIALIZER;
|
pkgconf_list_t unfiltered_list = PKGCONF_LIST_INITIALIZER;
|
||||||
pkgconf_list_t filtered_list = PKGCONF_LIST_INITIALIZER;
|
pkgconf_list_t filtered_list = PKGCONF_LIST_INITIALIZER;
|
||||||
|
@ -467,6 +468,9 @@ apply_env_var(const char *prefix, pkgconf_client_t *client, pkgconf_pkg_t *world
|
||||||
|
|
||||||
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_fn, NULL);
|
pkgconf_fragment_filter(client, &filtered_list, &unfiltered_list, filter_fn, NULL);
|
||||||
|
|
||||||
|
if (postprocess_fn != NULL)
|
||||||
|
postprocess_fn(client, world, &filtered_list);
|
||||||
|
|
||||||
if (filtered_list.head == NULL)
|
if (filtered_list.head == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -481,28 +485,6 @@ out:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
apply_env(pkgconf_client_t *client, pkgconf_pkg_t *world, void *env_prefix_p, int maxdepth)
|
|
||||||
{
|
|
||||||
const char *want_env_prefix = env_prefix_p, *it;
|
|
||||||
char workbuf[PKGCONF_ITEM_SIZE];
|
|
||||||
|
|
||||||
for (it = want_env_prefix; *it != '\0'; it++)
|
|
||||||
if (!isalpha((unsigned char)*it) &&
|
|
||||||
!isdigit((unsigned char)*it))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
snprintf(workbuf, sizeof workbuf, "%s_CFLAGS", want_env_prefix);
|
|
||||||
if (!apply_env_var(workbuf, client, world, maxdepth, pkgconf_pkg_cflags, filter_cflags))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
snprintf(workbuf, sizeof workbuf, "%s_LIBS", want_env_prefix);
|
|
||||||
if (!apply_env_var(workbuf, client, world, maxdepth, pkgconf_pkg_libs, filter_libs))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maybe_add_module_definitions(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *fragment_list)
|
maybe_add_module_definitions(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *fragment_list)
|
||||||
{
|
{
|
||||||
|
@ -543,6 +525,28 @@ maybe_add_module_definitions(pkgconf_client_t *client, pkgconf_pkg_t *world, pkg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
apply_env(pkgconf_client_t *client, pkgconf_pkg_t *world, void *env_prefix_p, int maxdepth)
|
||||||
|
{
|
||||||
|
const char *want_env_prefix = env_prefix_p, *it;
|
||||||
|
char workbuf[PKGCONF_ITEM_SIZE];
|
||||||
|
|
||||||
|
for (it = want_env_prefix; *it != '\0'; it++)
|
||||||
|
if (!isalpha((unsigned char)*it) &&
|
||||||
|
!isdigit((unsigned char)*it))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
snprintf(workbuf, sizeof workbuf, "%s_CFLAGS", want_env_prefix);
|
||||||
|
if (!apply_env_var(workbuf, client, world, maxdepth, pkgconf_pkg_cflags, filter_cflags, maybe_add_module_definitions))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
snprintf(workbuf, sizeof workbuf, "%s_LIBS", want_env_prefix);
|
||||||
|
if (!apply_env_var(workbuf, client, world, maxdepth, pkgconf_pkg_libs, filter_libs, NULL))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
apply_cflags(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth)
|
apply_cflags(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue