diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-ld/Linker.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-link/llvm-link.cpp | 2 | ||||
-rw-r--r-- | tools/llvmc/CompilerDriver.cpp | 85 | ||||
-rw-r--r-- | tools/llvmc/CompilerDriver.h | 8 | ||||
-rw-r--r-- | tools/llvmc/Configuration.cpp | 24 | ||||
-rw-r--r-- | tools/llvmc/llvmc.cpp | 4 |
6 files changed, 68 insertions, 57 deletions
diff --git a/tools/llvm-ld/Linker.cpp b/tools/llvm-ld/Linker.cpp index 9d1999517f..af2c0546f3 100644 --- a/tools/llvm-ld/Linker.cpp +++ b/tools/llvm-ld/Linker.cpp @@ -45,7 +45,7 @@ std::string llvm::FindLib(const std::string &Filename, bool SharedObjectOnly) { // Determine if the pathname can be found as it stands. sys::Path FilePath; - if (FilePath.set_file(Filename) && FilePath.readable()) + if (FilePath.setFile(Filename) && FilePath.readable()) return Filename; // Ask the System Path object to locate the library. This ensures that diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 6e404918b6..b1715a8e27 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -47,7 +47,7 @@ DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden); // static inline std::auto_ptr<Module> LoadFile(const std::string &FN) { sys::Path Filename; - if (!Filename.set_file(FN)) { + if (!Filename.setFile(FN)) { std::cerr << "Invalid file name: '" << FN << "'\n"; return std::auto_ptr<Module>(); } diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp index b890220c9c..182397a27e 100644 --- a/tools/llvmc/CompilerDriver.cpp +++ b/tools/llvmc/CompilerDriver.cpp @@ -134,7 +134,7 @@ public: StringVector::const_iterator E = paths.end(); while (I != E) { sys::Path tmp; - tmp.set_directory(*I); + tmp.setDirectory(*I); IncludePaths.push_back(tmp); ++I; } @@ -149,7 +149,7 @@ public: StringVector::const_iterator E = paths.end(); while (I != E) { sys::Path tmp; - tmp.set_directory(*I); + tmp.setDirectory(*I); LibraryPaths.push_back(tmp); ++I; } @@ -159,6 +159,10 @@ public: LibraryPaths.push_back(libPath); } + virtual void addToolPath( const sys::Path& toolPath ) { + ToolPaths.push_back(toolPath); + } + virtual void setfPassThrough(const StringVector& fOpts) { fOptions = fOpts; } @@ -182,8 +186,8 @@ private: void cleanup() { if (!isSet(KEEP_TEMPS_FLAG)) { - if (TempDir.is_directory() && TempDir.writable()) - TempDir.destroy_directory(/*remove_contents=*/true); + if (TempDir.isDirectory() && TempDir.writable()) + TempDir.destroyDirectory(/*remove_contents=*/true); } else { std::cout << "Temporary files are in " << TempDir.get() << "\n"; } @@ -192,9 +196,9 @@ private: sys::Path MakeTempFile(const std::string& basename, const std::string& suffix ) { sys::Path result(TempDir); - if (!result.append_file(basename)) + if (!result.appendFile(basename)) throw basename + ": can't use this file name"; - if (!result.append_suffix(suffix)) + if (!result.appendSuffix(suffix)) throw suffix + ": can't use this file suffix"; return result; } @@ -373,7 +377,7 @@ private: if (!isSet(DRY_RUN_FLAG)) { sys::Path progpath = sys::Program::FindProgramByName( action->program.get()); - if (progpath.is_empty()) + if (progpath.isEmpty()) throw std::string("Can't find program '"+progpath.get()+"'"); else if (progpath.executable()) action->program = progpath; @@ -404,24 +408,24 @@ private: const sys::Path& dir, bool native = false) { sys::Path fullpath(dir); - fullpath.append_file(link_item); + fullpath.appendFile(link_item); if (native) { - fullpath.append_suffix("a"); + fullpath.appendSuffix("a"); } else { - fullpath.append_suffix("bc"); + fullpath.appendSuffix("bc"); if (fullpath.readable()) return fullpath; - fullpath.elide_suffix(); - fullpath.append_suffix("o"); + fullpath.elideSuffix(); + fullpath.appendSuffix("o"); if (fullpath.readable()) return fullpath; fullpath = dir; - fullpath.append_file(std::string("lib") + link_item); - fullpath.append_suffix("a"); + fullpath.appendFile(std::string("lib") + link_item); + fullpath.appendSuffix("a"); if (fullpath.readable()) return fullpath; - fullpath.elide_suffix(); - fullpath.append_suffix("so"); + fullpath.elideSuffix(); + fullpath.appendSuffix("so"); if (fullpath.readable()) return fullpath; } @@ -446,14 +450,14 @@ private: // on the command line. PathVector::iterator PI = LibraryPaths.begin(); PathVector::iterator PE = LibraryPaths.end(); - while (PI != PE && fullpath.is_empty()) { + while (PI != PE && fullpath.isEmpty()) { fullpath = GetPathForLinkageItem(link_item.get(),*PI); ++PI; } // If we didn't find the file in any of the library search paths // so we have to bail. No where else to look. - if (fullpath.is_empty()) { + if (fullpath.isEmpty()) { err = std::string("Can't find linkage item '") + link_item.get() + "'"; return false; @@ -466,7 +470,7 @@ private: set.insert(fullpath); // If its an LLVM bytecode file ... - if (fullpath.is_bytecode_file()) { + if (fullpath.isBytecodeFile()) { // Process the dependent libraries recursively Module::LibraryListType modlibs; if (GetBytecodeDependentLibraries(fullpath.get(),modlibs)) { @@ -530,13 +534,13 @@ public: // If they are asking for linking and didn't provide an output // file then its an error (no way for us to "make up" a meaningful // file name based on the various linker input files). - if (finalPhase == LINKING && Output.is_empty()) + if (finalPhase == LINKING && Output.isEmpty()) throw std::string( "An output file name must be specified for linker output"); // If they are not asking for linking, provided an output file and // there is more than one input file, its an error - if (finalPhase != LINKING && !Output.is_empty() && InpList.size() > 1) + if (finalPhase != LINKING && !Output.isEmpty() && InpList.size() > 1) throw std::string("An output file name cannot be specified ") + "with more than one input file name when not linking"; @@ -581,19 +585,19 @@ public: // Initialize the input and output files sys::Path InFile(I->first); - sys::Path OutFile(I->first.get_basename()); + sys::Path OutFile(I->first.getBasename()); // PRE-PROCESSING PHASE Action& action = cd->PreProcessor; // Get the preprocessing action, if needed, or error if appropriate - if (!action.program.is_empty()) { + if (!action.program.isEmpty()) { if (action.isSet(REQUIRED_FLAG) || finalPhase == PREPROCESSING) { if (finalPhase == PREPROCESSING) { - OutFile.append_suffix("E"); + OutFile.appendSuffix("E"); actions.push_back(GetAction(cd,InFile,OutFile,PREPROCESSING)); } else { - sys::Path TempFile(MakeTempFile(I->first.get_basename(),"E")); + sys::Path TempFile(MakeTempFile(I->first.getBasename(),"E")); actions.push_back(GetAction(cd,InFile,TempFile, PREPROCESSING)); InFile = TempFile; @@ -614,13 +618,13 @@ public: action = cd->Translator; // Get the translation action, if needed, or error if appropriate - if (!action.program.is_empty()) { + if (!action.program.isEmpty()) { if (action.isSet(REQUIRED_FLAG) || finalPhase == TRANSLATION) { if (finalPhase == TRANSLATION) { - OutFile.append_suffix("o"); + OutFile.appendSuffix("o"); actions.push_back(GetAction(cd,InFile,OutFile,TRANSLATION)); } else { - sys::Path TempFile(MakeTempFile(I->first.get_basename(),"trans")); + sys::Path TempFile(MakeTempFile(I->first.getBasename(),"trans")); actions.push_back(GetAction(cd,InFile,TempFile,TRANSLATION)); InFile = TempFile; } @@ -630,10 +634,10 @@ public: /// The output of the translator is an LLVM Assembly program /// We need to translate it to bytecode Action* action = new Action(); - action->program.set_file("llvm-as"); + action->program.setFile("llvm-as"); action->args.push_back(InFile.get()); action->args.push_back("-o"); - InFile.append_suffix("bc"); + InFile.appendSuffix("bc"); action->args.push_back(InFile.get()); actions.push_back(action); } @@ -653,13 +657,13 @@ public: // Get the optimization action, if needed, or error if appropriate if (!isSet(EMIT_RAW_FLAG)) { - if (!action.program.is_empty()) { + if (!action.program.isEmpty()) { if (action.isSet(REQUIRED_FLAG) || finalPhase == OPTIMIZATION) { if (finalPhase == OPTIMIZATION) { - OutFile.append_suffix("o"); + OutFile.appendSuffix("o"); actions.push_back(GetAction(cd,InFile,OutFile,OPTIMIZATION)); } else { - sys::Path TempFile(MakeTempFile(I->first.get_basename(),"opt")); + sys::Path TempFile(MakeTempFile(I->first.getBasename(),"opt")); actions.push_back(GetAction(cd,InFile,TempFile,OPTIMIZATION)); InFile = TempFile; } @@ -668,11 +672,11 @@ public: /// The output of the optimizer is an LLVM Assembly program /// We need to translate it to bytecode with llvm-as Action* action = new Action(); - action->program.set_file("llvm-as"); + action->program.setFile("llvm-as"); action->args.push_back(InFile.get()); action->args.push_back("-f"); action->args.push_back("-o"); - InFile.append_suffix("bc"); + InFile.appendSuffix("bc"); action->args.push_back(InFile.get()); actions.push_back(action); } @@ -695,20 +699,20 @@ public: if (isSet(EMIT_NATIVE_FLAG)) { // Use llc to get the native assembly file Action* action = new Action(); - action->program.set_file("llc"); + action->program.setFile("llc"); action->args.push_back(InFile.get()); action->args.push_back("-f"); action->args.push_back("-o"); - OutFile.append_suffix("s"); + OutFile.appendSuffix("s"); action->args.push_back(OutFile.get()); } else { // Just convert back to llvm assembly with llvm-dis Action* action = new Action(); - action->program.set_file("llvm-dis"); + action->program.setFile("llvm-dis"); action->args.push_back(InFile.get()); action->args.push_back("-f"); action->args.push_back("-o"); - OutFile.append_suffix("ll"); + OutFile.appendSuffix("ll"); action->args.push_back(OutFile.get()); actions.push_back(action); } @@ -743,7 +747,7 @@ public: // Set up the linking action with llvm-ld Action* link = new Action(); - link->program.set_file("llvm-ld"); + link->program.setFile("llvm-ld"); // Add in the optimization level requested switch (optLevel) { @@ -834,6 +838,7 @@ private: std::string machine; ///< Target machine name PathVector LibraryPaths; ///< -L options PathVector IncludePaths; ///< -I options + PathVector ToolPaths; ///< -B options StringVector Defines; ///< -D options sys::Path TempDir; ///< Name of the temporary directory. StringTable AdditionalArgs; ///< The -Txyz options diff --git a/tools/llvmc/CompilerDriver.h b/tools/llvmc/CompilerDriver.h index e15bc221da..62e53e2702 100644 --- a/tools/llvmc/CompilerDriver.h +++ b/tools/llvmc/CompilerDriver.h @@ -161,7 +161,7 @@ namespace llvm { /// @brief Set the output machine name. virtual void setOutputMachine(const std::string& machineName) = 0; - /// @brief Set Preprocessor specific options + /// @brief Set the options for a given phase. virtual void setPhaseArgs(Phases phase, const StringVector& opts) = 0; /// @brief Set Library Paths @@ -173,10 +173,12 @@ namespace llvm { /// @brief Set Library Paths virtual void setLibraryPaths(const StringVector& paths) = 0; - /// @brief Set the list of library paths to be searched for - /// libraries. + /// @brief Add a path to the list of library paths virtual void addLibraryPath( const sys::Path& libPath ) = 0; + /// @brief Add a path to the list of paths in which to find tools + virtual void addToolPath( const sys::Path& toolPath) = 0; + /// @brief Set the list of -f options to be passed through virtual void setfPassThrough(const StringVector& fOpts) = 0; diff --git a/tools/llvmc/Configuration.cpp b/tools/llvmc/Configuration.cpp index 6a835e26eb..01611ad335 100644 --- a/tools/llvmc/Configuration.cpp +++ b/tools/llvmc/Configuration.cpp @@ -233,7 +233,7 @@ namespace { action.args.clear(); } else { if (token == STRING || token == OPTION) { - action.program.set_file(ConfigLexerState.StringVal); + action.program.setFile(ConfigLexerState.StringVal); } else { error("Expecting a program name"); } @@ -421,33 +421,33 @@ CompilerDriver::ConfigData* LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) { CompilerDriver::ConfigData* result = 0; sys::Path confFile; - if (configDir.is_empty()) { + if (configDir.isEmpty()) { // Try the environment variable const char* conf = getenv("LLVM_CONFIG_DIR"); if (conf) { - confFile.set_directory(conf); - confFile.append_file(ftype); + confFile.setDirectory(conf); + confFile.appendFile(ftype); if (!confFile.readable()) throw std::string("Configuration file for '") + ftype + "' is not available."; } else { // Try the user's home directory confFile = sys::Path::GetUserHomeDirectory(); - if (!confFile.is_empty()) { - confFile.append_directory(".llvm"); - confFile.append_directory("etc"); - confFile.append_file(ftype); + if (!confFile.isEmpty()) { + confFile.appendDirectory(".llvm"); + confFile.appendDirectory("etc"); + confFile.appendFile(ftype); if (!confFile.readable()) confFile.clear(); } - if (!confFile.is_empty()) { + if (!confFile.isEmpty()) { // Okay, try the LLVM installation directory confFile = sys::Path::GetLLVMConfigDir(); - confFile.append_file(ftype); + confFile.appendFile(ftype); if (!confFile.readable()) { // Okay, try the "standard" place confFile = sys::Path::GetLLVMDefaultConfigDir(); - confFile.append_file(ftype); + confFile.appendFile(ftype); if (!confFile.readable()) { throw std::string("Configuration file for '") + ftype + "' is not available."; @@ -457,7 +457,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) { } } else { confFile = configDir; - confFile.append_file(ftype); + confFile.appendFile(ftype); if (!confFile.readable()) throw std::string("Configuration file for '") + ftype + "' is not available."; diff --git a/tools/llvmc/llvmc.cpp b/tools/llvmc/llvmc.cpp index d5536e17d8..c377659a88 100644 --- a/tools/llvmc/llvmc.cpp +++ b/tools/llvmc/llvmc.cpp @@ -111,6 +111,10 @@ cl::list<std::string> WOpts("W", cl::ZeroOrMore, cl::Prefix, cl::desc("Pass through -W options to compiler tools"), cl::value_desc("warnings category")); +cl::list<std::string> BOpt("B", cl::ZeroOrMore, cl::Prefix, + cl::desc("Indicate where llvmc sub-tools are installed"), + cl::value_desc("directory path containing bin and lib directories")); + //===------------------------------------------------------------------------=== //=== INPUT OPTIONS //===------------------------------------------------------------------------=== |