]> err.no Git - pkg-config/commitdiff
2009-03-30 Tollef Fog Heen <tfheen@err.no>
authorTollef Fog Heen <tfheen@err.no>
Mon, 30 Mar 2009 18:40:53 +0000 (20:40 +0200)
committerTollef Fog Heen <tfheen@err.no>
Mon, 30 Mar 2009 18:40:53 +0000 (20:40 +0200)
* pkg.[ch], parse.[ch], main.c, check/Makefile.am,
check/check-missing, check/missing-requires-private.pc:
Skip Requires.private unless we need to look at them for cflags.
Add test case.  Thanks to Loïc Minier for most of the idea and the
implementation.  Debian #475031

ChangeLog
check/Makefile.am
check/check-missing [new file with mode: 0755]
check/missing-requires-private.pc [new file with mode: 0644]
main.c
parse.c
parse.h
pkg.c
pkg.h

index 5191f59460f3931a495cb0554205ea356089a389..46a6603e95aa9a2ae0890224141b6d2b059d1b1f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-03-30  Tollef Fog Heen  <tfheen@err.no>
 
+       * pkg.[ch], parse.[ch], main.c, check/Makefile.am,
+       check/check-missing, check/missing-requires-private.pc:
+       Skip Requires.private unless we need to look at them for cflags.
+       Add test case.  Thanks to Loïc Minier for most of the idea and the
+       implementation.  Debian #475031
+
        * check/common: Run all tests in the C locale
 
        * check/common: Add support for non-zero return codes to test
index 772c8ad18db1629bcf90557d219eb4e931ba9e4b..355f1922ff7fb76d449a99334decae3d6ad59757 100644 (file)
@@ -1,8 +1,8 @@
 
 TESTS = check-cflags check-libs check-define-variable  \
        check-libs-private check-requires-private check-includedir \
-       check-conflicts
+       check-conflicts check-missing
 
 EXTRA_DIST = $(TESTS) common simple.pc requires-test.pc public-dep.pc  \
-       private-dep.pc includedir.pc
+       private-dep.pc includedir.pc missing-requires-private.pc
 
diff --git a/check/check-missing b/check/check-missing
new file mode 100755 (executable)
index 0000000..bd2650c
--- /dev/null
@@ -0,0 +1,52 @@
+#! /bin/sh
+
+# Make sure we're POSIX
+if [ "$PKG_CONFIG_SHELL_IS_POSIX" != "1" ]; then
+    PKG_CONFIG_SHELL_IS_POSIX=1 PATH=`getconf PATH` exec sh $0 "$@"
+fi
+
+. ${srcdir}/common
+
+# non-existent package; call should fail and cause no output
+EXPECT_RETURN=1
+RESULT=""
+ARGS="pkg-non-existent"
+run_test
+
+# tests below are on an existing package, but with missing Requires.private;
+# when pkg-config outputs error, the actual error text isn't checked
+# package exists
+ARGS="missing-requires-private"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+# get Libs
+ARGS="--libs missing-requires-private"
+EXPECT_RETURN=0
+RESULT="-L/missing-requires-private/lib -lmissing-requires-private"
+run_test
+
+# Libs.private should fail (verbosely, but the output isn't verified)
+ARGS="--silence-errors --static --libs missing-requires-private"
+EXPECT_RETURN=1
+RESULT=""
+run_test
+
+# Cflags.private should fail (verbosely, but the output isn't verified)
+ARGS="--silence-errors --static --cflags missing-requires-private"
+EXPECT_RETURN=1
+RESULT=""
+run_test
+
+# Cflags should fail (verbosely, but the output isn't verified)
+ARGS="--silence-errors --cflags missing-requires-private"
+EXPECT_RETURN=1
+RESULT=""
+run_test
+
+# get includedir var
+ARGS="--variable includedir missing-requires-private"
+EXPECT_RETURN=0
+RESULT="/usr/include/somedir"
+run_test
diff --git a/check/missing-requires-private.pc b/check/missing-requires-private.pc
new file mode 100644 (file)
index 0000000..171c866
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include/somedir
+
+Name: Missing Requires.private test package
+Description: Dummy package for testing with a missing Requires.private
+Version: 1.0.0
+Requires.private: pkg-non-existent-private-dep
+Libs: -L/missing-requires-private/lib -lmissing-requires-private
+Cflags: -I/missing-requires-private/include
+foodir: bar
diff --git a/main.c b/main.c
index a2bb2ce56a0d708e5f1e91db350079bab3b3ae56..568c171efeb901acc8a74332e748fe95f23d5160 100644 (file)
--- a/main.c
+++ b/main.c
@@ -384,6 +384,13 @@ main (int argc, char **argv)
   else
     disable_private_libs();
 
+  /* honor Requires.private if any Cflags are requested or any static
+   * libs are requested */
+
+  if (want_I_cflags || want_other_cflags || want_cflags ||
+      (want_static_lib_list && (want_libs || want_l_libs || want_L_libs)))
+    enable_requires_private();
+
   if (want_my_version)
     {
       printf ("%s\n", VERSION);
diff --git a/parse.c b/parse.c
index f773db3f2c5310e4fd8151f287319c74b9c49154..4c6275f00705d7d5b6e6ba1409d2a130d68cf39b 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2006-2008 Tollef Fog Heen <tfheen@err.no>
+ * Copyright (C) 2006-2009 Tollef Fog Heen <tfheen@err.no>
  * Copyright (C) 2001, 2002, 2005-2006 Red Hat Inc.
  * 
  * This program is free software; you can redistribute it and/or
@@ -917,7 +917,9 @@ pathnamecmp (const char *a,
 #endif
 
 static void
-parse_line (Package *pkg, const char *untrimmed, const char *path, gboolean ignore_requires, gboolean ignore_private_libs)
+parse_line (Package *pkg, const char *untrimmed, const char *path,
+           gboolean ignore_requires, gboolean ignore_private_libs,
+           gboolean ignore_requires_private)
 {
   char *str;
   char *p;
@@ -961,7 +963,10 @@ parse_line (Package *pkg, const char *untrimmed, const char *path, gboolean igno
       else if (strcmp (tag, "Version") == 0)
         parse_version (pkg, p, path);
       else if (strcmp (tag, "Requires.private") == 0)
-       parse_requires_private (pkg, p, path);
+       {
+         if (!ignore_requires_private)
+           parse_requires_private (pkg, p, path);
+       }
       else if (strcmp (tag, "Requires") == 0)
        {
           if (ignore_requires == FALSE)
@@ -1078,7 +1083,9 @@ parse_line (Package *pkg, const char *untrimmed, const char *path, gboolean igno
 }
 
 Package*
-parse_package_file (const char *path, gboolean ignore_requires, gboolean ignore_private_libs)
+parse_package_file (const char *path, gboolean ignore_requires,
+                   gboolean ignore_private_libs,
+                   gboolean ignore_requires_private)
 {
   FILE *f;
   Package *pkg;
@@ -1115,7 +1122,8 @@ parse_package_file (const char *path, gboolean ignore_requires, gboolean ignore_
     {
       one_line = TRUE;
       
-      parse_line (pkg, str->str, path, ignore_requires, ignore_private_libs);
+      parse_line (pkg, str->str, path, ignore_requires, ignore_private_libs,
+                 ignore_requires_private);
 
       g_string_truncate (str, 0);
     }
diff --git a/parse.h b/parse.h
index f764f90b7fad0533f5258af6887bd39c25b83aeb..0da036c607bce4f9496e52daefd65fdce8d43d5b 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -23,7 +23,8 @@
 #include "pkg.h"
 
 Package *parse_package_file (const char *path, gboolean ignore_requires,
-                             gboolean ignore_private_libs);
+                            gboolean ignore_private_libs,
+                            gboolean ignore_requires_private);
 
 Package *get_compat_package (const char *name);
 
diff --git a/pkg.c b/pkg.c
index 0d750fd849b2229b876ec0251cc31d30bef82d6c..236462f2436fb96905a34c14487ff2fb9e2be7e8 100644 (file)
--- a/pkg.c
+++ b/pkg.c
@@ -55,6 +55,7 @@ static int scanned_dir_count = 0;
 
 gboolean disable_uninstalled = FALSE;
 gboolean ignore_requires = FALSE;
+gboolean ignore_requires_private = TRUE;
 gboolean ignore_private_libs = TRUE;
 
 void
@@ -337,7 +338,8 @@ internal_get_package (const char *name, gboolean warn, gboolean check_compat)
     }
 
   debug_spew ("Reading '%s' from file '%s'\n", name, location);
-  pkg = parse_package_file (location, ignore_requires, ignore_private_libs);
+  pkg = parse_package_file (location, ignore_requires, ignore_private_libs, 
+                           ignore_requires_private);
   
   if (pkg == NULL)
     {
@@ -1509,8 +1511,9 @@ void
 print_package_list (void)
 {
   int mlen = 0;
-  
+
   ignore_requires = TRUE;
+  ignore_requires_private = TRUE;
 
   g_hash_table_foreach (locations, max_len_foreach, &mlen);
   g_hash_table_foreach (locations, packages_foreach, GINT_TO_POINTER (mlen + 1));
@@ -1527,3 +1530,16 @@ disable_private_libs(void)
 {
   ignore_private_libs = TRUE;
 }
+
+
+void
+enable_requires_private(void)
+{
+  ignore_requires_private = FALSE;
+}
+
+void
+disable_requires_private(void)
+{
+  ignore_requires_private = TRUE;
+}
diff --git a/pkg.h b/pkg.h
index d749de40deccd81098f9141b0b5cc940a74d5532..97ea176963f294e18c2b6e266fa51e3f9124b363 100644 (file)
--- a/pkg.h
+++ b/pkg.h
@@ -119,6 +119,8 @@ gboolean name_ends_in_uninstalled (const char *str);
 
 void enable_private_libs(void);
 void disable_private_libs(void);
+void enable_requires_private(void);
+void disable_requires_private(void);
 
 /* If TRUE, do not automatically prefer uninstalled versions */
 extern gboolean disable_uninstalled;