2016-01-27 06:40:11 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-02-08 05:56:52 +08:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "utils/string/join.hpp"
|
|
|
|
|
2016-01-27 06:40:11 +08:00
|
|
|
class CodeCompiler
|
|
|
|
{
|
2016-02-08 05:56:52 +08:00
|
|
|
public:
|
2016-02-22 05:21:15 +08:00
|
|
|
|
2016-02-08 05:56:52 +08:00
|
|
|
void compile(const std::string& in_file, const std::string& out_file)
|
|
|
|
{
|
|
|
|
auto compile_command = utils::prints(
|
|
|
|
"clang++",
|
2016-02-22 05:21:15 +08:00
|
|
|
// "-std=c++1y -O2 -DNDEBUG", // compile flags
|
|
|
|
"-std=c++1y", // compile flags
|
|
|
|
in_file, // input file
|
|
|
|
"-o", out_file, // ouput file
|
|
|
|
"-I../", // include paths
|
|
|
|
"-shared -fPIC" // shared library flags
|
2016-02-08 05:56:52 +08:00
|
|
|
);
|
2016-02-11 06:34:49 +08:00
|
|
|
|
|
|
|
// synchronous call
|
2016-02-08 05:56:52 +08:00
|
|
|
system(compile_command.c_str());
|
|
|
|
}
|
2016-01-27 06:40:11 +08:00
|
|
|
};
|