From 13b07e3d9d3c1f3e687a719675aabb6b68e3c822 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Jan 2019 09:16:33 +0200 Subject: Print list of available operations and meta-operations in info --- build2/operation.cxx | 36 +++++++++++++++++++++++++++--------- build2/operation.hxx | 6 ++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/build2/operation.cxx b/build2/operation.cxx index 0fd0a95..1cbf104 100644 --- a/build2/operation.cxx +++ b/build2/operation.cxx @@ -495,19 +495,37 @@ namespace build2 if (i != 0) cout << endl; - const scope& s (*static_cast (ts[i].target)); + const scope& rs (*static_cast (ts[i].target)); + + // Print [meta_]operation names. Due to the way our aliasing works, we + // have to go through the [meta_]operation_table. + // + auto print_ops = [] (const auto& ov, const auto& ot) + { + // This is a sparse vector with NULL holes. id 0 is invalid while 1 is + // the noop meta-operation and the default operation; we omit printing + // both. + // + for (size_t id (2); id < ov.size (); ++id) + { + if (ov[id] != nullptr) + cout << ' ' << ot[id]; + } + }; // This could be a simple project that doesn't set project name. // cout - << "project: " << cast_empty (s[var_project]) << endl - << "version: " << cast_empty (s[var_version]) << endl - << "summary: " << cast_empty (s[var_project_summary]) << endl - << "url: " << cast_empty (s[var_project_url]) << endl - << "src_root: " << cast (s[var_src_root]) << endl - << "out_root: " << cast (s[var_out_root]) << endl - << "amalgamation: " << cast_empty (s[var_amalgamation]) << endl - << "subprojects: " << cast_empty (s[var_subprojects]) << endl; + << "project: " << cast_empty (rs[var_project]) << endl + << "version: " << cast_empty (rs[var_version]) << endl + << "summary: " << cast_empty (rs[var_project_summary]) << endl + << "url: " << cast_empty (rs[var_project_url]) << endl + << "src_root: " << cast (rs[var_src_root]) << endl + << "out_root: " << cast (rs[var_out_root]) << endl + << "amalgamation: " << cast_empty (rs[var_amalgamation]) << endl + << "subprojects: " << cast_empty (rs[var_subprojects]) << endl + << "operations:"; print_ops (rs.operations, operation_table); cout << endl + << "meta-operations:"; print_ops (rs.meta_operations, meta_operation_table); cout << endl; } } diff --git a/build2/operation.hxx b/build2/operation.hxx index f79228b..d2c3486 100644 --- a/build2/operation.hxx +++ b/build2/operation.hxx @@ -287,6 +287,12 @@ namespace build2 process_func* process; }; + inline ostream& + operator<< (ostream& os, const meta_operation_data& d) + { + return os << d.name; + } + extern butl::string_table meta_operation_table; extern butl::string_table operation_table; -- cgit v1.1