16 #define COUT std::cout 18 #define COUT LogDebug("ExpressionEvaluator") 35 rm += sfile +
' ' + ofile;
45 : m_name(
"VI_" + generateName()) {
47 pch +=
"/src/precompile.h";
62 std::ifstream
ss(
file.c_str());
63 COUT <<
"local file: " <<
file << std::endl;
65 std::getline(
ss, cxxf);
70 COUT <<
"file in release area: " <<
file << std::endl;
71 std::ifstream
ss(
file.c_str());
73 std::getline(
ss, cxxf);
74 incDir = relDir + incDir;
81 COUT <<
"file in base release area: " <<
file << std::endl;
82 std::ifstream
ss(
file.c_str());
85 "ExpressionEvaluator",
86 pch +
" file not found neither in " +
baseDir +
" nor in " + relDir +
" nor in " + paDir);
87 std::getline(
ss, cxxf);
88 incDir = paDir + incDir;
93 std::regex rq(
"-I[^ ]+");
94 cxxf = std::regex_replace(cxxf, rq,
std::string(
""));
98 cxxf = std::regex_replace(cxxf, rq,
std::string(
"='\""));
101 std::regex rq(
"\" ");
102 cxxf = std::regex_replace(cxxf, rq,
std::string(
"\"' "));
104 COUT <<
'|' << cxxf <<
"|\n" << std::endl;
107 std::string cpp =
"c++ -H -Wall -shared -Winvalid-pch ";
109 cpp +=
" -I" + incDir;
110 cpp +=
" -o " + ofile +
' ' + sfile +
" 2>&1\n";
112 COUT << cpp << std::endl;
118 source +=
"struct " +
m_name +
" final : public " + iname +
"{\n";
122 source +=
"extern " + quote +
'C' + quote +
' ' +
std::string(iname) +
"* " + factory +
"() {\n";
124 source +=
"return &local;\n}\n";
129 std::ofstream
tmp(sfile.c_str());
137 void* dl = dlopen(ofile.c_str(), RTLD_LAZY);
141 std::string(
"compilation/linking failed\n") + cpp +
ss +
"dlerror " + dlerror());
145 m_expr = dlsym(dl, factory.c_str());
std::string execSysCommand(const std::string &cmdline)
ExpressionEvaluator(const char *pkg, const char *iname, const std::string &iexpr)
static std::string const source
std::string getEnvironmentVariable(std::string const &name, std::string const &defaultValue=std::string())