1 #ifndef VIRTUALFILESYSTEM_H_
2 #define VIRTUALFILESYSTEM_H_
6 #include <msp/fs/path.h>
13 Provides access to the filesystem in a way that takes known targets into
14 account. Thus, targets may be returned for files that do not exist yet if it's
15 possible to build them.
17 class VirtualFileSystem
20 typedef std::list<std::string> SearchPath;
23 typedef std::map<std::string, FileTarget *> TargetMap;
27 TargetMap include_cache;
28 TargetMap library_cache;
31 VirtualFileSystem(Builder &);
33 FileTarget *get_target(const Msp::FS::Path &) const;
35 /** Registers a target with the VFS. A target may be registered at multiple
36 paths if building it results in multiple files. */
37 void register_path(const Msp::FS::Path &, FileTarget *);
39 /** Locates a source file. If a file is found but no target is associated
40 with it, a new package-less target is created with the appropriate tool. */
41 FileTarget *find_header(const std::string &, const SearchPath &);
43 /** Locates a library. The library name should be the same as what would be
44 used in linking with the library. If a file is found but no target is
45 associated with it, a new package-less target of appropriate type is
47 FileTarget *find_library(const std::string &, const SearchPath &, LibMode);
50 FileTarget *get_header(const Msp::FS::Path &, const Tool &);
51 FileTarget *get_library(const std::string &, const Msp::FS::Path &, LibMode);
52 Msp::FS::Path try_patterns(const Msp::FS::Path &, const std::list<Pattern> &, const std::string &);