| 34 | inline namespace MIGRAPHX_INLINE_NS { |
| 35 | |
| 36 | std::vector<char> src_compiler::compile(const std::vector<src_file>& srcs) const |
| 37 | { |
| 38 | assert(not srcs.empty()); |
| 39 | tmp_dir td{"compile"}; |
| 40 | std::vector<std::string> params{flags}; |
| 41 | |
| 42 | params.emplace_back("-I."); |
| 43 | |
| 44 | auto out = output; |
| 45 | |
| 46 | for(const auto& src : srcs) |
| 47 | { |
| 48 | fs::path full_path = td.path / src.path; |
| 49 | fs::path parent_path = full_path.parent_path(); |
| 50 | fs::create_directories(parent_path); |
| 51 | write_buffer(full_path, src.content.data(), src.content.size()); |
| 52 | if(src.path.extension().string() == ".cpp") |
| 53 | { |
| 54 | params.emplace_back(src.path.filename().string()); |
| 55 | if(out.empty()) |
| 56 | out = src.path.stem().string() + out_ext; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | params.emplace_back("-o " + out); |
| 61 | |
| 62 | std::vector<std::string> args; |
| 63 | if(not launcher.empty()) |
| 64 | args.push_back(compiler.string()); |
| 65 | args.insert(args.end(), params.begin(), params.end()); |
| 66 | td.execute(launcher.empty() ? compiler : launcher, args); |
| 67 | |
| 68 | auto out_path = td.path / out; |
| 69 | if(not fs::exists(out_path)) |
| 70 | MIGRAPHX_THROW("Output file missing: " + out); |
| 71 | |
| 72 | return read_buffer(out_path); |
| 73 | } |
| 74 | |
| 75 | } // namespace MIGRAPHX_INLINE_NS |
| 76 | } // namespace migraphx |
nothing calls this directly
no test coverage detected