From 722cf9d345e38b6f5ff4ed538d1f68bc75b2ab51 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 10 Jul 2015 15:29:42 +0200 Subject: Implement automatic subproject discovery Currently we only capture their directories without the project names. We will need project names when we hook import search into this. --- build/config/operation.cxx | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'build/config') diff --git a/build/config/operation.cxx b/build/config/operation.cxx index 300dd22..ea338f5 100644 --- a/build/config/operation.cxx +++ b/build/config/operation.cxx @@ -21,11 +21,7 @@ namespace build { namespace config { - static const dir_path build_dir ("build"); - static const dir_path bootstrap_dir ("build/bootstrap"); - static const path config_file ("build/config.build"); - static const path src_root_file ("build/bootstrap/src-root.build"); // configure // @@ -149,7 +145,7 @@ namespace build // if (out_root != src_root) { - mkdir (out_root); + mkdir_p (out_root); mkdir (out_root / build_dir); mkdir (out_root / bootstrap_dir); } @@ -278,7 +274,7 @@ namespace build // dir_path out_nroot (out_root / n.dir); - // The same logic to src_root as in create_bootstrap_inner(). + // The same logic for src_root as in create_bootstrap_inner(). // scope& nroot (create_root (out_nroot, dir_path ())); bootstrap_out (nroot); @@ -295,6 +291,25 @@ namespace build bootstrap_src (nroot); m = disfigure_project (a, nroot) || m; + + // We use mkdir_p() to create the out_root of a subproject + // which means there could be empty parent directories left + // behind. Clean them up. + // + if (!n.dir.simple () && out_root != src_root) + { + for (dir_path d (n.dir.directory ()); + !d.empty (); + d = d.directory ()) + { + rmdir_status s (rmdir (out_root / d)); + + if (s == rmdir_status::not_empty) + break; // No use trying do remove parent ones. + + m = (s == rmdir_status::success) || m; + } + } } } -- cgit v1.1