Improve error message if gcc or other tools can not be found.

This fixes #192.
This commit is contained in:
kai
2012-10-14 12:39:35 +02:00
parent 95121115d3
commit 8519f448f8
2 changed files with 12 additions and 15 deletions

View File

@@ -30,24 +30,21 @@ static cl::opt<std::string> mslib("ms-lib",
sys::Path getProgram(const char *name, const cl::opt<std::string> &opt, const char *envVar = 0)
{
sys::Path path;
const char *prog = NULL;
if (opt.getNumOccurrences() > 0 && opt.length() > 0)
prog = gcc.c_str();
if (opt.getNumOccurrences() > 0 && opt.length() > 0 && (prog = opt.c_str()))
path = sys::Program::FindProgramByName(prog);
if (!prog && envVar)
prog = getenv(envVar);
if (!prog)
prog = name;
if (path.empty() && envVar && (prog = getenv(envVar)))
path = sys::Program::FindProgramByName(prog);
sys::Path path = sys::Program::FindProgramByName(prog);
if (path.empty() && !prog) {
if (prog) {
path.set(prog);
} else {
error("failed to locate %s", name);
fatal();
}
if (path.empty())
path = sys::Program::FindProgramByName(name);
if (path.empty()) {
error("failed to locate %s", name);
fatal();
}
return path;