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