Merge pull request #115 from pedronavf/master

Added functionality to have clang in a custom directory, and not in the PATH
This commit is contained in:
Thomas Pöchtrager 2017-06-25 15:57:23 +02:00 committed by GitHub
commit a0c5314c2d
3 changed files with 30 additions and 3 deletions

View File

@ -167,6 +167,16 @@ bool usegcclibstdcxx(Target &target, const char *, const char *, char **) {
return true; return true;
} }
bool compilerpath(Target &target, const char *, const char *path, char **) {
target.compilerpath = path;
return true;
}
bool intrinsicpath(Target &target, const char *, const char *path, char **) {
target.intrinsicpath = path;
return true;
}
bool runprog(Target &target, const char *, const char *progname, char **cargs) { bool runprog(Target &target, const char *, const char *progname, char **cargs) {
auto *prog = program::getprog(progname); auto *prog = program::getprog(progname);
@ -258,6 +268,13 @@ constexpr struct Opt {
{"-icxx-isystem", checkincludepath, true, true}, {"-icxx-isystem", checkincludepath, true, true},
{"-cxx-isystem", checkincludepath, true, true}, {"-cxx-isystem", checkincludepath, true, true},
{"-I", checkincludepath, true, true}, {"-I", checkincludepath, true, true},
// sets a custom path for the compiler
{"-foc-compiler-path", compilerpath, true, false, "="},
// specifies an additional directory to search when looking for clang's
// intrinsic paths
{"-foc-intrinsic-path", intrinsicpath, true, false, "="}
}; };
bool parse(int argc, char **argv, Target &target) { bool parse(int argc, char **argv, Target &target) {

View File

@ -288,12 +288,17 @@ void Target::setCompilerPath() {
compilerexecname = getTriple(); compilerexecname = getTriple();
compilerexecname += "-"; compilerexecname += "-";
compilerexecname += compilername; compilerexecname += compilername;
} else {
if (!compilerpath.empty()) {
compilerpath += "/";
compilerpath += compilername;
} else { } else {
if (!realPath(compilername.c_str(), compilerpath, ignoreCCACHE)) if (!realPath(compilername.c_str(), compilerpath, ignoreCCACHE))
compilerpath = compilername; compilerpath = compilername;
compilerexecname += compilername; compilerexecname += compilername;
} }
}
} }
bool Target::findClangIntrinsicHeaders(std::string &path) { bool Target::findClangIntrinsicHeaders(std::string &path) {
@ -404,6 +409,10 @@ do { \
TRYDIR2("/../include/clang"); TRYDIR2("/../include/clang");
TRYDIR2("/usr/include/clang"); TRYDIR2("/usr/include/clang");
if (!intrinsicpath.empty()) {
TRYDIR2(intrinsicpath);
}
return false; return false;
#undef TRYDIR #undef TRYDIR
#undef TRYDIR2 #undef TRYDIR2

View File

@ -149,6 +149,7 @@ struct Target {
string_vector args; string_vector args;
const char *language; const char *language;
char execpath[PATH_MAX + 1]; char execpath[PATH_MAX + 1];
std::string intrinsicpath;
}; };
} // namespace target } // namespace target