[cfe-commits] r67229 - in /cfe/trunk: include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp
Daniel Dunbar
daniel at zuster.org
Wed Mar 18 13:26:19 PDT 2009
Author: ddunbar
Date: Wed Mar 18 15:26:19 2009
New Revision: 67229
URL: http://llvm.org/viewvc/llvm-project?rev=67229&view=rev
Log:
Driver: Support ToolChain specific path lists to search for files and
programs.
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=67229&r1=67228&r2=67229&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Mar 18 15:26:19 2009
@@ -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 @@
/// 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 @@
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
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=67229&r1=67228&r2=67229&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Mar 18 15:26:19 2009
@@ -849,13 +849,36 @@
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);
}
More information about the cfe-commits
mailing list