simplify rule_add
parent
0987bfff92
commit
463712674c
21
main.cc
21
main.cc
|
@ -33,17 +33,9 @@ static void rule_add(
|
||||||
string_range target, string_range depends,
|
string_range target, string_range depends,
|
||||||
cs_bcode *body, bool action = false
|
cs_bcode *body, bool action = false
|
||||||
) {
|
) {
|
||||||
list_parser p{cs, target};
|
build::make_rule::body_func bodyf{};
|
||||||
for (auto tr: p.iter()) {
|
if (!cscript::cs_code_is_empty(body)) {
|
||||||
auto &rl = mk.rule(tr).action(action);
|
bodyf = [body = cs_bcode_ref(body), &cs](auto tgt, auto srcs) {
|
||||||
list_parser lp{cs, depends};
|
|
||||||
for (auto dp: lp.iter()) {
|
|
||||||
rl.depend(dp);
|
|
||||||
}
|
|
||||||
if (cscript::cs_code_is_empty(body)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
rl.body([body = cs_bcode_ref(body), &cs](auto tgt, auto srcs) {
|
|
||||||
cs_stacked_value targetv, sourcev, sourcesv;
|
cs_stacked_value targetv, sourcev, sourcesv;
|
||||||
|
|
||||||
if (!targetv.set_alias(cs.new_ident("target"))) {
|
if (!targetv.set_alias(cs.new_ident("target"))) {
|
||||||
|
@ -80,7 +72,12 @@ static void rule_add(
|
||||||
} catch (cscript::cs_error const &e) {
|
} catch (cscript::cs_error const &e) {
|
||||||
throw build::make_error{e.what()};
|
throw build::make_error{e.what()};
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
}
|
||||||
|
list_parser p{cs, target};
|
||||||
|
for (auto tr: p.iter()) {
|
||||||
|
list_parser lp{cs, depends};
|
||||||
|
mk.rule(tr).action(action).body(bodyf).depend(lp.iter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue