v.pkgconfig: support Requires.private; handle double spaces in pkgconfig files (#7994)

pull/8008/head
pancake 2021-01-10 11:14:41 +01:00 committed by GitHub
parent 704f38d87f
commit 0e016baa34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 10 deletions

View File

@ -31,6 +31,7 @@ pub mut:
paths []string // TODO: move to options? paths []string // TODO: move to options?
vars map[string]string vars map[string]string
requires []string requires []string
requires_private []string
version string version string
description string description string
name string name string
@ -39,7 +40,7 @@ pub mut:
fn (mut pc PkgConfig) parse_list(s string) []string { fn (mut pc PkgConfig) parse_list(s string) []string {
operators := [ '=', '<', '>', '>=', '<=' ] operators := [ '=', '<', '>', '>=', '<=' ]
r := pc.parse_line(s.replace(',', '')).split(' ') r := pc.parse_line(s.replace(' ', ' ').replace(',', '')).split(' ')
mut res := []string{} mut res := []string{}
mut skip := false mut skip := false
for a in r { for a in r {
@ -113,6 +114,8 @@ fn (mut pc PkgConfig) parse(file string) bool {
pc.version = pc.parse_line(line[8..]) pc.version = pc.parse_line(line[8..])
} else if line.starts_with('Requires:') { } else if line.starts_with('Requires:') {
pc.requires = pc.parse_list(line[9..]) pc.requires = pc.parse_list(line[9..])
} else if line.starts_with('Requires.private:') {
pc.requires_private = pc.parse_list(line[17..])
} else if line.starts_with('Cflags:') { } else if line.starts_with('Cflags:') {
pc.cflags = pc.parse_list(line[7..]) pc.cflags = pc.parse_list(line[7..])
} else if line.starts_with('Libs:') { } else if line.starts_with('Libs:') {
@ -178,17 +181,25 @@ pub fn (mut pc PkgConfig) extend(pcdep &PkgConfig) ?string {
fn (mut pc PkgConfig) load_requires() { fn (mut pc PkgConfig) load_requires() {
for dep in pc.requires { for dep in pc.requires {
pc.load_require(dep)
}
for dep in pc.requires_private {
pc.load_require(dep)
}
}
fn (mut pc PkgConfig) load_require(dep string) {
mut pcdep := PkgConfig{ mut pcdep := PkgConfig{
paths: pc.paths paths: pc.paths
} }
depfile := pcdep.resolve(dep) or { depfile := pcdep.resolve(dep) or {
break eprintln('cannot resolve $dep')
return
} }
pcdep.parse(depfile) pcdep.parse(depfile)
pcdep.load_requires() pcdep.load_requires()
pc.extend(pcdep) pc.extend(pcdep)
} }
}
fn (mut pc PkgConfig) add_path(path string) { fn (mut pc PkgConfig) add_path(path string) {
p := if path.ends_with('/') { path[0..path.len - 1] } else { path } p := if path.ends_with('/') { path[0..path.len - 1] } else { path }