From 18410e6a154a09b8389b87d13b1a9968825dd32a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 4 May 2024 19:48:27 +0300 Subject: [PATCH] Support environment variables as hints for binary package locations --- source/lib/binarypackage.cpp | 14 ++++++++++++++ source/lib/binarypackage.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/source/lib/binarypackage.cpp b/source/lib/binarypackage.cpp index d9df0a1..09cd652 100644 --- a/source/lib/binarypackage.cpp +++ b/source/lib/binarypackage.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include "binarypackage.h" @@ -100,6 +101,13 @@ bool BinaryPackage::locate_files() { vector bases; + for(const string &e: env_hints) + { + string env_value = getenv(e); + if(!env_value.empty()) + bases.push_back(env_value); + } + /* If we have any relative paths that need resolving, or we have no paths at all and are not using pkg-config, look for files in prefix */ if(relative_paths || (!use_pkgconfig && export_binfo.libpath.empty() && export_binfo.incpath.empty())) @@ -176,6 +184,7 @@ BinaryPackage::Loader::Loader(BinaryPackage &p): DataFile::DerivedObjectLoader(p) { add("build_info", &Loader::build_info); + add("env_hint", &Loader::env_hint); add("header", &Loader::header); } @@ -184,6 +193,11 @@ void BinaryPackage::Loader::build_info() load_sub(obj.export_binfo); } +void BinaryPackage::Loader::env_hint(const string &e) +{ + obj.env_hints.push_back(e); +} + void BinaryPackage::Loader::header(const string &h) { obj.headers.push_back(h); diff --git a/source/lib/binarypackage.h b/source/lib/binarypackage.h index b690d83..9730a69 100644 --- a/source/lib/binarypackage.h +++ b/source/lib/binarypackage.h @@ -17,12 +17,14 @@ public: Loader(BinaryPackage &); private: void build_info(); + void env_hint(const std::string &); void header(const std::string &); }; using Flags = std::vector; private: + std::vector env_hints; bool relative_paths = false; bool found_on_system = false; Msp::FS::Path base_path; -- 2.45.2