aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/b.cxx62
-rw-r--r--libbuild2/context.cxx1
-rw-r--r--libbuild2/context.hxx9
-rw-r--r--libbuild2/install/operation.cxx2
-rw-r--r--libbuild2/operation.cxx10
-rw-r--r--libbuild2/operation.hxx11
-rw-r--r--libbuild2/test/operation.cxx2
7 files changed, 51 insertions, 46 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 3f6dadf..51b024e 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -790,11 +790,11 @@ main (int argc, char* argv[])
if (!mname.empty ())
{
- if (meta_operation_id m = meta_operation_table.find (mname))
+ if (meta_operation_id m = ctx->meta_operation_table.find (mname))
{
// Can modify params, opspec, change meta-operation name.
//
- if (auto f = meta_operation_table[m].process)
+ if (auto f = ctx->meta_operation_table[m].process)
mname = ctx->current_mname = f (
*ctx, mparams, opspecs, lifted != nullptr, l);
}
@@ -835,9 +835,11 @@ main (int argc, char* argv[])
// Return true if this operation is lifted.
//
- auto lift = [&oname, &mname, &os, &mit, &lifted, &skip, &l, &trace] ()
+ auto lift = [&ctx,
+ &oname, &mname,
+ &os, &mit, &lifted, &skip, &l, &trace] ()
{
- meta_operation_id m (meta_operation_table.find (oname));
+ meta_operation_id m (ctx->meta_operation_table.find (oname));
if (m != 0)
{
@@ -1165,8 +1167,8 @@ main (int argc, char* argv[])
// all be known. We store the combined action id in uint8_t;
// see <operation> for details.
//
- assert (operation_table.size () <= 128);
- assert (meta_operation_table.size () <= 128);
+ assert (ctx->operation_table.size () <= 128);
+ assert (ctx->meta_operation_table.size () <= 128);
// Since we now know all the names of meta-operations and
// operations, "lift" names that we assumed (from buildspec syntax)
@@ -1183,7 +1185,7 @@ main (int argc, char* argv[])
if (!mname.empty ())
{
- m = meta_operation_table.find (mname);
+ m = ctx->meta_operation_table.find (mname);
if (m == 0)
fail (l) << "unknown meta-operation " << mname;
@@ -1191,7 +1193,7 @@ main (int argc, char* argv[])
if (!oname.empty ())
{
- o = operation_table.find (oname);
+ o = ctx->operation_table.find (oname);
if (o == 0)
fail (l) << "unknown operation " << oname;
@@ -1214,7 +1216,7 @@ main (int argc, char* argv[])
if (mif == nullptr)
fail (l) << "target " << tn << " does not support meta-"
- << "operation " << meta_operation_table[m].name;
+ << "operation " << ctx->meta_operation_table[m].name;
}
//
// Otherwise, check that all the targets in a meta-operation
@@ -1227,7 +1229,7 @@ main (int argc, char* argv[])
if (mi == nullptr)
fail (l) << "target " << tn << " does not support meta-"
- << "operation " << meta_operation_table[mid].name;
+ << "operation " << ctx->meta_operation_table[mid].name;
if (mi != mif)
fail (l) << "different implementations of meta-operation "
@@ -1264,16 +1266,16 @@ main (int argc, char* argv[])
//
if (oid == 0)
{
- auto lookup =
- [&rs, &l, &tn] (operation_id o) -> const operation_info*
- {
- const operation_info* r (rs.root_extra->operations[o]);
+ auto lookup = [&ctx, &rs, &l, &tn] (operation_id o) ->
+ const operation_info*
+ {
+ const operation_info* r (rs.root_extra->operations[o]);
- if (r == nullptr)
- fail (l) << "target " << tn << " does not support "
- << "operation " << operation_table[o];
- return r;
- };
+ if (r == nullptr)
+ fail (l) << "target " << tn << " does not support "
+ << "operation " << ctx->operation_table[o];
+ return r;
+ };
if (o == 0)
o = default_id;
@@ -1341,19 +1343,19 @@ main (int argc, char* argv[])
//
else
{
- auto check =
- [&rs, &l, &tn] (operation_id o, const operation_info* i)
- {
- const operation_info* r (rs.root_extra->operations[o]);
+ auto check = [&ctx, &rs, &l, &tn] (operation_id o,
+ const operation_info* i)
+ {
+ const operation_info* r (rs.root_extra->operations[o]);
- if (r == nullptr)
- fail (l) << "target " << tn << " does not support "
- << "operation " << operation_table[o];
+ if (r == nullptr)
+ fail (l) << "target " << tn << " does not support "
+ << "operation " << ctx->operation_table[o];
- if (r != i)
- fail (l) << "different implementations of operation "
- << i->name << " in the same operation batch";
- };
+ if (r != i)
+ fail (l) << "different implementations of operation "
+ << i->name << " in the same operation batch";
+ };
check (orig_oid, oif);
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx
index f4d8a39..23cef44 100644
--- a/libbuild2/context.cxx
+++ b/libbuild2/context.cxx
@@ -11,7 +11,6 @@
#include <libbuild2/scope.hxx>
#include <libbuild2/target.hxx>
#include <libbuild2/variable.hxx>
-#include <libbuild2/operation.hxx>
#include <libbuild2/diagnostics.hxx>
#include <libbutl/ft/exception.hxx> // uncaught_exceptions
diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx
index 31930a1..1d20acb 100644
--- a/libbuild2/context.hxx
+++ b/libbuild2/context.hxx
@@ -13,6 +13,7 @@
// likely a non-starter.
//
#include <libbuild2/action.hxx>
+#include <libbuild2/operation.hxx>
#include <libbuild2/scheduler.hxx>
#include <libbuild2/export.hxx>
@@ -32,9 +33,6 @@ namespace build2
class value;
using values = small_vector<value, 1>;
- struct meta_operation_info;
- struct operation_info;
-
struct opspec;
class LIBBUILD2_SYMEXPORT run_phase_mutex
@@ -363,6 +361,11 @@ namespace build2
//
const variable* var_build_meta_operation;
+ // Known meta-operation and operation tables.
+ //
+ build2::meta_operation_table meta_operation_table;
+ build2::operation_table operation_table;
+
// The old/new src_root remapping for subprojects.
//
dir_path old_src_root;
diff --git a/libbuild2/install/operation.cxx b/libbuild2/install/operation.cxx
index 1135ad6..a2ad7d0 100644
--- a/libbuild2/install/operation.cxx
+++ b/libbuild2/install/operation.cxx
@@ -4,6 +4,8 @@
#include <libbuild2/install/operation.hxx>
+#include <libbuild2/variable.hxx>
+
using namespace std;
using namespace butl;
diff --git a/libbuild2/operation.cxx b/libbuild2/operation.cxx
index c07d359..0bf87d5 100644
--- a/libbuild2/operation.cxx
+++ b/libbuild2/operation.cxx
@@ -10,6 +10,7 @@
#include <libbuild2/scope.hxx>
#include <libbuild2/target.hxx>
#include <libbuild2/context.hxx>
+#include <libbuild2/variable.hxx>
#include <libbuild2/algorithm.hxx>
#include <libbuild2/diagnostics.hxx>
@@ -546,8 +547,8 @@ namespace build2
<< "out_root: " << cast<dir_path> (rs[ctx.var_out_root]) << endl
<< "amalgamation: " << cast_empty<dir_path> (rs[ctx.var_amalgamation]) << endl
<< "subprojects: " << cast_empty<subprojects> (rs[ctx.var_subprojects]) << endl
- << "operations:"; print_ops (rs.root_extra->operations, operation_table); cout << endl
- << "meta-operations:"; print_ops (rs.root_extra->meta_operations, meta_operation_table); cout << endl;
+ << "operations:"; print_ops (rs.root_extra->operations, ctx.operation_table); cout << endl
+ << "meta-operations:"; print_ops (rs.root_extra->meta_operations, ctx.meta_operation_table); cout << endl;
}
}
@@ -623,9 +624,4 @@ namespace build2
nullptr,
nullptr
};
-
- // Tables.
- //
- string_table<meta_operation_id, meta_operation_data> meta_operation_table;
- string_table<operation_id> operation_table;
}
diff --git a/libbuild2/operation.hxx b/libbuild2/operation.hxx
index 0d56219..520b37b 100644
--- a/libbuild2/operation.hxx
+++ b/libbuild2/operation.hxx
@@ -11,7 +11,6 @@
#include <libbuild2/utility.hxx>
#include <libbuild2/action.hxx>
-#include <libbuild2/variable.hxx>
#include <libbuild2/target-state.hxx>
#include <libbuild2/export.hxx>
@@ -26,6 +25,9 @@ namespace build2
class include_type;
struct prerequisite_member;
+ class value;
+ using values = small_vector<value, 1>;
+
struct opspec;
// Meta-operation info.
@@ -296,11 +298,10 @@ namespace build2
return os << d.name;
}
- LIBBUILD2_SYMEXPORT extern butl::string_table<meta_operation_id,
- meta_operation_data>
- meta_operation_table;
+ using meta_operation_table = butl::string_table<meta_operation_id,
+ meta_operation_data>;
- LIBBUILD2_SYMEXPORT extern butl::string_table<operation_id> operation_table;
+ using operation_table = butl::string_table<operation_id>;
// These are "sparse" in the sense that we may have "holes" that
// are represented as NULL pointers. Also, lookup out of bounds
diff --git a/libbuild2/test/operation.cxx b/libbuild2/test/operation.cxx
index 3ff7702..0ca8da0 100644
--- a/libbuild2/test/operation.cxx
+++ b/libbuild2/test/operation.cxx
@@ -4,6 +4,8 @@
#include <libbuild2/test/operation.hxx>
+#include <libbuild2/variable.hxx>
+
using namespace std;
using namespace butl;