Skip to content

Commit 7c02274

Browse files
committed
v.pkgconfig: support PKG_CONFIG_PATH_DEFAULTS for overriding the default search path list too (enable easier -m32 with a custom tcc cross compiler)
1 parent 1ba1f99 commit 7c02274

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

vlib/v/pkgconfig/pkgconfig.v

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,36 @@ fn (mut pc PkgConfig) load_require(dep string) ? {
224224
}
225225

226226
fn (mut pc PkgConfig) add_path(path string) {
227-
p := if path.ends_with('/') { path[0..path.len - 1] } else { path }
227+
if path == '' {
228+
return
229+
}
230+
p := path.trim_right('/')
228231
if !os.exists(p) {
229232
return
230233
}
234+
$if trace_pkgconfig_add_path ? {
235+
eprintln('> PkgConfig.add_path path: ${p}')
236+
}
231237
if pc.paths.index(p) == -1 {
232238
pc.paths << p
233239
}
234240
}
235241

236242
fn (mut pc PkgConfig) load_paths() {
237-
if pc.options.use_default_paths {
238-
for path in pkgconfig.default_paths {
243+
// Allow for full custom user control over the default paths too, through
244+
// setting `PKG_CONFIG_PATH_DEFAULTS` to a list of search paths, separated
245+
// by `:`.
246+
config_path_override := os.getenv('PKG_CONFIG_PATH_DEFAULTS')
247+
if config_path_override != '' {
248+
for path in config_path_override.split(':') {
239249
pc.add_path(path)
240250
}
251+
} else {
252+
if pc.options.use_default_paths {
253+
for path in pkgconfig.default_paths {
254+
pc.add_path(path)
255+
}
256+
}
241257
}
242258
for path in pc.options.path.split(':') {
243259
pc.add_path(path)

0 commit comments

Comments
 (0)