summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2009-03-30 20:40:53 +0200
committerTollef Fog Heen <tfheen@err.no>2009-03-30 20:40:53 +0200
commit02d5ae3fb61c52f642d3b6b41973f12372fcdc60 (patch)
tree6f4f2952c0d62cfd0b92be663557cc6108b21093
parent34657e444f7a8879ea3ed7b5d5d795fe96b231c7 (diff)
downloadpkg-config-02d5ae3fb61c52f642d3b6b41973f12372fcdc60.tar.gz
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
-rw-r--r--ChangeLog6
-rw-r--r--check/Makefile.am4
-rwxr-xr-xcheck/check-missing52
-rw-r--r--check/missing-requires-private.pc12
-rw-r--r--main.c7
-rw-r--r--parse.c18
-rw-r--r--parse.h3
-rw-r--r--pkg.c20
-rw-r--r--pkg.h2
9 files changed, 114 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 5191f59..46a6603 100644
--- 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
diff --git a/check/Makefile.am b/check/Makefile.am
index 772c8ad..355f192 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -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
index 0000000..bd2650c
--- /dev/null
+++ b/check/check-missing
@@ -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
index 0000000..171c866
--- /dev/null
+++ b/check/missing-requires-private.pc
@@ -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 a2bb2ce..568c171 100644
--- 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 f773db3..4c6275f 100644
--- 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 f764f90..0da036c 100644
--- 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 0d750fd..236462f 100644
--- 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 d749de4..97ea176 100644
--- 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;