diff options
Diffstat (limited to 'tools/llvm-config/llvm-config.cpp')
| -rw-r--r-- | tools/llvm-config/llvm-config.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp index 79fd7f8..7edf5ec 100644 --- a/tools/llvm-config/llvm-config.cpp +++ b/tools/llvm-config/llvm-config.cpp @@ -54,7 +54,8 @@ using namespace llvm; static void VisitComponent(StringRef Name, const StringMap<AvailableComponent*> &ComponentMap, std::set<AvailableComponent*> &VisitedComponents, - std::vector<StringRef> &RequiredLibs) { + std::vector<StringRef> &RequiredLibs, + bool IncludeNonInstalled) { // Lookup the component. AvailableComponent *AC = ComponentMap.lookup(Name); assert(AC && "Invalid component name!"); @@ -65,10 +66,14 @@ static void VisitComponent(StringRef Name, return; } + // Only include non-installed components if requested. + if (!AC->IsInstalled && !IncludeNonInstalled) + return; + // Otherwise, visit all the dependencies. for (unsigned i = 0; AC->RequiredLibraries[i]; ++i) { VisitComponent(AC->RequiredLibraries[i], ComponentMap, VisitedComponents, - RequiredLibs); + RequiredLibs, IncludeNonInstalled); } // Add to the required library list. @@ -83,8 +88,11 @@ static void VisitComponent(StringRef Name, /// \param Components - The names of the components to find libraries for. /// \param RequiredLibs [out] - On return, the ordered list of libraries that /// are required to link the given components. +/// \param IncludeNonInstalled - Whether non-installed components should be +/// reported. void ComputeLibsForComponents(const std::vector<StringRef> &Components, - std::vector<StringRef> &RequiredLibs) { + std::vector<StringRef> &RequiredLibs, + bool IncludeNonInstalled) { std::set<AvailableComponent*> VisitedComponents; // Build a map of component names to information. @@ -107,7 +115,7 @@ void ComputeLibsForComponents(const std::vector<StringRef> &Components, } VisitComponent(ComponentLower, ComponentMap, VisitedComponents, - RequiredLibs); + RequiredLibs, IncludeNonInstalled); } // The list is now ordered with leafs first, we want the libraries to printed @@ -182,9 +190,9 @@ int main(int argc, char **argv) { sys::path::parent_path(CurrentPath)).str(); // Check to see if we are inside a development tree by comparing to possible - // locations (prefix style or CMake style). This could be wrong in the face of - // symbolic links, but is good enough. - if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE) { + // locations (prefix style or CMake style). + if (sys::fs::equivalent(CurrentExecPrefix, + Twine(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE)) { IsInDevelopmentTree = true; DevelopmentTreeLayout = MakefileStyle; @@ -196,11 +204,12 @@ int main(int argc, char **argv) { } else { ActiveObjRoot = LLVM_OBJ_ROOT; } - } else if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT)) { + } else if (sys::fs::equivalent(CurrentExecPrefix, LLVM_OBJ_ROOT)) { IsInDevelopmentTree = true; DevelopmentTreeLayout = CMakeStyle; ActiveObjRoot = LLVM_OBJ_ROOT; - } else if (CurrentExecPrefix == std::string(LLVM_OBJ_ROOT) + "/bin") { + } else if (sys::fs::equivalent(CurrentExecPrefix, + Twine(LLVM_OBJ_ROOT) + "/bin")) { IsInDevelopmentTree = true; DevelopmentTreeLayout = CMakeBuildModeStyle; ActiveObjRoot = LLVM_OBJ_ROOT; @@ -278,6 +287,10 @@ int main(int argc, char **argv) { PrintLibFiles = true; } else if (Arg == "--components") { for (unsigned j = 0; j != array_lengthof(AvailableComponents); ++j) { + // Only include non-installed components when in a development tree. + if (!AvailableComponents[j].IsInstalled && !IsInDevelopmentTree) + continue; + OS << ' '; OS << AvailableComponents[j].Name; } @@ -310,7 +323,8 @@ int main(int argc, char **argv) { // Construct the list of all the required libraries. std::vector<StringRef> RequiredLibs; - ComputeLibsForComponents(Components, RequiredLibs); + ComputeLibsForComponents(Components, RequiredLibs, + /*IncludeNonInstalled=*/IsInDevelopmentTree); for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) { StringRef Lib = RequiredLibs[i]; |
