From 4c09f5e51af4fc5d064cd7462b89c0d455dfab2a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 23 Nov 2023 00:04:18 +0100 Subject: Add method to setup LD_LIBRARY_PATH for grok. --- src/lib/util.cc | 25 +++++++++++++++++++++++++ src/lib/util.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/lib/util.cc b/src/lib/util.cc index 8cfdf0552..a25914a6c 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -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 diff --git a/src/lib/util.h b/src/lib/util.h index 2d65b9214..b85cf0a33 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -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 -- cgit v1.2.3