From 65e2834347d7755544b99e3ff987b7e06edd28f0 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 16 Sep 2024 16:46:49 +0300 Subject: [PATCH] v.pkgconfig: fix parser, when includedir= lines, had trailing spaces (fix `-d use_openssl` for openssl 3.3.2 installed through brew on macos) --- vlib/v/pkgconfig/pkgconfig.v | 8 ++++++-- vlib/v/pkgconfig/pkgconfig_test.v | 8 ++++++++ vlib/v/pkgconfig/test_samples/openssl-3.3.2.pc | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 vlib/v/pkgconfig/test_samples/openssl-3.3.2.pc diff --git a/vlib/v/pkgconfig/pkgconfig.v b/vlib/v/pkgconfig/pkgconfig.v index 13271cce44ffb3..9257f3cf5f3296 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 a130c1f4f5f572..9cea08691e9364 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 00000000000000..05bc97604e5b6e --- /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 +