From 08e8dc3f19929b3ab6ed1df375c3ea11f9a785ae Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 2 May 2018 21:00:37 +0200 Subject: [PATCH] pass real target to dependency callbacks --- ostd/build/make.hh | 10 ++++++---- src/build_make.cc | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ostd/build/make.hh b/ostd/build/make.hh index bf6fc8e..b06e7ac 100644 --- a/ostd/build/make.hh +++ b/ostd/build/make.hh @@ -76,7 +76,7 @@ struct make_rule { void(string_range, iterator_range) >; using depend_func = std::function< - void(decltype(appender>()) &) + void(string_range, decltype(appender>()) &) >; make_rule() = delete; @@ -133,11 +133,13 @@ struct make_rule { return p_cond(target); } - void depends(std::function body) const { + void depends( + string_range tgt, std::function body + ) const { auto app = appender>(); for (auto &f: p_deps) { app.clear(); - f(app); + f(tgt, app); for (auto &s: app.get()) { body(s); } @@ -167,7 +169,7 @@ private: template void add_depend(R &&v) { if constexpr (std::is_constructible_v) { - p_deps.push_back([s = std::string{v}](auto &app) { + p_deps.push_back([s = std::string{v}](auto, auto &app) { app.put(std::move(s)); }); } else if constexpr(std::is_constructible_v) { diff --git a/src/build_make.cc b/src/build_make.cc index c9c2aed..258b2a5 100644 --- a/src/build_make.cc +++ b/src/build_make.cc @@ -185,7 +185,7 @@ void make::find_rules(string_range target, std::vector &rlist) { rlist.emplace_back(); rule_inst &sr = rlist.back(); sr.rule = &rule; - rule.depends([&sr, &tgt](string_range d) { + rule.depends(target, [&sr, &tgt](string_range d) { sr.deps.push_back(tgt.replace(d)); }); if (!rule.has_body()) {