forked from OSchip/llvm-project
Lift InitHeaderSearch::AddEnvVarPaths logic higher.
llvm-svn: 86337
This commit is contained in:
parent
6dc9638153
commit
ec87991c8f
|
@ -53,10 +53,6 @@ public:
|
||||||
bool isCXXAware, bool isUserSupplied,
|
bool isCXXAware, bool isUserSupplied,
|
||||||
bool isFramework, bool IgnoreSysRoot = false);
|
bool isFramework, bool IgnoreSysRoot = false);
|
||||||
|
|
||||||
/// AddEnvVarPaths - Add a list of paths from an environment variable to a
|
|
||||||
/// header search list.
|
|
||||||
void AddEnvVarPaths(const char *Name);
|
|
||||||
|
|
||||||
/// AddGnuCPlusPlusIncludePaths - Add the necessary paths to suport a gnu
|
/// AddGnuCPlusPlusIncludePaths - Add the necessary paths to suport a gnu
|
||||||
/// libstdc++.
|
/// libstdc++.
|
||||||
void AddGnuCPlusPlusIncludePaths(const std::string &Base, const char *Dir32,
|
void AddGnuCPlusPlusIncludePaths(const std::string &Base, const char *Dir32,
|
||||||
|
@ -69,9 +65,9 @@ public:
|
||||||
const char *Arch,
|
const char *Arch,
|
||||||
const char *Version);
|
const char *Version);
|
||||||
|
|
||||||
/// AddDefaultEnvVarPaths - Adds list of paths from default environment
|
/// AddDelimitedPaths - Add a list of paths delimited by the system PATH
|
||||||
/// variables such as CPATH.
|
/// separator. The processing follows that of the CPATH variable for gcc.
|
||||||
void AddDefaultEnvVarPaths(const LangOptions &Lang);
|
void AddDelimitedPaths(const char *String);
|
||||||
|
|
||||||
// AddDefaultCIncludePaths - Add paths that should always be searched.
|
// AddDefaultCIncludePaths - Add paths that should always be searched.
|
||||||
void AddDefaultCIncludePaths(const llvm::Triple &triple);
|
void AddDefaultCIncludePaths(const llvm::Triple &triple);
|
||||||
|
@ -80,9 +76,6 @@ public:
|
||||||
// compiling c++.
|
// compiling c++.
|
||||||
void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple);
|
void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple);
|
||||||
|
|
||||||
// AddDefaultFrameworkIncludePaths - Add the framework paths. Used on darwin.
|
|
||||||
void AddDefaultFrameworkIncludePaths(const llvm::Triple &triple);
|
|
||||||
|
|
||||||
/// AddDefaultSystemIncludePaths - Adds the default system include paths so
|
/// AddDefaultSystemIncludePaths - Adds the default system include paths so
|
||||||
/// that e.g. stdio.h is found.
|
/// that e.g. stdio.h is found.
|
||||||
void AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
void AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
||||||
|
|
|
@ -82,9 +82,8 @@ void InitHeaderSearch::AddPath(const llvm::StringRef &Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InitHeaderSearch::AddEnvVarPaths(const char *Name) {
|
void InitHeaderSearch::AddDelimitedPaths(const char *at) {
|
||||||
const char* at = getenv(Name);
|
if (*at == 0) // Empty string should not add '.' path.
|
||||||
if (!at || *at == 0) // Empty string should not add '.' path.
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char* delim = strchr(at, llvm::sys::PathSeparator);
|
const char* delim = strchr(at, llvm::sys::PathSeparator);
|
||||||
|
@ -443,35 +442,20 @@ void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(const llvm::Triple &tripl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitHeaderSearch::AddDefaultFrameworkIncludePaths(const llvm::Triple &triple) {
|
|
||||||
llvm::Triple::OSType os = triple.getOS();
|
|
||||||
if (os != llvm::Triple::Darwin)
|
|
||||||
return;
|
|
||||||
AddPath("/System/Library/Frameworks", System, true, false, true);
|
|
||||||
AddPath("/Library/Frameworks", System, true, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
||||||
const llvm::Triple &triple) {
|
const llvm::Triple &triple) {
|
||||||
AddDefaultCIncludePaths(triple);
|
AddDefaultCIncludePaths(triple);
|
||||||
AddDefaultFrameworkIncludePaths(triple);
|
|
||||||
|
// Add the default framework include paths on Darwin.
|
||||||
|
if (triple.getOS() == llvm::Triple::Darwin) {
|
||||||
|
AddPath("/System/Library/Frameworks", System, true, false, true);
|
||||||
|
AddPath("/Library/Frameworks", System, true, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (Lang.CPlusPlus)
|
if (Lang.CPlusPlus)
|
||||||
AddDefaultCPlusPlusIncludePaths(triple);
|
AddDefaultCPlusPlusIncludePaths(triple);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitHeaderSearch::AddDefaultEnvVarPaths(const LangOptions &Lang) {
|
|
||||||
AddEnvVarPaths("CPATH");
|
|
||||||
if (Lang.CPlusPlus && Lang.ObjC1)
|
|
||||||
AddEnvVarPaths("OBJCPLUS_INCLUDE_PATH");
|
|
||||||
else if (Lang.CPlusPlus)
|
|
||||||
AddEnvVarPaths("CPLUS_INCLUDE_PATH");
|
|
||||||
else if (Lang.ObjC1)
|
|
||||||
AddEnvVarPaths("OBJC_INCLUDE_PATH");
|
|
||||||
else
|
|
||||||
AddEnvVarPaths("C_INCLUDE_PATH");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// RemoveDuplicates - If there are duplicate directory entries in the specified
|
/// RemoveDuplicates - If there are duplicate directory entries in the specified
|
||||||
/// search list, remove the later (dead) ones.
|
/// search list, remove the later (dead) ones.
|
||||||
static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
|
static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
|
||||||
|
|
|
@ -1149,7 +1149,24 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Init.AddDefaultEnvVarPaths(Lang);
|
// Add CPATH environment paths.
|
||||||
|
if (const char *Env = getenv("CPATH"))
|
||||||
|
Init.AddDelimitedPaths(Env);
|
||||||
|
|
||||||
|
// Add language specific environment paths.
|
||||||
|
if (Lang.CPlusPlus && Lang.ObjC1) {
|
||||||
|
if (const char *Env = getenv("OBJCPLUS_INCLUDE_PATH"))
|
||||||
|
Init.AddDelimitedPaths(Env);
|
||||||
|
} else if (Lang.CPlusPlus) {
|
||||||
|
if (const char *Env = getenv("CPLUS_INCLUDE_PATH"))
|
||||||
|
Init.AddDelimitedPaths(Env);
|
||||||
|
} else if (Lang.ObjC1) {
|
||||||
|
if (const char *Env = getenv("OBJC_INCLUDE_PATH"))
|
||||||
|
Init.AddDelimitedPaths(Env);
|
||||||
|
} else {
|
||||||
|
if (const char *Env = getenv("C_INCLUDE_PATH"))
|
||||||
|
Init.AddDelimitedPaths(Env);
|
||||||
|
}
|
||||||
|
|
||||||
if (!nobuiltininc) {
|
if (!nobuiltininc) {
|
||||||
std::string P = GetBuiltinIncludePath(Argv0);
|
std::string P = GetBuiltinIncludePath(Argv0);
|
||||||
|
|
Loading…
Reference in New Issue