Skip to content

Commit

Permalink
Allow passing custom arguments to CreateInterpreter
Browse files Browse the repository at this point in the history
Parameters of the interpreter are read from the INTEROP_EXTRA_INTERPRETER_ARGS
environment variable. If no arguments have been passed, the interpreter is
created with -std=c++17 and -march=native.

Signed-off-by: Andrzej Turko <[email protected]>
  • Loading branch information
a-turko committed Jul 20, 2023
1 parent 21795a4 commit bdecd72
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions clingwrapper/src/clingwrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,28 @@ static struct Signalmap_t {
// }
// };

static inline
void push_tokens_from_string(char *s, std::vector <const char*> &tokens) {
char *token = strtok(s, " ");

while (token) {
tokens.push_back(token);
token = strtok(NULL, " ");
}
}

class ApplicationStarter {
InterOp::TInterp_t Interp;
public:
ApplicationStarter() {
// Create the interpreter and initilize the pointer
// FIXME: We should make these flags available via the env variable
// INTEROP_EXTRA_INTERPRETER_ARGS
Interp = InterOp::CreateInterpreter({"-std=c++17", "-march=native"});

std::vector <const char *> InterpArgs({"-std=c++17", "-march=native"});
char *InterpArgString = getenv("INTEROP_EXTRA_INTERPRETER_ARGS");
if (InterpArgString)
push_tokens_from_string(InterpArgString, InterpArgs);

Interp = InterOp::CreateInterpreter(InterpArgs);

// fill out the builtins
std::set<std::string> bi{g_builtins};
Expand Down

0 comments on commit bdecd72

Please sign in to comment.