From d7bf55a194585372fa3bf57fb5f5a6b5d66fa9a4 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 18 Jan 2017 11:36:52 -0600 Subject: [PATCH] main: add --with-path CLI option (closes #104) --- main.c | 5 +++++ pkgconf.1 | 3 +++ tests/basic.sh | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index cc14b13..0bcf79c 100644 --- a/main.c +++ b/main.c @@ -577,6 +577,7 @@ usage(void) printf(" --no-cache do not cache already seen packages when\n"); printf(" walking the dependency graph\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"); @@ -681,6 +682,7 @@ main(int argc, char *argv[]) { "validate", no_argument, NULL, 0 }, { "log-file", required_argument, NULL, 40 }, { "path", no_argument, &want_flags, PKG_PATH }, + { "with-path", required_argument, NULL, 42 }, { NULL, 0, NULL, 0 } }; @@ -714,6 +716,9 @@ main(int argc, char *argv[]) case 40: logfile_arg = pkg_optarg; break; + case 42: + pkgconf_path_add(pkg_optarg, &pkg_client.dir_list, true); + break; case '?': case ':': return EXIT_FAILURE; diff --git a/pkgconf.1 b/pkgconf.1 index b81cc94..ba20380 100644 --- a/pkgconf.1 +++ b/pkgconf.1 @@ -65,6 +65,9 @@ flag. Ignore .Sq Provides 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 .Sh MODULE-SPECIFIC OPTIONS .Bl -tag -width indent diff --git a/tests/basic.sh b/tests/basic.sh index 426db40..294246e 100755 --- a/tests/basic.sh +++ b/tests/basic.sh @@ -32,7 +32,8 @@ tests_init \ pkg_config_path \ nolibs \ nocflags \ - arbitary_path + arbitary_path \ + with_path noargs_body() { @@ -255,6 +256,16 @@ pkg_config_path_body() 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() { export PKG_CONFIG_PATH="${selfdir}/lib1"