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-07-11 09:39:33 +08:00
|
|
|
// TODO: all libraries have to be compiled in the server compile time
|
|
|
|
// TODO: generate copile command
|
2016-01-27 06:40:11 +08:00
|
|
|
class CodeCompiler
|
|
|
|
{
|
2016-02-08 05:56:52 +08:00
|
|
|
public:
|
2016-06-06 17:29:52 +08:00
|
|
|
void compile(const std::string &in_file, const std::string &out_file)
|
2016-02-08 05:56:52 +08:00
|
|
|
{
|
2016-06-06 17:29:52 +08:00
|
|
|
auto compile_command =
|
|
|
|
utils::prints("clang++",
|
|
|
|
// "-std=c++1y -O2 -DNDEBUG", // compile flags
|
2016-07-11 09:39:33 +08:00
|
|
|
"-std=c++1y -DDEBUG", // compile flags
|
2016-06-06 17:29:52 +08:00
|
|
|
in_file, // input file
|
|
|
|
"-o", out_file, // ouput file
|
2016-06-27 06:43:28 +08:00
|
|
|
"-I./include", // include paths (TODO: parameter)
|
2016-07-11 09:39:33 +08:00
|
|
|
"-I./src",
|
|
|
|
"-I../../libs/fmt",
|
2016-06-06 17:29:52 +08:00
|
|
|
"-shared -fPIC" // shared library flags
|
|
|
|
);
|
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
|
|
|
};
|