From 50e725ae23124a10d56a615fb8b0ae80d0d2b4d3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 16 Jun 2020 13:07:31 +0200 Subject: Add metadata for exe{b}, including whether it is statically-linked Use this information to omit ad hoc C++ recipe tests is testing statically- linked build system. --- build2/b.cxx | 55 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'build2/b.cxx') diff --git a/build2/b.cxx b/build2/b.cxx index bae40b6..930dbac 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -426,32 +426,61 @@ main (int argc, char* argv[]) fail << e; } - // Initialize the diagnostics state. + // Handle --build2-metadata (see also buildfile). // - init_diag (verbosity (), - ops.silent (), - (ops.progress () ? optional (true) : - ops.no_progress () ? optional (false) : nullopt), - ops.no_line (), - ops.no_column (), - fdterm (stderr_fd ())); +#ifndef BUILD2_BOOTSTRAP + if (ops.build2_metadata_specified ()) + { + auto& o (cout); + + // Note that the export.metadata variable should be the first non- + // blank/comment line. + // + o << "# build2 buildfile b" << endl + << "export.metadata = 1 b" << endl + << "b.name = [string] b" << endl + << "b.version = [string] '" << LIBBUILD2_VERSION_FULL << '\'' << endl + << "b.checksum = [string] '" << LIBBUILD2_VERSION_FULL << '\'' << endl + << "b.static = [bool] " << +#ifdef LIBBUILD2_STATIC + "true" +#else + "false" +#endif + << endl; + + return 0; + } +#endif // Handle --version. // if (ops.version ()) { - cout << "build2 " << LIBBUILD2_VERSION_ID << endl - << "libbutl " << LIBBUTL_VERSION_ID << endl - << "host " << BUILD2_HOST_TRIPLET << endl; + auto& o (cout); + + o << "build2 " << LIBBUILD2_VERSION_ID << endl + << "libbutl " << LIBBUTL_VERSION_ID << endl + << "host " << BUILD2_HOST_TRIPLET << endl; #ifndef BUILD2_BOOTSTRAP - cout << "Copyright (c) " << BUILD2_COPYRIGHT << "." << endl; + o << "Copyright (c) " << BUILD2_COPYRIGHT << "." << endl; #endif - cout << "This is free software released under the MIT license." << endl; + o << "This is free software released under the MIT license." << endl; return 0; } + // Initialize the diagnostics state. + // + init_diag (verbosity (), + ops.silent (), + (ops.progress () ? optional (true) : + ops.no_progress () ? optional (false) : nullopt), + ops.no_line (), + ops.no_column (), + fdterm (stderr_fd ())); + // Handle --help. // if (ops.help ()) -- cgit v1.1