1 #ifndef VIRTUALFILESYSTEM_H_
2 #define VIRTUALFILESYSTEM_H_
6 #include <msp/fs/path.h>
12 class VirtualFileSystem
15 typedef std::list<std::string> SearchPath;
18 typedef std::map<std::string, FileTarget *> TargetMap;
22 TargetMap include_cache;
23 TargetMap library_cache;
26 VirtualFileSystem(Builder &);
28 FileTarget *get_target(const Msp::FS::Path &) const;
30 void register_path(const Msp::FS::Path &, FileTarget *);
32 /** Tries to locate a header based on location of including file and include
33 path. Considers known targets as well as existing files. If a matching
34 target is not found but a file exists, a new SystemHeader target will be
35 created and returned. */
36 FileTarget *find_header(const std::string &, const Msp::FS::Path &, const SearchPath &);
38 /** Tries to locate a library in a library path. The library name should be
39 the same as would be given to the linker with -l, i.e. without the "lib"
40 prefix or extension. Considers known targets as well as existing files. If
41 a matching target is not found but a file exists, a new SystemLibrary target
42 will be created and returned. */
43 FileTarget *find_library(const std::string &, const SearchPath &, LibMode);
47 Check if a header exists, either as a target or a file. Returns an existing
48 target of one was found, or a new SystemHeader target if there was no known
49 target but the file exists.
51 FileTarget *get_header(const Msp::FS::Path &);
53 FileTarget *get_library(const std::string &, const Msp::FS::Path &, LibMode);
55 Msp::FS::Path try_patterns(const Msp::FS::Path &, const std::list<Pattern> &, const std::string &);