forked from OSchip/llvm-project
Driver: Support ToolChain specific path lists to search for files and
programs. llvm-svn: 67229
This commit is contained in:
parent
da382a88bf
commit
68b01a03ba
|
@ -10,6 +10,7 @@
|
|||
#ifndef CLANG_DRIVER_TOOLCHAIN_H_
|
||||
#define CLANG_DRIVER_TOOLCHAIN_H_
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/System/Path.h"
|
||||
#include <string>
|
||||
|
||||
|
@ -23,9 +24,21 @@ namespace driver {
|
|||
|
||||
/// ToolChain - Access to tools for a single platform.
|
||||
class ToolChain {
|
||||
public:
|
||||
typedef llvm::SmallVector<std::string, 4> path_list;
|
||||
|
||||
private:
|
||||
const HostInfo &Host;
|
||||
std::string Arch, Platform, OS;
|
||||
|
||||
/// The list of toolchain specific path prefixes to search for
|
||||
/// files.
|
||||
path_list FilePaths;
|
||||
|
||||
/// The list of toolchain specific path prefixes to search for
|
||||
/// programs.
|
||||
path_list ProgramPaths;
|
||||
|
||||
protected:
|
||||
ToolChain(const HostInfo &Host, const char *_Arch, const char *_Platform,
|
||||
const char *_OS);
|
||||
|
@ -40,6 +53,12 @@ public:
|
|||
const std::string &getPlatform() const { return Platform; }
|
||||
const std::string &getOS() const { return OS; }
|
||||
|
||||
path_list getFilePaths() { return FilePaths; }
|
||||
const path_list getFilePaths() const { return FilePaths; }
|
||||
|
||||
path_list getProgramPaths() { return ProgramPaths; }
|
||||
const path_list getProgramPaths() const { return ProgramPaths; }
|
||||
|
||||
// Tool access.
|
||||
|
||||
/// TranslateArgs - Create a new derived argument list for any
|
||||
|
|
|
@ -849,13 +849,36 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
|
|||
|
||||
llvm::sys::Path Driver::GetFilePath(const char *Name,
|
||||
const ToolChain &TC) const {
|
||||
// FIXME: Implement.
|
||||
const ToolChain::path_list &List = TC.getFilePaths();
|
||||
for (ToolChain::path_list::const_iterator
|
||||
it = List.begin(), ie = List.end(); it != ie; ++it) {
|
||||
llvm::sys::Path P(*it);
|
||||
P.appendComponent(Name);
|
||||
if (P.exists())
|
||||
return P;
|
||||
}
|
||||
|
||||
return llvm::sys::Path(Name);
|
||||
}
|
||||
|
||||
llvm::sys::Path Driver::GetProgramPath(const char *Name,
|
||||
const ToolChain &TC) const {
|
||||
// FIXME: Implement.
|
||||
const ToolChain::path_list &List = TC.getProgramPaths();
|
||||
for (ToolChain::path_list::const_iterator
|
||||
it = List.begin(), ie = List.end(); it != ie; ++it) {
|
||||
llvm::sys::Path P(*it);
|
||||
P.appendComponent(Name);
|
||||
if (P.exists())
|
||||
return P;
|
||||
}
|
||||
|
||||
// As a last resort, always search in our directory before pulling
|
||||
// from the path.
|
||||
llvm::sys::Path P(Dir);
|
||||
P.appendComponent(Name);
|
||||
if (P.exists())
|
||||
return P;
|
||||
|
||||
return llvm::sys::Path(Name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue