diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-05-13 08:24:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-05-27 08:35:29 +0200 |
commit | 44d3acdb065205f5fd69834a75b472721bea5443 (patch) | |
tree | 026c95b68088120b403140ab5f143c9ea114f90c /libbuild2/rule.cxx | |
parent | 741cce26c1caeacc0e578a8bef1efefa993adcc1 (diff) |
Support for cleaning up recipe builds
Diffstat (limited to 'libbuild2/rule.cxx')
-rw-r--r-- | libbuild2/rule.cxx | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx index 98b4458..7286c63 100644 --- a/libbuild2/rule.cxx +++ b/libbuild2/rule.cxx @@ -305,6 +305,8 @@ namespace build2 // adhoc_rule // + const dir_path adhoc_rule::recipes_build_dir ("recipes.out"); + bool adhoc_rule:: match (action a, target& t, const string& h, optional<action> fallback) const { @@ -317,6 +319,35 @@ namespace build2 return true; } + // Scope operation callback that cleans up recipe builds. + // + target_state adhoc_rule:: + clean_recipes_build (action, const scope& rs, const dir&) + { + context& ctx (rs.ctx); + + const dir_path& out_root (rs.out_path ()); + + dir_path d (out_root / rs.root_extra->build_dir / recipes_build_dir); + + if (exists (d)) + { + if (rmdir_r (ctx, d)) + { + // Clean up build/ if it also became empty (e.g., in case of a build + // with a transient configuration). + // + d = out_root / rs.root_extra->build_dir; + if (empty (d)) + rmdir (ctx, d); + + return target_state::changed; + } + } + + return target_state::unchanged; + } + // adhoc_script_rule // void adhoc_script_rule:: @@ -572,8 +603,6 @@ namespace build2 << ind << string (braces, '}'); } - static const dir_path recipes_build_dir ("recipes.out"); - // From module.cxx. // void |