15460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===- SearchDirs.h -------------------------------------------------------===//
25460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
35460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//                     The MCLinker Project
45460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
55460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// This file is distributed under the University of Illinois Open Source
65460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// License. See LICENSE.TXT for details.
75460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
85460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#ifndef MCLD_MC_SEARCHDIRS_H
1022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#define MCLD_MC_SEARCHDIRS_H
1122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#include <mcld/ADT/Uncopyable.h>
1287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include <mcld/MC/Input.h>
1322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#include <mcld/Support/Path.h>
1422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
155460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include <llvm/ADT/StringRef.h>
165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#include <vector>
1822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#include <string>
1922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
2022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaonamespace mcld {
215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass MCLDFile;
235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass MCLDDirectory;
245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/** \class SearchDirs
265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  \brief SearchDirs contains the list of paths that MCLinker will search for
275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  archive libraries and control scripts.
285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *
295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  SearchDirs is customized for linking. It handles -L on the command line
305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  and SEARCH_DIR macro in the link script.
315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *
325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  @see MCLDDirectory.
335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao */
345460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass SearchDirs : private Uncopyable
355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao{
365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic:
375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  typedef std::vector<MCLDDirectory*> DirList;
385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  typedef DirList::iterator iterator;
395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  typedef DirList::const_iterator const_iterator;
405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic:
425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  SearchDirs();
4322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
4422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  SearchDirs(const sys::fs::Path& pSysRoot);
4522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ~SearchDirs();
475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
48affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  // find - give a namespec, return a real path of the shared object.
4922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  sys::fs::Path*
5022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  find(const std::string& pNamespec, mcld::Input::Type pPreferType);
515460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
5222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  const sys::fs::Path*
5322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  find(const std::string& pNamespec, mcld::Input::Type pPreferType) const;
545460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
5522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  void setSysRoot(const sys::fs::Path& pSysRoot) { m_SysRoot = pSysRoot; }
5622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  const sys::fs::Path& sysroot() const { return m_SysRoot; }
575460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
5822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // -----  iterators  ----- //
5922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  const_iterator begin() const { return m_DirList.begin(); }
6022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  iterator       begin()       { return m_DirList.begin(); }
6122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  const_iterator end  () const { return m_DirList.end();   }
6222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  iterator       end  ()       { return m_DirList.end();   }
635460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
645460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  // -----  modifiers  ----- //
656f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines  bool insert(const char* pDirectory);
666f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines
6722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  bool insert(const std::string& pDirectory);
6822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
6922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  bool insert(const sys::fs::Path& pDirectory);
705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate:
725460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  DirList m_DirList;
7322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  sys::fs::Path m_SysRoot;
745460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
755460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
765460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} // namespace of mcld
775460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
785460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#endif
795460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
80