aboutsummaryrefslogtreecommitdiff
path: root/build2/b.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-16 13:07:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-16 13:07:31 +0200
commit50e725ae23124a10d56a615fb8b0ae80d0d2b4d3 (patch)
treeab916fa1916d7e435a3bf4e25ef205ce4eccbd08 /build2/b.cxx
parentaf73b1603d851dcb2ce7ae84bd57df0c2f9a716d (diff)
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.
Diffstat (limited to 'build2/b.cxx')
-rw-r--r--build2/b.cxx55
1 files changed, 42 insertions, 13 deletions
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<bool> (true) :
- ops.no_progress () ? optional<bool> (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<bool> (true) :
+ ops.no_progress () ? optional<bool> (false) : nullopt),
+ ops.no_line (),
+ ops.no_column (),
+ fdterm (stderr_fd ()));
+
// Handle --help.
//
if (ops.help ())