From 1845141809aa91b03718066a6f46863885a6a887 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Mar 2019 09:06:37 +0200 Subject: Add support for alternative build file/directory naming scheme Now the build/*.build, buildfile, and .buildignore filesystem entries in a project can alternatively (but consistently) be called build2/*.build2, build2file, and .build2ignore. See a note at the beginning of the Project Structure section in the manual for details (motivation, restrictions, etc). --- build2/config/init.cxx | 2 +- build2/config/operation.cxx | 41 +++++++++++++++++++++++------------------ build2/config/utility.cxx | 10 ++++++---- build2/config/utility.hxx | 9 +++++++++ 4 files changed, 39 insertions(+), 23 deletions(-) (limited to 'build2/config') diff --git a/build2/config/init.cxx b/build2/config/init.cxx index 25c7022..9dc3a3c 100644 --- a/build2/config/init.cxx +++ b/build2/config/init.cxx @@ -88,7 +88,7 @@ namespace build2 const variable& c_v (vp.insert ("config.version", false)); { - path f (out_root / config_file); + path f (config_file (rs)); if (exists (f)) { diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx index 5acc42b..1064ebb 100644 --- a/build2/config/operation.cxx +++ b/build2/config/operation.cxx @@ -28,9 +28,12 @@ namespace build2 // configure // static void - save_src_root (const dir_path& out_root, const dir_path& src_root) + save_src_root (const scope& root) { - path f (out_root / src_root_file); + const dir_path& out_root (root.out_path ()); + const dir_path& src_root (root.src_path ()); + + path f (out_root / root.root_extra->src_root_file); if (verb >= 2) text << "cat >" << f; @@ -54,9 +57,12 @@ namespace build2 } static void - save_out_root (const dir_path& out_root, const dir_path& src_root) + save_out_root (const scope& root) { - path f (src_root / out_root_file); + const dir_path& out_root (root.out_path ()); + const dir_path& src_root (root.src_path ()); + + path f (src_root / root.root_extra->out_root_file); if (verb) text << (verb >= 2 ? "cat >" : "save ") << f; @@ -84,8 +90,7 @@ namespace build2 static void save_config (const scope& root, const project_set& projects) { - const dir_path& out_root (root.out_path ()); - path f (out_root / config_file); + path f (config_file (root)); if (verb) text << (verb >= 2 ? "cat >" : "save ") << f; @@ -319,8 +324,8 @@ namespace build2 // if (out_root != src_root) { - mkdir_p (out_root / build_dir); - mkdir (out_root / bootstrap_dir, 2); + mkdir_p (out_root / root.root_extra->build_dir); + mkdir (out_root / root.root_extra->bootstrap_dir, 2); } // We distinguish between a complete configure and operation- @@ -333,7 +338,7 @@ namespace build2 // Save src-root.build unless out_root is the same as src. // if (out_root != src_root) - save_src_root (out_root, src_root); + save_src_root (root); // Save config.build. // @@ -378,8 +383,8 @@ namespace build2 return; } - mkdir (src_root / bootstrap_dir, 2); // Make sure exists. - save_out_root (out_root, src_root); + mkdir (src_root / root.root_extra->bootstrap_dir, 2); // Make sure exists. + save_out_root (root); // Configure subprojects. Since we don't load buildfiles if configuring // a forward, we do it for all known subprojects. @@ -636,19 +641,19 @@ namespace build2 { l5 ([&]{trace << "completely disfiguring " << out_root;}); - r = rmfile (out_root / config_file) || r; + r = rmfile (config_file (root)) || r; if (out_root != src_root) { - r = rmfile (out_root / src_root_file, 2) || r; + r = rmfile (out_root / root.root_extra->src_root_file, 2) || r; // Clean up the directories. // // Note: try to remove the root/ hooks directory if it is empty. // - r = rmdir (out_root / root_dir, 2) || r; - r = rmdir (out_root / bootstrap_dir, 2) || r; - r = rmdir (out_root / build_dir, 2) || r; + r = rmdir (out_root / root.root_extra->root_dir, 2) || r; + r = rmdir (out_root / root.root_extra->bootstrap_dir, 2) || r; + r = rmdir (out_root / root.root_extra->build_dir, 2) || r; switch (rmdir (out_root)) { @@ -712,8 +717,8 @@ namespace build2 // Remove the out-root.build file and try to remove the bootstrap/ // directory if it is empty. // - r = rmfile (src_root / out_root_file) || r; - r = rmdir (src_root / bootstrap_dir, 2) || r; + r = rmfile (src_root / root.root_extra->out_root_file) || r; + r = rmdir (src_root / root.root_extra->bootstrap_dir, 2) || r; return r; } diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx index 2fee5f7..d2e8699 100644 --- a/build2/config/utility.cxx +++ b/build2/config/utility.cxx @@ -183,12 +183,14 @@ namespace build2 // Create the build/ subdirectory. // - mkdir (d / build_dir, verbosity); + // Note that for now we use the standard build file/directory scheme. + // + mkdir (d / std_build_dir, verbosity); // Write build/bootstrap.build. // { - path f (d / bootstrap_file); + path f (d / std_bootstrap_file); if (verb >= verbosity) text << (verb >= 2 ? "cat >" : "save ") << f; @@ -232,7 +234,7 @@ namespace build2 // Write build/root.build. // { - path f (d / root_file); + path f (d / std_root_file); if (verb >= verbosity) text << (verb >= 2 ? "cat >" : "save ") << f; @@ -281,7 +283,7 @@ namespace build2 // if (buildfile) { - path f (d / buildfile_file); + path f (d / std_buildfile_file); if (verb >= verbosity) text << (verb >= 2 ? "cat >" : "save ") << f; diff --git a/build2/config/utility.hxx b/build2/config/utility.hxx index 6f384f5..eff1a02 100644 --- a/build2/config/utility.hxx +++ b/build2/config/utility.hxx @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -160,6 +161,14 @@ namespace build2 bool buildfile, // Create root buildfile. const char* who, // Who is creating it. uint16_t verbosity = 1); // Diagnostic verbosity. + + inline path + config_file (const scope& root) + { + return (root.out_path () / + root.root_extra->build_dir / + "config." + root.root_extra->build_ext); + } } } -- cgit v1.1