16namespace FS = std::filesystem;
24bool TOMLManifestBuilder::BuildTarget(BuildConfig& config) {
27 if (config.path_.empty()) {
33 if (!FS::exists(
path)) {
40 auto toml_file = toml::parse_file(
path);
43 auto* description = toml_file[
"description"].as_string();
45 if (!description)
throw std::runtime_error({});
55 auto* compiler_path_ptr = toml_file[
"compiler_path"].as_string();
57 if (!compiler_path_ptr)
return false;
59 std::string compiler = compiler_path_ptr->get();
60 std::string command = compiler +
" ";
62 auto* header_search_path_ptr = toml_file[
"compiler_headers_path"].as_array();
64 if (!header_search_path_ptr)
return false;
66 auto header_search_path = header_search_path_ptr;
68 if (header_search_path) {
69 for (
auto& headers : *header_search_path) {
70 command +=
"-I" + headers.as_string()->get() +
" ";
74 auto headers_path = toml_file[
"headers_path"].as_array();
77 for (
auto& headers : *headers_path) {
78 command +=
"-I" + headers.as_string()->get() +
" ";
82 auto sources_files = toml_file[
"sources_path"].as_array();
85 for (
auto& sources : *sources_files) {
86 command += sources.as_string()->get() +
" ";
90 auto macros_list = toml_file[
"cpp_macros"].as_array();
93 for (
auto& macro : *macros_list) {
94 command +=
"-D" + macro.as_string()->get() +
" ";
98 auto compiler_flags = toml_file[
"compiler_flags"].as_array();
100 if (compiler_flags) {
101 for (
auto& flag : *compiler_flags) {
102 command += flag.as_string()->get() +
" ";
106 if (!toml_file[
"compiler_std"].
is_string())
return false;
108 command +=
"-std=" + toml_file[
"compiler_std"].as_string()->get() +
" ";
110 if (toml_file[
"output_name"].as_string() ==
nullptr)
return false;
112 command +=
"-o " + toml_file[
"output_name"].as_string()->get();
114 auto target = toml_file[
"output_name"].as_string()->get();
118 auto ret_exec = std::system(command.c_str());
123 config.has_failed_ =
true;
128 config.has_failed_ =
true;
138const std::string_view TOMLManifestBuilder::BuildSystem() {
139 return "NeBuild (toml++::toml)";
TOML manifest builder header file.
constexpr bool is_string
Metafunction for determining if a type is, or is a reference to, a std::string or toml::value<std::st...
std::ostream & info() noexcept
replacement for std::cout for NeBuild logging.