summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2013-05-16 07:41:13 -0700
committerDan Nicholson <dbn.lists@gmail.com>2014-09-27 16:45:50 -0700
commit0e847a2201ace5e53e474c52ad5b51e70607980e (patch)
tree1ecbda0d9bbcfc35714cdffb8a8be14ea07059c5
parentce1a2416ce0f0bd9a8a8a5caaf7dad20cda4d47d (diff)
Add --validate option to check .pc syntax without dependencies
Provide developers a way to check their .pc files prior to release. This works the same as --exists except that package dependencies are not processed. That allows the .pc file to be checked in complete isolation of others. Freedesktop #7000 (https://bugs.freedesktop.org/show_bug.cgi?id=7000)
-rw-r--r--main.c11
-rw-r--r--pkg-config.114
2 files changed, 22 insertions, 3 deletions
diff --git a/main.c b/main.c
index 62758b8..8d37644 100644
--- a/main.c
+++ b/main.c
@@ -50,6 +50,7 @@ static gboolean want_exists = FALSE;
static gboolean want_provides = FALSE;
static gboolean want_requires = FALSE;
static gboolean want_requires_private = FALSE;
+static gboolean want_validate = FALSE;
static char *required_atleast_version = NULL;
static char *required_exact_version = NULL;
static char *required_max_version = NULL;
@@ -247,6 +248,8 @@ output_opt_cb (const char *opt, const char *arg, gpointer data,
want_requires = TRUE;
else if (strcmp (opt, "--print-requires-private") == 0)
want_requires_private = TRUE;
+ else if (strcmp (opt, "--validate") == 0)
+ want_validate = TRUE;
else
return FALSE;
@@ -461,6 +464,8 @@ static const GOptionEntry options_table[] = {
{ "print-requires-private", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
&output_opt_cb, "print which packages the package requires for static "
"linking", NULL },
+ { "validate", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ &output_opt_cb, "validate a package's .pc file", NULL },
{ "define-prefix", 0, 0, G_OPTION_ARG_NONE, &define_prefix,
"try to override the value of prefix for each .pc file found with a "
"guesstimated value based on the location of the .pc file", NULL },
@@ -682,8 +687,10 @@ main (int argc, char **argv)
g_string_free (str, TRUE);
- if (want_exists)
- return 0; /* if we got here, all the packages existed. */
+ /* If the user just wants to check package existence or validate its .pc
+ * file, we're all done. */
+ if (want_exists || want_validate)
+ return 0;
if (want_variable_list)
{
diff --git a/pkg-config.1 b/pkg-config.1
index 3ee869f..74bb70a 100644
--- a/pkg-config.1
+++ b/pkg-config.1
@@ -21,7 +21,7 @@ pkg-config \- Return metainformation about installed libraries
[\-\-print-variables]
[\-\-uninstalled]
[\-\-exists] [\-\-atleast-version=VERSION] [\-\-exact-version=VERSION]
-[\-\-max-version=VERSION] [\-\-list\-all] [\-\-print-provides]
+[\-\-max-version=VERSION] [\-\-validate] [\-\-list\-all] [\-\-print-provides]
[\-\-print-requires] [\-\-print-requires-private] [LIBRARIES...]
.SH DESCRIPTION
@@ -214,6 +214,18 @@ constraint after each package name, for example:
Remember to use \-\-print-errors if you want error messages. When no
output options are supplied to \fIpkg-config\fP, \-\-exists is implied.
.TP
+.I "--validate"
+Checks the syntax of a package's
+.I .pc
+file for validity. This is the same as \-\-exists except that
+dependencies are not verified. This can be useful for package developers
+to test their
+.I .pc
+file prior to release:
+.nf
+ $ pkg-config --validate ./my-package.pc
+.fi
+.TP
.I "--msvc-syntax"
This option is available only on Windows. It causes \fIpkg-config\fP
to output -l and -L flags in the form recognized by the Microsoft