mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 04:15:58 +03:00
Fixed #21 — Added -lib switch
This commit is contained in:
parent
859ae8481f
commit
fdead0d154
8 changed files with 137 additions and 18 deletions
|
@ -13,27 +13,42 @@ static cl::opt<std::string> gcc("gcc",
|
|||
cl::Hidden,
|
||||
cl::ZeroOrMore);
|
||||
|
||||
static cl::opt<std::string> ar("ar",
|
||||
cl::desc("Archiver"),
|
||||
cl::Hidden,
|
||||
cl::ZeroOrMore);
|
||||
|
||||
sys::Path getGcc() {
|
||||
const char *cc = NULL;
|
||||
|
||||
if (gcc.getNumOccurrences() > 0 && gcc.length() > 0)
|
||||
cc = gcc.c_str();
|
||||
|
||||
if (!cc)
|
||||
cc = getenv("CC");
|
||||
if (!cc)
|
||||
cc = "gcc";
|
||||
|
||||
sys::Path path = sys::Program::FindProgramByName(cc);
|
||||
if (path.empty() && !cc) {
|
||||
if (cc) {
|
||||
path.set(cc);
|
||||
sys::Path getProgram(const char *name, const cl::opt<std::string> &opt, const char *envVar = 0)
|
||||
{
|
||||
const char *prog = NULL;
|
||||
|
||||
if (opt.getNumOccurrences() > 0 && opt.length() > 0)
|
||||
prog = gcc.c_str();
|
||||
|
||||
if (!prog && envVar)
|
||||
prog = getenv(envVar);
|
||||
if (!prog)
|
||||
prog = name;
|
||||
|
||||
sys::Path path = sys::Program::FindProgramByName(prog);
|
||||
if (path.empty() && !prog) {
|
||||
if (prog) {
|
||||
path.set(prog);
|
||||
} else {
|
||||
error("failed to locate gcc");
|
||||
error("failed to locate %s", name);
|
||||
fatal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
sys::Path getGcc()
|
||||
{
|
||||
return getProgram("gcc", gcc, "CC");
|
||||
}
|
||||
|
||||
sys::Path getArchiver()
|
||||
{
|
||||
return getProgram("ar", ar);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue