12namespace FS = std::filesystem;
20bool JSONManifestBuilder::BuildTarget(BuildConfig& config) {
23 if (config.path_.empty()) {
29 if (!FS::exists(
path)) {
44 nlohmann::json json_obj = nlohmann::json::parse(
json);
47 nlohmann::json description = json_obj[
"description"];
51 if (
auto res = description.get<std::string>(); !
res.empty())
56 std::string compiler = json_obj[
"compiler_path"].get<std::string>();
58 std::string command = compiler +
" ";
60 nlohmann::json header_search_path = json_obj[
"compiler_headers_path"];
62 for (
auto& headers : header_search_path) {
63 command +=
"-I" + headers.get<std::string>() +
" ";
66 nlohmann::json headers_path = json_obj[
"headers_path"];
68 for (
auto& headers : headers_path) {
69 command +=
"-I" + headers.get<std::string>() +
" ";
72 nlohmann::json sources_files = json_obj[
"sources_path"];
74 for (
auto& sources : sources_files) {
75 command += sources.get<std::string>() +
" ";
78 nlohmann::json macros_list = json_obj[
"cpp_macros"];
80 for (
auto& macro : macros_list) {
81 command +=
"-D" + macro.get<std::string>() +
" ";
84 nlohmann::json compiler_flags = json_obj[
"compiler_flags"];
86 for (
auto& flag : compiler_flags) {
87 command += flag.get<std::string>() +
" ";
91 command +=
"-std=" + json_obj[
"compiler_std"].get<std::string>() +
" ";
93 command +=
"-o " + json_obj[
"output_name"].get<std::string>();
95 auto target = json_obj[
"output_name"].get<std::string>();
99 auto ret_exec = std::system(command.c_str());
104 config.has_failed_ =
true;
109 config.has_failed_ =
true;
120const std::string_view JSONManifestBuilder::BuildSystem() {
121 return "NeBuild (nlohmann::json)";
JSON manifest builder header file.
namespace for Niels Lohmann
constexpr bool is_string
Metafunction for determining if a type is, or is a reference to, a std::string or toml::value<std::st...
basic_json<> json
default specialization
std::ostream & info() noexcept
replacement for std::cout for NeBuild logging.