v.pkgconfig: fix parser, when includedir= lines, had trailing spaces (fix -d use_openssl for openssl 3.3.2 installed through brew on macos)

This commit is contained in:
Delyan Angelov 2024-09-16 16:46:49 +03:00
parent 0fb95a8ff8
commit 65e2834347
3 changed files with 26 additions and 2 deletions

View file

@ -3,6 +3,8 @@ module pkgconfig
import semver
import os
const version = '0.3.4'
const default_paths = [
'/usr/local/lib/x86_64-linux-gnu/pkgconfig',
'/usr/local/lib64/pkgconfig',
@ -18,7 +20,6 @@ const default_paths = [
'/usr/libdata/pkgconfig', // FreeBSD
'/usr/lib/i386-linux-gnu/pkgconfig', // Debian 32bit
]
const version = '0.3.3'
pub struct Options {
pub:
@ -31,6 +32,7 @@ pub:
pub struct PkgConfig {
pub mut:
file_path string
options Options
name string
modname string
@ -92,6 +94,7 @@ fn (mut pc PkgConfig) setvar(line string) {
}
fn (mut pc PkgConfig) parse(file string) bool {
pc.file_path = file
data := os.read_file(file) or { return false }
if pc.options.debug {
eprintln(data)
@ -105,7 +108,8 @@ fn (mut pc PkgConfig) parse(file string) bool {
}
}
} else {
for line in lines {
for oline in lines {
line := oline.trim_space()
if line.starts_with('#') {
continue
}

View file

@ -88,5 +88,13 @@ fn test_samples() {
assert x.version == '2.64.3'
assert x.conflicts == []
}
if x.name == 'OpenSSL' {
assert x.modname == 'openssl-3.3.2'
assert x.version == '3.3.2'
assert x.description == 'Secure Sockets Layer and cryptography libraries and tools'
assert x.vars['prefix'] == '/opt/homebrew/Cellar/openssl@3/3.3.2'
assert x.vars['libdir'] == '/opt/homebrew/Cellar/openssl@3/3.3.2/lib'
assert x.vars['includedir'] == '/opt/homebrew/Cellar/openssl@3/3.3.2/include'
}
}
}

View file

@ -0,0 +1,12 @@
## NOTE: this file has a space at the end of the includedir line. It is *deliberate*!
## That version with the space, was present in homebrew, and failed V compilations with `-d use_openssl` on macos.
## This .pc file is here, to prevent silent regressions for future cases like this.
prefix=/opt/homebrew/Cellar/openssl@3/3.3.2
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenSSL
Description: Secure Sockets Layer and cryptography libraries and tools
Version: 3.3.2