|
Revision 1349:a376776e2301, 0.8 kB
(checked in by Christian Kamm <kamm incasoftware de>, 3 years ago)
|
Use getenv on Windows, closes #248.
|
| Line | |
|---|
| 1 |
#include "gen/programs.h" |
|---|
| 2 |
|
|---|
| 3 |
#include "llvm/Support/CommandLine.h" |
|---|
| 4 |
#include "llvm/System/Program.h" |
|---|
| 5 |
|
|---|
| 6 |
#include "root.h" // error(char*) |
|---|
| 7 |
#include "mars.h" // fatal() |
|---|
| 8 |
|
|---|
| 9 |
using namespace llvm; |
|---|
| 10 |
|
|---|
| 11 |
static cl::opt<std::string> gcc("gcc", |
|---|
| 12 |
cl::desc("GCC to use for assembling and linking"), |
|---|
| 13 |
cl::Hidden, |
|---|
| 14 |
cl::ZeroOrMore); |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
sys::Path getGcc() { |
|---|
| 18 |
const char *cc = NULL; |
|---|
| 19 |
|
|---|
| 20 |
if (gcc.getNumOccurrences() > 0 && gcc.length() > 0) |
|---|
| 21 |
cc = gcc.c_str(); |
|---|
| 22 |
|
|---|
| 23 |
if (!cc) |
|---|
| 24 |
cc = getenv("CC"); |
|---|
| 25 |
if (!cc) |
|---|
| 26 |
cc = "gcc"; |
|---|
| 27 |
|
|---|
| 28 |
sys::Path path = sys::Program::FindProgramByName(cc); |
|---|
| 29 |
if (path.empty() && !cc) { |
|---|
| 30 |
if (cc) { |
|---|
| 31 |
path.set(cc); |
|---|
| 32 |
} else { |
|---|
| 33 |
error("failed to locate gcc"); |
|---|
| 34 |
fatal(); |
|---|
| 35 |
} |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
return path; |
|---|
| 39 |
} |
|---|