From 623def43b2ae0cd23ecef6688257c540e3118856 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 1 May 2024 18:07:05 +0200 Subject: Added dependencies calculation (WIP) --- xmake.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/xmake.cpp b/xmake.cpp index e5f85ac..e4cadfb 100644 --- a/xmake.cpp +++ b/xmake.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -70,7 +71,7 @@ namespace { void build(const pt::ptree& ptree) { fs::path target{get_target(ptree)}; - + std::vector objects{get_objects(ptree)}; std::vector sources{get_sources(ptree)}; std::cout << "Target: " << target << std::endl; @@ -80,6 +81,16 @@ namespace { std::cout << " " << i << std::endl; } + std::unordered_map> dependencies; + dependencies.emplace(target, objects); + for (const auto& p: sources) { + fs::path p_obj{p}; + p_obj.replace_extension("o"); + dependencies.emplace(p_obj, std::vector{p}); + // TODO: add headers dependencies: + // g++ -MM -MF -c + } + std::vector commands; // compile for (auto &p: sources) { @@ -90,9 +101,8 @@ namespace { } } // link - std::vector objects{get_objects(ptree)}; - std::vector dependencies{sources}; - if (is_outdated(target, dependencies)) { + std::vector deps{sources}; + if (is_outdated(target, deps)) { std::string link_command{"g++"}; for (auto &i: objects) { link_command += fmt::format(" {}", i.string()); @@ -174,7 +184,6 @@ int xmake(int argc, char* argv[]) exit(1); } - } catch (const std::exception& ex) { std::cerr << "xmake: " << ex.what() << std::endl; return 1; -- cgit v1.2.3