1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v.pkgconfig: support PKG_CONFIG_PATH_DEFAULTS for overriding the default search path list too (enable easier -m32 with a custom tcc cross compiler)

This commit is contained in:
Delyan Angelov 2022-12-10 00:50:24 +02:00
parent 1ba1f99b9c
commit 7c02274754
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -224,21 +224,37 @@ fn (mut pc PkgConfig) load_require(dep string) ? {
}
fn (mut pc PkgConfig) add_path(path string) {
p := if path.ends_with('/') { path[0..path.len - 1] } else { path }
if path == '' {
return
}
p := path.trim_right('/')
if !os.exists(p) {
return
}
$if trace_pkgconfig_add_path ? {
eprintln('> PkgConfig.add_path path: ${p}')
}
if pc.paths.index(p) == -1 {
pc.paths << p
}
}
fn (mut pc PkgConfig) load_paths() {
// Allow for full custom user control over the default paths too, through
// setting `PKG_CONFIG_PATH_DEFAULTS` to a list of search paths, separated
// by `:`.
config_path_override := os.getenv('PKG_CONFIG_PATH_DEFAULTS')
if config_path_override != '' {
for path in config_path_override.split(':') {
pc.add_path(path)
}
} else {
if pc.options.use_default_paths {
for path in pkgconfig.default_paths {
pc.add_path(path)
}
}
}
for path in pc.options.path.split(':') {
pc.add_path(path)
}