1 #include "linker/linker.h"
3 #include "llvm_api/clang_frontend.h"
8 void Linker::add_files(
const vector<str> &filenames) {
9 _input_files.insert(_input_files.end(), filenames.begin(), filenames.end());
14 vector<const char *> args{};
15 args.push_back(
"clang");
16 args.push_back(
"-stdlib=libc++");
18 for (
const str &e : _input_files) {
19 args.push_back(e.c_str());
21 for (
const str &e : _flags) {
22 args.push_back(e.c_str());
24 args.push_back(
"-lm");
27 std::for_each(args.begin(), args.end(), [](
const auto &a) { std::cout << a <<
' '; });
30 return !clang_main((
int)args.size(), (
char **)args.data());
33 void Linker::add_flag(
const str &flag) { _flags.push_back(flag); }
35 void Linker::add_flags(vector<str> flags) { _flags.insert(_flags.begin(), flags.begin(), flags.end()); }