Bug 51883 - automatic prefix munging on Windows causes useless output with paths containing spaces
Summary: automatic prefix munging on Windows causes useless output with paths containi...
Status: RESOLVED FIXED
Alias: None
Product: pkg-config
Classification: Unclassified
Component: src (show other bugs)
Version: unspecified
Hardware: All Windows (All)
: medium normal
Assignee: Tollef Fog Heen
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-09 04:40 UTC by John Stumpo
Modified: 2012-08-21 12:50 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Escape spaces in autodetected ${prefix} values on Windows. (1.16 KB, patch)
2012-07-09 04:40 UTC, John Stumpo
Details | Splinter Review

Description John Stumpo 2012-07-09 04:40:59 UTC
Created attachment 63995 [details] [review]
Escape spaces in autodetected ${prefix} values on Windows.

On Windows, when pkg-config auto-rewrites the "prefix" variable and the path contains spaces, it considers each side of the space as a separate argument when it comes time to consolidate duplicate arguments. In most cases, this results in useless output.

Example:
(pkg-config is in "Z:\test dir\bin" and the .pc files are in "Z:\test dir\lib\pkgconfig")
$ pkg-config --cflags glib-2.0
dir/include/glib-2.0 dir/lib/glib-2.0/include -mms-bitfields -IZ:/test
$ pkg-config --cflags --libs gthread-2.0
dir/include/glib-2.0 dir/lib/glib-2.0/include -mms-bitfields -IZ:/test  dir/lib -LZ:/test -lgthread-2.0 -lglib-2.0 -lintl 

The attached patch adds a level of escaping at the time the value of ${prefix} is determined, which keeps the path together through pkg-config's processing and makes the result directly usable in compilation commands, despite the spaces. Here are the same examples done with the patch applied:
$ pkg-config-patched --cflags glib-2.0
-mms-bitfields -IZ:/test\ dir/include/glib-2.0 -IZ:/test\ dir/lib/glib-2.0/include
$ pkg-config-patched --cflags --libs gthread-2.0
-mms-bitfields -IZ:/test\ dir/include/glib-2.0 -IZ:/test\ dir/lib/glib-2.0/include  -LZ:/test\ dir/lib -lgthread-2.0 -lglib-2.0 -lintl
Comment 1 Dan Nicholson 2012-08-20 13:06:41 UTC
Comment on attachment 63995 [details] [review]
Escape spaces in autodetected ${prefix} values on Windows.

Review of attachment 63995 [details] [review]:
-----------------------------------------------------------------

I haven't tested, but this looks good. If you can address the comment below, I'll be happy to commit.

::: parse.c
@@ +1060,5 @@
> +		gchar *oldprefix = prefix;
> +		prefix = strdup_escape_shell(prefix);
> +		g_free(oldprefix);
> +	      }
> +

Instead of adding another block and variable, can we just reuse the q local variable? Also, space after function like other coding style.
Comment 2 Dan Nicholson 2012-08-21 12:50:50 UTC
I made those small changes and pushed them in commit f57fafe. Please reopen if you're still having issues.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.