diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index 0c3fe6f097dc4a8cdb046e3c3ede35118260c76b..321029e9bfef2d95fccfab7b9b42c94b2a5009ec 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -30,6 +30,8 @@ #include "RConfigure.h" #include <atomic> +#include <string> +#include <vector> class TClass; class TCanvas; @@ -355,6 +357,7 @@ public: static Int_t ConvertVersionCode2Int(Int_t code); static Int_t ConvertVersionInt2Code(Int_t v); static Int_t RootVersionCode(); + static const std::vector<std::string> &AddExtraInterpreterArgs(const std::vector<std::string> &args); static const char**&GetExtraInterpreterArgs(); static const TString& GetRootSys(); diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index ed9d317d97b337f3fc21d1e6e01a559d93c5d93a..10a765747eaac76397834858ff3a2f9024467bb8 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -2901,8 +2901,22 @@ Int_t TROOT::RootVersionCode() { return ROOT_VERSION_CODE; } +//////////////////////////////////////////////////////////////////////////////// +/// Provide command line arguments to the interpreter construction. +/// These arguments are added to the existing flags (e.g. `-DNDEBUG`). +/// They are evaluated once per process, at the time where TROOT (and thus +/// TInterpreter) is constructed. +/// Returns the new flags. + +const std::vector<std::string> &TROOT::AddExtraInterpreterArgs(const std::vector<std::string> &args) { + static std::vector<std::string> sArgs = {}; + sArgs.insert(sArgs.begin(), args.begin(), args.end()); + return sArgs; +} //////////////////////////////////////////////////////////////////////////////// +/// INTERNAL function! +/// Used by rootcling to inject interpreter arguments through a C-interface layer. const char**& TROOT::GetExtraInterpreterArgs() { static const char** extraInterpArgs = 0; diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index e8246b55e1cb38ce8a45548f6d86e2aaf90b5fe9..208da4110f15ece14ea5b829c432d9cf46771916 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1254,6 +1254,10 @@ TCling::TCling(const char *name, const char *title, const char* const argv[]) } } + for (const auto &arg: TROOT::AddExtraInterpreterArgs({})) { + interpArgs.push_back(arg.c_str()); + } + fInterpreter = new cling::Interpreter(interpArgs.size(), &(interpArgs[0]), llvmResourceDir);