Add method to setup LD_LIBRARY_PATH for grok.
authorCarl Hetherington <cth@carlh.net>
Wed, 22 Nov 2023 23:04:18 +0000 (00:04 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Nov 2023 20:20:31 +0000 (21:20 +0100)
src/lib/util.cc
src/lib/util.h

index 8cfdf0552307148d10dad94d30764dc1c2249872..a25914a6c6e99dc3c5df1df7ae6d5f0de06b753e 100644 (file)
@@ -1117,3 +1117,28 @@ word_wrap(string input, int columns)
        return output;
 }
 
+
+
+#ifdef DCPOMATIC_GROK
+void
+setup_grok_library_path()
+{
+       static std::string old_path;
+       if (old_path.empty()) {
+               old_path = getenv("LD_LIRARY_PATH");
+       }
+       auto const grok = Config::instance()->grok();
+       if (!grok || grok->binary_location.empty()) {
+               setenv("LD_LIRARY_PATH", old_path.c_str(), 1);
+               return;
+       }
+
+       std::string new_path = old_path;
+       if (!new_path.empty()) {
+               new_path += ":";
+       }
+       new_path += grok->binary_location.string();
+
+       setenv("LD_LIBRARY_PATH", new_path.c_str(), 1);
+}
+#endif
index 2d65b92142005541f9a1391385085a655a2887d9..b85cf0a333fef898a4829e15917bbd7afdd61651 100644 (file)
@@ -98,6 +98,9 @@ extern std::string error_details(boost::system::error_code ec);
 extern bool contains_assetmap(boost::filesystem::path dir);
 extern std::string word_wrap(std::string input, int columns);
 extern void capture_ffmpeg_logs();
+#ifdef DCPOMATIC_GROK
+extern void setup_grok_library_path();
+#endif
 
 
 template <class T>