17 #define COUT std::cout 19 #define COUT LogDebug("ExpressionEvaluator") 36 rm += sfile +
' ' +
ofile;
46 : m_name(
"VI_" + generateName()) {
48 pch +=
"/src/precompile.h";
63 std::ifstream
ss(file.c_str());
64 COUT <<
"local file: " << file << std::endl;
66 std::getline(
ss, cxxf);
70 std::string file = relDir + incDir + pch +
".cxxflags";
71 COUT <<
"file in release area: " << file << std::endl;
72 std::ifstream
ss(file.c_str());
74 std::getline(
ss, cxxf);
75 incDir = relDir + incDir;
81 std::string file = paDir + incDir + pch +
".cxxflags";
82 COUT <<
"file in base release area: " << file << std::endl;
83 std::ifstream
ss(file.c_str());
86 "ExpressionEvaluator",
87 pch +
" file not found neither in " +
baseDir +
" nor in " + relDir +
" nor in " + paDir);
88 std::getline(
ss, cxxf);
89 incDir = paDir + incDir;
94 std::regex rq(
"-I[^ ]+");
95 cxxf = std::regex_replace(cxxf, rq,
std::string(
""));
99 cxxf = std::regex_replace(cxxf, rq,
std::string(
"='\""));
102 std::regex rq(
"\" ");
103 cxxf = std::regex_replace(cxxf, rq,
std::string(
"\"' "));
105 COUT <<
'|' << cxxf <<
"|\n" << std::endl;
108 std::string cpp =
"c++ -H -Wall -shared -Winvalid-pch ";
110 cpp +=
" -I" + incDir;
111 cpp +=
" -o " + ofile +
' ' + sfile +
" 2>&1\n";
113 COUT << cpp << std::endl;
119 source +=
"struct " + m_name +
" final : public " + iname +
"{\n";
123 source +=
"extern " + quote +
'C' + quote +
' ' +
std::string(iname) +
"* " + factory +
"() {\n";
124 source +=
"static " + m_name +
" local;\n";
125 source +=
"return &local;\n}\n";
127 COUT << source << std::endl;
130 std::ofstream
tmp(sfile.c_str());
131 tmp << source << std::endl;
138 void* dl = dlopen(ofile.c_str(), RTLD_LAZY);
142 std::string(
"compilation/linking failed\n") + cpp +
ss +
"dlerror " + dlerror());
146 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())