From 006b6c88fff8c8b15108ce08352941b02f6274c8 Mon Sep 17 00:00:00 2001 Message-Id: <006b6c88fff8c8b15108ce08352941b02f6274c8.1368795508.git.dbn.lists@gmail.com> From: Dan Nicholson Date: Thu, 16 May 2013 07:41:13 -0700 Subject: [PATCH] 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) --- main.c | 11 +++++++++-- pkg-config.1 | 14 +++++++++++++- 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 ccbfa5c..19db4d2 100644 --- a/pkg-config.1 +++ b/pkg-config.1 @@ -18,7 +18,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 @@ -198,6 +198,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 -- 1.8.1.4