From ec955eb6726b31e26d17c34474619b60f3563194 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 15 Jun 2024 14:24:14 +0200 Subject: Automatically depend on YMakefile (rebuild if necessary), tests --- Builder.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Builder.cpp') diff --git a/Builder.cpp b/Builder.cpp index 69ecf48..d64ba27 100644 --- a/Builder.cpp +++ b/Builder.cpp @@ -326,6 +326,13 @@ std::unordered_map> Builder::get_dependencies(co } } + // add dependencies to YMakefiles + for (auto& i: dependencies) { + if (is_buildable_by_name(i.first) && fs::exists(i.first.parent_path() / YMakefile)) { + i.second.push_back(i.first.parent_path() / YMakefile); + } + } + return dependencies; } @@ -339,7 +346,9 @@ void Builder::build_file(const fs::path& p) { command = _lang.getCompileCommand(p, source_file, target_from_object(p), include_paths_of_object(p)); } else { // link - std::vector objects{dependencies_of(p)}; + std::vector deps{dependencies_of(p)}; + std::vector objects; + std::copy_if(deps.begin(), deps.end(), std::back_inserter(objects), is_linkable); std::vector link_libs{link_libs_of(p)}; command = _lang.getLinkCommand(p, objects, link_libs); } @@ -438,7 +447,7 @@ std::unordered_set Builder::get_buildlist(std::function add; for (const auto& i: cleanlist) { std::vector deps{dependencies_of(i)}; - std::copy(deps.begin(), deps.end(), std::inserter(add, add.begin())); + std::copy_if(deps.begin(), deps.end(), std::inserter(add, add.begin()), is_buildable_by_name); } std::copy(add.begin(), add.end(), std::inserter(cleanlist, cleanlist.begin())); -- cgit v1.2.3