main: add support for --variable
parent
8100eb84f0
commit
e8a944f41d
18
main.c
18
main.c
|
@ -36,6 +36,7 @@ static int want_modversion = 0;
|
||||||
static int maximum_traverse_depth = -1;
|
static int maximum_traverse_depth = -1;
|
||||||
|
|
||||||
static char *required_pkgconfig_version = NULL;
|
static char *required_pkgconfig_version = NULL;
|
||||||
|
static char *want_variable = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_cflags(pkg_t *pkg, void *unused)
|
print_cflags(pkg_t *pkg, void *unused)
|
||||||
|
@ -58,6 +59,16 @@ print_modversion(pkg_t *pkg, void *unused)
|
||||||
printf("%s\n", pkg->version);
|
printf("%s\n", pkg->version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_variable(pkg_t *pkg, void *unused)
|
||||||
|
{
|
||||||
|
char *variable;
|
||||||
|
|
||||||
|
variable = tuple_find(pkg->vars, want_variable);
|
||||||
|
if (variable != NULL)
|
||||||
|
printf("%s ", variable);
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct pkg_queue_ {
|
typedef struct pkg_queue_ {
|
||||||
struct pkg_queue_ *prev, *next;
|
struct pkg_queue_ *prev, *next;
|
||||||
const char *package;
|
const char *package;
|
||||||
|
@ -125,6 +136,12 @@ pkg_queue_walk(pkg_queue_t *head)
|
||||||
pkg_traverse(&world, print_libs, NULL, maximum_traverse_depth);
|
pkg_traverse(&world, print_libs, NULL, maximum_traverse_depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (want_variable)
|
||||||
|
{
|
||||||
|
wanted_something++;
|
||||||
|
pkg_traverse(&world, print_variable, NULL, 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (wanted_something)
|
if (wanted_something)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -167,6 +184,7 @@ main(int argc, const char *argv[])
|
||||||
{ "libs", 0, POPT_ARG_NONE, &want_libs, 0, "output all linker flags" },
|
{ "libs", 0, POPT_ARG_NONE, &want_libs, 0, "output all linker flags" },
|
||||||
{ "cflags", 0, POPT_ARG_NONE, &want_cflags, 0, "output all compiler flags" },
|
{ "cflags", 0, POPT_ARG_NONE, &want_cflags, 0, "output all compiler flags" },
|
||||||
{ "modversion", 0, POPT_ARG_NONE, &want_modversion, 0, "output package version" },
|
{ "modversion", 0, POPT_ARG_NONE, &want_modversion, 0, "output package version" },
|
||||||
|
{ "variable", 0, POPT_ARG_STRING, &want_variable, 0, "get the value of the specified variable" },
|
||||||
{ "exists", 0, POPT_ARG_NONE, NULL, 0, "return 0 if all packages present" },
|
{ "exists", 0, POPT_ARG_NONE, NULL, 0, "return 0 if all packages present" },
|
||||||
{ "print-errors", 0, POPT_ARG_NONE, NULL, 0, "dummy option for pkg-config compatibility" },
|
{ "print-errors", 0, POPT_ARG_NONE, NULL, 0, "dummy option for pkg-config compatibility" },
|
||||||
{ "short-errors", 0, POPT_ARG_NONE, NULL, 0, "dummy option for pkg-config compatibility" },
|
{ "short-errors", 0, POPT_ARG_NONE, NULL, 0, "dummy option for pkg-config compatibility" },
|
||||||
|
|
Loading…
Reference in New Issue