]> git.tdb.fi Git - builder.git/commitdiff
Support environment variables as hints for binary package locations
authorMikko Rasa <tdb@tdb.fi>
Sat, 4 May 2024 16:48:27 +0000 (19:48 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 4 May 2024 16:48:27 +0000 (19:48 +0300)
source/lib/binarypackage.cpp
source/lib/binarypackage.h

index d9df0a1f2049b12ee8e9b783578aa936e6ddaad0..09cd652b2999ede9417c7c6c045de62fcfc4f2f7 100644 (file)
@@ -1,5 +1,6 @@
 #include <limits>
 #include <msp/core/algorithm.h>
+#include <msp/core/environ.h>
 #include <msp/io/print.h>
 #include <msp/strings/utils.h>
 #include "binarypackage.h"
@@ -100,6 +101,13 @@ bool BinaryPackage::locate_files()
 {
        vector<FS::Path> 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<BinaryPackage, Package::Loader>(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);
index b690d83ebdfa5a263effaffda4494c0bf17161c0..9730a69dab5bea3667df6deb8322ea98172c929d 100644 (file)
@@ -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<std::string>;
 
 private:
+       std::vector<std::string> env_hints;
        bool relative_paths = false;
        bool found_on_system = false;
        Msp::FS::Path base_path;