1//===- SearchDirs.h -------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_MC_SEARCHDIRS_H_ 10#define MCLD_MC_SEARCHDIRS_H_ 11 12#include "mcld/MC/Input.h" 13#include "mcld/Support/Path.h" 14#include "mcld/Support/Compiler.h" 15 16#include <llvm/ADT/StringRef.h> 17 18#include <string> 19#include <vector> 20 21namespace mcld { 22 23class MCLDDirectory; 24class MCLDFile; 25 26/** \class SearchDirs 27 * \brief SearchDirs contains the list of paths that MCLinker will search for 28 * archive libraries and control scripts. 29 * 30 * SearchDirs is customized for linking. It handles -L on the command line 31 * and SEARCH_DIR macro in the link script. 32 * 33 * @see MCLDDirectory. 34 */ 35class SearchDirs { 36 public: 37 typedef std::vector<MCLDDirectory*> DirList; 38 typedef DirList::iterator iterator; 39 typedef DirList::const_iterator const_iterator; 40 41 public: 42 SearchDirs(); 43 44 explicit SearchDirs(const sys::fs::Path& pSysRoot); 45 46 ~SearchDirs(); 47 48 // find - give a namespec, return a real path of the shared object. 49 sys::fs::Path* find(const std::string& pNamespec, 50 mcld::Input::Type pPreferType); 51 52 const sys::fs::Path* find(const std::string& pNamespec, 53 mcld::Input::Type pPreferType) const; 54 55 void setSysRoot(const sys::fs::Path& pSysRoot) { m_SysRoot = pSysRoot; } 56 const sys::fs::Path& sysroot() const { return m_SysRoot; } 57 58 // ----- iterators ----- // 59 const_iterator begin() const { return m_DirList.begin(); } 60 iterator begin() { return m_DirList.begin(); } 61 const_iterator end() const { return m_DirList.end(); } 62 iterator end() { return m_DirList.end(); } 63 64 // ----- modifiers ----- // 65 bool insert(const char* pDirectory); 66 67 bool insert(const std::string& pDirectory); 68 69 bool insert(const sys::fs::Path& pDirectory); 70 71 private: 72 DirList m_DirList; 73 sys::fs::Path m_SysRoot; 74 75 private: 76 DISALLOW_COPY_AND_ASSIGN(SearchDirs); 77}; 78 79} // namespace mcld 80 81#endif // MCLD_MC_SEARCHDIRS_H_ 82