aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/version
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-08-22 14:38:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-08-23 18:14:07 +0200
commit5035f4ef68922ac758b1e4734e67d73c9228010b (patch)
tree271fdd5b1d6e995a058d97aacb3ac90a538d9ff1 /libbuild2/version
parent8793941652d6aa1c3d02b2f87f691e6d06254b7d (diff)
Introduce notion of build context
All non-const global state is now in class context and we can now have multiple independent builds going on at the same time.
Diffstat (limited to 'libbuild2/version')
-rw-r--r--libbuild2/version/init.cxx19
-rw-r--r--libbuild2/version/rule.cxx3
-rw-r--r--libbuild2/version/utility.cxx9
-rw-r--r--libbuild2/version/utility.hxx6
4 files changed, 25 insertions, 12 deletions
diff --git a/libbuild2/version/init.cxx b/libbuild2/version/init.cxx
index a4e41d6..123dc65 100644
--- a/libbuild2/version/init.cxx
+++ b/libbuild2/version/init.cxx
@@ -37,6 +37,8 @@ namespace build2
tracer trace ("version::boot");
l5 ([&]{trace << "for " << rs;});
+ context& ctx (rs.ctx);
+
// Extract the version from the manifest file. As well as summary and
// url while at it.
//
@@ -67,7 +69,7 @@ namespace build2
{
if (nv.name == "name")
{
- auto& pn (cast<project_name> (rs.vars[var_project]));
+ auto& pn (cast<project_name> (rs.vars[ctx.var_project]));
if (nv.value != pn.string ())
{
@@ -219,7 +221,7 @@ namespace build2
// Set all the version.* variables.
//
- auto& vp (var_pool.rw (rs));
+ auto& vp (ctx.var_pool.rw (rs));
auto set = [&vp, &rs] (const char* var, auto val)
{
@@ -228,8 +230,8 @@ namespace build2
rs.assign (v) = move (val);
};
- if (!sum.empty ()) rs.assign (var_project_summary) = move (sum);
- if (!url.empty ()) rs.assign (var_project_url) = move (url);
+ if (!sum.empty ()) rs.assign (ctx.var_project_summary) = move (sum);
+ if (!url.empty ()) rs.assign (ctx.var_project_url) = move (url);
set ("version", v.string ()); // Project version (var_version).
@@ -268,7 +270,7 @@ namespace build2
// Create the module.
//
- mod.reset (new module (cast<project_name> (rs.vars[var_project]),
+ mod.reset (new module (cast<project_name> (rs.vars[ctx.var_project]),
move (v),
committed,
rewritten,
@@ -294,6 +296,8 @@ namespace build2
if (!first)
fail (l) << "multiple version module initializations";
+ context& ctx (rs.ctx);
+
// Load in.base (in.* variables, in{} target type).
//
if (!cast_false<bool> (rs["in.base.loaded"]))
@@ -320,7 +324,7 @@ namespace build2
if (!val)
{
- string p (cast<project_name> (rs.vars[var_project]).string ());
+ string p (cast<project_name> (rs.vars[ctx.var_project]).string ());
p += '-';
p += v.string ();
val = move (p);
@@ -370,7 +374,8 @@ namespace build2
//
try
{
- auto_rmfile t (fixup_manifest (f,
+ auto_rmfile t (fixup_manifest (rs.ctx,
+ f,
path::temp_path ("manifest"),
m.version));
diff --git a/libbuild2/version/rule.cxx b/libbuild2/version/rule.cxx
index 37e6b0f..fe999b3 100644
--- a/libbuild2/version/rule.cxx
+++ b/libbuild2/version/rule.cxx
@@ -328,7 +328,8 @@ namespace build2
// the out tree. Somehow the latter feels more appropriate (even though
// if we crash in between, we won't clean it up).
//
- return fixup_manifest (p, rs.out_path () / "manifest.t", m.version);
+ return fixup_manifest (
+ t.ctx, p, rs.out_path () / "manifest.t", m.version);
}
}
}
diff --git a/libbuild2/version/utility.cxx b/libbuild2/version/utility.cxx
index 70daab1..0669da7 100644
--- a/libbuild2/version/utility.cxx
+++ b/libbuild2/version/utility.cxx
@@ -17,11 +17,14 @@ namespace build2
namespace version
{
auto_rmfile
- fixup_manifest (const path& in, path out, const standard_version& v)
+ fixup_manifest (context& ctx,
+ const path& in,
+ path out,
+ const standard_version& v)
{
- auto_rmfile r (move (out), !dry_run /* active */);
+ auto_rmfile r (move (out), !ctx.dry_run /* active */);
- if (!dry_run)
+ if (!ctx.dry_run)
{
try
{
diff --git a/libbuild2/version/utility.hxx b/libbuild2/version/utility.hxx
index 16e8c78..170488d 100644
--- a/libbuild2/version/utility.hxx
+++ b/libbuild2/version/utility.hxx
@@ -8,6 +8,7 @@
#include <libbuild2/types.hxx>
#include <libbuild2/utility.hxx>
+#include <libbuild2/context.hxx>
#include <libbuild2/filesystem.hxx>
namespace build2
@@ -18,7 +19,10 @@ namespace build2
// not preserve comments. Probably acceptable for snapshots.
//
auto_rmfile
- fixup_manifest (const path& in, path out, const standard_version&);
+ fixup_manifest (context&,
+ const path& in,
+ path out,
+ const standard_version&);
}
}