Suggestion: Load specified .pc file / .pc parser

Daniel Macks dmacks at netspace.org
Tue Dec 17 01:52:11 PST 2013


On Tue, 17 Dec 2013 10:02:39 +0100, Tollef Fog Heen <tfheen at err.no> wrote:
]] Kevin Ingwersen
>
> > Also, I was wondering if there is a way to otherwise parse .pc
> > files. As the assignment syntax is mixed (colon token and equal token)
> > I can’t just apply it straight away into a PHP script or another C
> > source - I have never been really good with writing parsers ^^; So I
> > was wondering if there was a .pc-parser already available?
>
> There's one inside pkg-config itself, obviously.  I'm not sure it's
> worth the effort to make it into a library. 

There are some perl modules that do it, not sure how robust and 
up-to-date on .pc syntax they are, and if they are actual parsers 
(rather than just wrappers around system(pkgconfig) they might need 
customization if your pkgconfig itself is a patched version. 

When there becomes a formal spec[1], it would be easy to write a parser 
that follows it because the exact grammar/syntax options would be 
known. For example, the spec could take a self-documenting approach of 
"equals for shell-like variable assignment, colon for pkg-config data 
fields", or else allow either syntax but explicitly enumerate the valid 
fields with "anything else is a shell-like variable assignment". And 
the perl and other implementations could be double-checked for 
conformance. 

[1] https://bugs.freedesktop.org/show_bug.cgi?id=4738#c15

dan

  --
Daniel Macks
dmacks at netspace.org




More information about the pkg-config mailing list