diff --git a/vlib/v/pkgconfig/pkgconfig.v b/vlib/v/pkgconfig/pkgconfig.v index 13271cce44..9257f3cf5f 100644 --- a/vlib/v/pkgconfig/pkgconfig.v +++ b/vlib/v/pkgconfig/pkgconfig.v @@ -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 } diff --git a/vlib/v/pkgconfig/pkgconfig_test.v b/vlib/v/pkgconfig/pkgconfig_test.v index a130c1f4f5..9cea08691e 100644 --- a/vlib/v/pkgconfig/pkgconfig_test.v +++ b/vlib/v/pkgconfig/pkgconfig_test.v @@ -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' + } } } diff --git a/vlib/v/pkgconfig/test_samples/openssl-3.3.2.pc b/vlib/v/pkgconfig/test_samples/openssl-3.3.2.pc new file mode 100644 index 0000000000..05bc97604e --- /dev/null +++ b/vlib/v/pkgconfig/test_samples/openssl-3.3.2.pc @@ -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 +