mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2025-12-20 04:20:04 +01:00
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
This commit is contained in:
parent
34657e444f
commit
02d5ae3fb6
9 changed files with 114 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
52
check/check-missing
Executable file
52
check/check-missing
Executable file
|
|
@ -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
|
||||
12
check/missing-requires-private.pc
Normal file
12
check/missing-requires-private.pc
Normal file
|
|
@ -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
|
||||
7
main.c
7
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);
|
||||
|
|
|
|||
18
parse.c
18
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);
|
||||
}
|
||||
|
|
|
|||
3
parse.h
3
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);
|
||||
|
||||
|
|
|
|||
20
pkg.c
20
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;
|
||||
}
|
||||
|
|
|
|||
2
pkg.h
2
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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue