File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -224,20 +224,36 @@ fn (mut pc PkgConfig) load_require(dep string) ? {
224224}
225225
226226fn (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
236242fn (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)
You can’t perform that action at this time.
0 commit comments