aboutsummaryrefslogtreecommitdiff
path: root/build2/bin/guess.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-11 07:23:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-11 07:23:37 +0200
commit0760742386e8e6034bbd619487ef156bc574e408 (patch)
tree8b4df6a356e5424f89a94464809349bbde667189 /build2/bin/guess.cxx
parentfac576a331d6587e4343d09d6caf959d9a776118 (diff)
Add bin.rc module (resource compiler)
Diffstat (limited to 'build2/bin/guess.cxx')
-rw-r--r--build2/bin/guess.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/build2/bin/guess.cxx b/build2/bin/guess.cxx
index ea4ac49..8a91015 100644
--- a/build2/bin/guess.cxx
+++ b/build2/bin/guess.cxx
@@ -282,5 +282,62 @@ namespace build2
return ld_info {move (r.id), move (r.signature), move (r.checksum)};
}
+
+ rc_info
+ guess_rc (const path& rc)
+ {
+ tracer trace ("bin::guess_rc");
+
+ guess_result r;
+
+ // Binutils windres recognizes the --version option.
+ //
+ {
+ auto f = [] (string& l) -> guess_result
+ {
+ // Binutils windres --version output has a line that starts with
+ // "GNU windres ".
+ //
+ if (l.compare (0, 12, "GNU windres ") == 0)
+ return guess_result {"gnu", move (l), ""};
+
+ return guess_result ();
+ };
+
+ // Suppress all the errors because we may be trying an unsupported
+ // option.
+ //
+ sha256 cs;
+ r = run<guess_result> (rc, "--version", f, false, false, &cs);
+
+ if (!r.empty ())
+ r.checksum = cs.string ();
+ }
+
+ // Microsoft rc.exe /? prints its standard banner and exits with zero
+ // status.
+ //
+ if (r.empty ())
+ {
+ auto f = [] (string& l) -> guess_result
+ {
+ if (l.compare (0, 14, "Microsoft (R) ") == 0)
+ return guess_result {"msvc", move (l), ""};
+
+ return guess_result ();
+ };
+
+ sha256 cs;
+ r = run<guess_result> (rc, "/?", f, false, false, &cs);
+
+ if (!r.empty ())
+ r.checksum = cs.string ();
+ }
+
+ if (r.empty ())
+ fail << "unable to guess " << rc << " signature";
+
+ return rc_info {move (r.id), move (r.signature), move (r.checksum)};
+ }
}
}