From 398e790cc1893af669f6cbf49abf1b567844d622 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 22 Mar 2018 09:42:24 -0400 Subject: [PATCH] Ignore Requires.internal if we only want cflags `pkg-config --cflags --libs dep` should not fail if internal packages are missing. https://bugs.freedesktop.org/show_bug.cgi?id=105572 --- check/check-requires-private | 3 +++ check/requires-notfound-test.pc | 9 +++++++++ main.c | 4 ++++ parse.c | 10 ++++++---- parse.h | 3 ++- pkg.c | 17 ++++++++++++++++- pkg.h | 2 ++ 7 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 check/requires-notfound-test.pc diff --git a/check/check-requires-private b/check/check-requires-private index 66e3ef7..586b33e 100755 --- a/check/check-requires-private +++ b/check/check-requires-private @@ -7,12 +7,15 @@ set -e # expect cflags from requires-test, public-dep and private-dep but not internal-dep RESULT="-I/requires-test/include -I/private-dep/include -I/public-dep/include" run_test --cflags requires-test +run_test --cflags requires-notfound-test run_test --static --cflags requires-test +run_test --static --cflags requires-notfound-test # expect libs for just requires-test and public-dep RESULT="-L/requires-test/lib -L/public-dep/lib -lrequires-test -lpublic-dep" if [ "$list_indirect_deps" = no ]; then run_test --libs requires-test + run_test --libs requires-notfound-test fi # expect libs for requires-test, public-dep, private-dep and internal-dep in static case diff --git a/check/requires-notfound-test.pc b/check/requires-notfound-test.pc new file mode 100644 index 0000000..dfe46b6 --- /dev/null +++ b/check/requires-notfound-test.pc @@ -0,0 +1,9 @@ +Name: Requires test package +Description: Dummy pkgconfig test package for testing Requires/Requires.private +Version: 1.0.0 +Requires: public-dep >= 1 +Requires.private: private-dep >= 1 +Requires.internal: notfound-dep >= 1 +Libs: -L/requires-test/lib -lrequires-test +Cflags: -I/requires-test/include + diff --git a/main.c b/main.c index 6ed8aba..65497a7 100644 --- a/main.c +++ b/main.c @@ -650,6 +650,10 @@ main (int argc, char **argv) (want_static_lib_list && (pkg_flags & LIBS_ANY))) enable_requires_private(); + if (want_requires_private || want_exists || + (want_static_lib_list && (pkg_flags & LIBS_ANY))) + enable_requires_internal(); + /* ignore Requires if no Cflags or Libs are requested */ if (pkg_flags == 0 && !want_requires && !want_exists) diff --git a/parse.c b/parse.c index 02a4cf3..6d6b171 100644 --- a/parse.c +++ b/parse.c @@ -926,7 +926,8 @@ parse_url (Package *pkg, const char *str, const char *path) static void parse_line (Package *pkg, const char *untrimmed, const char *path, gboolean ignore_requires, gboolean ignore_private_libs, - gboolean ignore_requires_private) + gboolean ignore_requires_private, + gboolean ignore_requires_internal) { char *str; char *p; @@ -976,7 +977,7 @@ parse_line (Package *pkg, const char *untrimmed, const char *path, } else if (strcmp (tag, "Requires.internal") == 0) { - if (!ignore_requires_private) + if (!ignore_requires_internal) parse_requires_internal (pkg, p, path); } else if (strcmp (tag, "Requires") == 0) @@ -1113,7 +1114,8 @@ Package* parse_package_file (const char *key, const char *path, gboolean ignore_requires, gboolean ignore_private_libs, - gboolean ignore_requires_private) + gboolean ignore_requires_private, + gboolean ignore_requires_internal) { FILE *f; Package *pkg; @@ -1158,7 +1160,7 @@ parse_package_file (const char *key, const char *path, one_line = TRUE; parse_line (pkg, str->str, path, ignore_requires, ignore_private_libs, - ignore_requires_private); + ignore_requires_private, ignore_requires_internal); g_string_truncate (str, 0); } diff --git a/parse.h b/parse.h index db1bf86..6736f58 100644 --- a/parse.h +++ b/parse.h @@ -25,7 +25,8 @@ Package *parse_package_file (const char *key, const char *path, gboolean ignore_requires, gboolean ignore_private_libs, - gboolean ignore_requires_private); + gboolean ignore_requires_private, + gboolean ignore_requires_internal); GList *parse_module_list (Package *pkg, const char *str, const char *path); diff --git a/pkg.c b/pkg.c index 47725d6..c1f09f1 100644 --- a/pkg.c +++ b/pkg.c @@ -49,6 +49,7 @@ static GList *search_dirs = NULL; gboolean disable_uninstalled = FALSE; gboolean ignore_requires = FALSE; gboolean ignore_requires_private = TRUE; +gboolean ignore_requires_internal = TRUE; gboolean ignore_private_libs = TRUE; void @@ -317,7 +318,8 @@ internal_get_package (const char *name, gboolean warn) debug_spew ("Reading '%s' from file '%s'\n", name, location); pkg = parse_package_file (key, location, ignore_requires, - ignore_private_libs, ignore_requires_private); + ignore_private_libs, ignore_requires_private, + ignore_requires_internal); g_free (key); if (pkg != NULL && strstr (location, "uninstalled.pc")) @@ -1195,6 +1197,7 @@ print_package_list (void) ignore_requires = TRUE; ignore_requires_private = TRUE; + ignore_requires_internal = TRUE; g_hash_table_foreach (packages, max_len_foreach, &mlen); g_hash_table_foreach (packages, packages_foreach, GINT_TO_POINTER (mlen + 1)); @@ -1235,3 +1238,15 @@ disable_requires_private(void) { ignore_requires_private = TRUE; } + +void +enable_requires_internal(void) +{ + ignore_requires_internal = FALSE; +} + +void +disable_requires_internal(void) +{ + ignore_requires_internal = TRUE; +} diff --git a/pkg.h b/pkg.h index 584a6e2..18bde7e 100644 --- a/pkg.h +++ b/pkg.h @@ -129,6 +129,8 @@ void enable_requires(void); void disable_requires(void); void enable_requires_private(void); void disable_requires_private(void); +void enable_requires_internal(void); +void disable_requires_internal(void); /* If TRUE, do not automatically prefer uninstalled versions */ extern gboolean disable_uninstalled; -- 2.14.1