aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-03-07 09:06:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-03-07 09:06:37 +0200
commit1845141809aa91b03718066a6f46863885a6a887 (patch)
treea3f542ec7c1781e65aa16a9b0d5c31eae4c4d757 /build2/config
parente0002617846755fb5f199f40a677e16d6f69e5ec (diff)
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).
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/init.cxx2
-rw-r--r--build2/config/operation.cxx41
-rw-r--r--build2/config/utility.cxx10
-rw-r--r--build2/config/utility.hxx9
4 files changed, 39 insertions, 23 deletions
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<uint64_t> ("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 <build2/types.hxx>
#include <build2/utility.hxx>
+#include <build2/scope.hxx>
#include <build2/variable.hxx>
#include <build2/diagnostics.hxx>
@@ -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);
+ }
}
}