Skip to content

Commit

Permalink
v.pkgconfig: fix parser, when includedir= lines, had trailing spaces …
Browse files Browse the repository at this point in the history
…(fix `-d use_openssl` for openssl 3.3.2 installed through brew on macos)
  • Loading branch information
spytheman committed Sep 16, 2024
1 parent 0fb95a8 commit 65e2834
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vlib/v/pkgconfig/pkgconfig.v
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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:
Expand All @@ -31,6 +32,7 @@ pub:

pub struct PkgConfig {
pub mut:
file_path string
options Options
name string
modname string
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions vlib/v/pkgconfig/pkgconfig_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
}
12 changes: 12 additions & 0 deletions vlib/v/pkgconfig/test_samples/openssl-3.3.2.pc
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 65e2834

Please sign in to comment.