tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg-config-0.26



On Friday, at 16:26, Julio Merino wrote:
| Good luck maintaining obsolete sources.  Or good luck rewriting this in 
| C, but you'll soon realize that it's not as trivial as it seems.

The trivial version ... is trivial (i.e. the version merely extracting key:
value pairs and doing variable expansion). It can be written in about 15 lines
of 'awk' (bsd license excepted ;)

The complete version (handling recursive Require: and filtering duplicate
c/ldflags) definitely requires more work, but it is also definititely more
easily written in the "good scripting language" of your choice than in C (not
even talking about using glib just for that...). Of course you'd have to
implement all pkg-config bugs to have a really compatible version (Marc Espie
will probably confirm ;) 

Just to illustrate my mail, I wrote a trivial awk program. Aleksej will be
happy to develop this further, I guess :)

awk -v field=Cflags </usr/pkg/lib/pkgconfig/glib.pc '
/=/ {
    match($0, /=/)
    v[substr($0, 0, RSTART-1)] = substr($0, RSTART+1)
}

/:/ {
    match($0, /:/)
    f = substr($0, RSTART+1);
    if (field == substr($0, 0, RSTART-1)) {
        while (match(f, /\${[^}]*}/)) {
            r = v[substr(f,RSTART+2,RLENGTH-3)]
            f = substr(f,0,RSTART-1) r substr(f,RSTART+RLENGTH)
        }
        print f
    }
}
'


Home | Main Index | Thread Index | Old Index