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>
Sun, 28 Jan 2024 01:01:58 +0000 (02:01 +0100)
src/lib/util.cc
src/lib/util.h

index 5e1b2ee496f103c40ee9cb3879418439be02fc7e..e8cbe984372eb000e5d11e2c8806da3485f49cdb 100644 (file)
@@ -1118,3 +1118,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>