• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SEARCHDIRS_H
10 #define SEARCHDIRS_H
11 #ifdef ENABLE_UNITTEST
12 #include <gtest.h>
13 #endif
14 #include <llvm/ADT/StringRef.h>
15 #include "mcld/ADT/Uncopyable.h"
16 #include "mcld/MC/MCLDInput.h"
17 
18 namespace mcld
19 {
20 
21 class MCLDFile;
22 class MCLDDirectory;
23 
24 namespace sys {
25 namespace fs {
26 class Path;
27 } // namespace of fs
28 } // namespace of sys
29 
30 /** \class SearchDirs
31  *  \brief SearchDirs contains the list of paths that MCLinker will search for
32  *  archive libraries and control scripts.
33  *
34  *  SearchDirs is customized for linking. It handles -L on the command line
35  *  and SEARCH_DIR macro in the link script.
36  *
37  *  @see MCLDDirectory.
38  */
39 class SearchDirs : private Uncopyable
40 {
41 public:
42   typedef std::vector<MCLDDirectory*> DirList;
43   typedef DirList::iterator iterator;
44   typedef DirList::const_iterator const_iterator;
45 
46 public:
47   SearchDirs();
48   ~SearchDirs();
49 
50   // find - give a namespec, return a real path of the shared object.
51   //
52   sys::fs::Path* find(const std::string& pNamespec, mcld::Input::Type pPreferType);
53 
54   // -----  iterators  ----- //
begin()55   iterator begin()
56   { return m_DirList.begin(); }
57 
end()58   iterator end()
59   { return m_DirList.end(); }
60 
begin()61   const_iterator begin() const
62   { return m_DirList.begin(); }
63 
end()64   const_iterator end() const
65   { return m_DirList.end(); }
66 
67   // -----  modifiers  ----- //
68   void add(const MCLDDirectory& pDirectory);
69 
70 private:
71   DirList m_DirList;
72 };
73 
74 } // namespace of mcld
75 
76 #endif
77 
78