aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/bin/guess.cxx18
-rw-r--r--libbuild2/bin/guess.hxx5
-rw-r--r--libbuild2/bin/init.cxx37
3 files changed, 52 insertions, 8 deletions
diff --git a/libbuild2/bin/guess.cxx b/libbuild2/bin/guess.cxx
index 3329cc5..63f5db5 100644
--- a/libbuild2/bin/guess.cxx
+++ b/libbuild2/bin/guess.cxx
@@ -16,12 +16,16 @@ namespace build2
string id;
string signature;
string checksum;
- semantic_version version;
+ optional<semantic_version> version;
guess_result () = default;
+
guess_result (string&& i, string&& s, semantic_version&& v)
: id (move (i)), signature (move (s)), version (move (v)) {}
+ guess_result (string&& i, string&& s, optional<semantic_version>&& v)
+ : id (move (i)), signature (move (s)), version (move (v)) {}
+
bool
empty () const {return id.empty ();}
};
@@ -288,7 +292,7 @@ namespace build2
move (arr.id),
move (arr.signature),
move (arr.checksum),
- move (arr.version),
+ move (*arr.version),
move (rlp),
move (rlr.id),
@@ -325,7 +329,7 @@ namespace build2
auto f = [&ld] (string& l, bool) -> guess_result
{
string id;
- semantic_version ver;
+ optional<semantic_version> ver;
// Microsoft link.exe output starts with "Microsoft (R) ".
//
@@ -337,6 +341,8 @@ namespace build2
//
else if (l.compare (0, 4, "LLD ") == 0)
{
+ ver = parse_version (l, 4);
+
// The only way to distinguish between various LLD drivers is via
// their name. Handle potential prefixes (say a target) and
// suffixes (say a version).
@@ -446,7 +452,11 @@ namespace build2
fail << "unable to guess " << ld << " signature";
return ld_info {
- move (pp), move (r.id), move (r.signature), move (r.checksum)};
+ move (pp),
+ move (r.id),
+ move (r.signature),
+ move (r.checksum),
+ move (r.version)};
}
rc_info
diff --git a/libbuild2/bin/guess.hxx b/libbuild2/bin/guess.hxx
index 255932b..27bb5ed 100644
--- a/libbuild2/bin/guess.hxx
+++ b/libbuild2/bin/guess.hxx
@@ -72,12 +72,17 @@ namespace build2
// toolchain-specific manner (usually the output of --version/-version/-v)
// and is not bulletproof.
//
+ // Note that for now the version is extracted only for some linkers. Once
+ // it's done for all of them, we should drop optional.
+ //
struct ld_info
{
process_path path;
string id;
string signature;
string checksum;
+
+ optional<semantic_version> version;
};
ld_info
diff --git a/libbuild2/bin/init.cxx b/libbuild2/bin/init.cxx
index 4565eb8..f6faab5 100644
--- a/libbuild2/bin/init.cxx
+++ b/libbuild2/bin/init.cxx
@@ -781,17 +781,46 @@ namespace build2
//
if (verb >= (p.second ? 2 : 3))
{
- text << "bin.ld " << project (rs) << '@' << rs << '\n'
+ diag_record dr (text);
+
+ {
+ dr << "bin.ld " << project (rs) << '@' << rs << '\n'
<< " ld " << ldi.path << '\n'
- << " id " << ldi.id << '\n'
- << " signature " << ldi.signature << '\n'
- << " checksum " << ldi.checksum;
+ << " id " << ldi.id << '\n';
+ }
+
+ if (ldi.version)
+ {
+ dr << " version " << ldi.version->string () << '\n'
+ << " major " << ldi.version->major << '\n'
+ << " minor " << ldi.version->minor << '\n'
+ << " patch " << ldi.version->patch << '\n';
+ }
+
+ if (ldi.version && !ldi.version->build.empty ())
+ {
+ dr << " build " << ldi.version->build << '\n';
+ }
+
+ dr << " signature " << ldi.signature << '\n'
+ << " checksum " << ldi.checksum;
}
rs.assign<process_path> ("bin.ld.path") = move (ldi.path);
rs.assign<string> ("bin.ld.id") = move (ldi.id);
rs.assign<string> ("bin.ld.signature") = move (ldi.signature);
rs.assign<string> ("bin.ld.checksum") = move (ldi.checksum);
+
+ if (ldi.version)
+ {
+ semantic_version& v (*ldi.version);
+
+ rs.assign<string> ("bin.ld.version") = v.string ();
+ rs.assign<uint64_t> ("bin.ld.version.major") = v.major;
+ rs.assign<uint64_t> ("bin.ld.version.minor") = v.minor;
+ rs.assign<uint64_t> ("bin.ld.version.patch") = v.patch;
+ rs.assign<string> ("bin.ld.version.build") = move (v.build);
+ }
}
return true;