From: Daniel Dunbar Date: Wed, 20 Jan 2010 02:35:16 +0000 (+0000) Subject: Driver: Lift clang resource directory computation to the Driver object. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=225c41706dc0f3682236e351820d339e14390e00;p=clang Driver: Lift clang resource directory computation to the Driver object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93971 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index 8933619b2c..3186471ce6 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -61,6 +61,9 @@ public: /// command line. std::string Dir; + /// The path to the compiler resource directory. + std::string ResourceDir; + /// Default host triple. std::string DefaultHostTriple; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index b073c0ae1e..c2693d8dff 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -67,6 +67,14 @@ Driver::Driver(llvm::StringRef _Name, llvm::StringRef _Dir, CCCUseClangCXX = false; } + + // Compute the path to the resource directory. + llvm::sys::Path P(Dir); + P.eraseComponent(); // Remove /bin from foo/bin + P.appendComponent("lib"); + P.appendComponent("clang"); + P.appendComponent(CLANG_VERSION_STRING); + ResourceDir = P.str(); } Driver::~Driver() { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 010953df5e..5e1d2661dd 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -9,7 +9,6 @@ #include "Tools.h" -#include "clang/Basic/Version.h" #include "clang/Driver/Action.h" #include "clang/Driver/Arg.h" #include "clang/Driver/ArgList.h" @@ -864,15 +863,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc); // Pass the path to compiler resource files. - // - // FIXME: Get this from a configuration object. - llvm::sys::Path P(D.Dir); - P.eraseComponent(); // Remove /bin from foo/bin - P.appendComponent("lib"); - P.appendComponent("clang"); - P.appendComponent(CLANG_VERSION_STRING); CmdArgs.push_back("-resource-dir"); - CmdArgs.push_back(Args.MakeArgString(P.str())); + CmdArgs.push_back(D.ResourceDir.c_str()); // Add preprocessing options like -I, -D, etc. if we are using the // preprocessor.