main: add --with-path CLI option (closes #104)

pull/109/head
William Pitcock 2017-01-18 11:36:52 -06:00
parent b428eeaacf
commit d7bf55a194
3 changed files with 20 additions and 1 deletions

5
main.c
View File

@ -577,6 +577,7 @@ usage(void)
printf(" --no-cache do not cache already seen packages when\n"); printf(" --no-cache do not cache already seen packages when\n");
printf(" walking the dependency graph\n"); printf(" walking the dependency graph\n");
printf(" --log-file=filename write an audit log to a specified file\n"); printf(" --log-file=filename write an audit log to a specified file\n");
printf(" --with-path=path adds a directory to the search path\n");
printf("\nchecking specific pkg-config database entries:\n\n"); printf("\nchecking specific pkg-config database entries:\n\n");
@ -681,6 +682,7 @@ main(int argc, char *argv[])
{ "validate", no_argument, NULL, 0 }, { "validate", no_argument, NULL, 0 },
{ "log-file", required_argument, NULL, 40 }, { "log-file", required_argument, NULL, 40 },
{ "path", no_argument, &want_flags, PKG_PATH }, { "path", no_argument, &want_flags, PKG_PATH },
{ "with-path", required_argument, NULL, 42 },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -714,6 +716,9 @@ main(int argc, char *argv[])
case 40: case 40:
logfile_arg = pkg_optarg; logfile_arg = pkg_optarg;
break; break;
case 42:
pkgconf_path_add(pkg_optarg, &pkg_client.dir_list, true);
break;
case '?': case '?':
case ':': case ':':
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@ -65,6 +65,9 @@ flag.
Ignore Ignore
.Sq Provides .Sq Provides
rules in modules when resolving dependencies. rules in modules when resolving dependencies.
.It Fl -with-path Ns = Ns Ar PATH
Adds a new module search path to pkgconf's dependency resolver. Paths added in
this way are given preference before other paths.
.El .El
.Sh MODULE-SPECIFIC OPTIONS .Sh MODULE-SPECIFIC OPTIONS
.Bl -tag -width indent .Bl -tag -width indent

View File

@ -32,7 +32,8 @@ tests_init \
pkg_config_path \ pkg_config_path \
nolibs \ nolibs \
nocflags \ nocflags \
arbitary_path arbitary_path \
with_path
noargs_body() noargs_body()
{ {
@ -255,6 +256,16 @@ pkg_config_path_body()
pkgconf --libs bar pkgconf --libs bar
} }
with_path_body()
{
atf_check \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --with-path=${selfdir}/lib1 --with-path=${selfdir}/lib2 --libs foo
atf_check \
-o inline:"-L/test/lib -lbar -lfoo \n" \
pkgconf --with-path=${selfdir}/lib1 --with-path=${selfdir}/lib2 --libs bar
}
nolibs_body() nolibs_body()
{ {
export PKG_CONFIG_PATH="${selfdir}/lib1" export PKG_CONFIG_PATH="${selfdir}/lib1"