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<Msp::FS::Path> SearchPath;
23 typedef std::map<Msp::FS::Path, FileTarget *> TargetMap;
27 std::set<Msp::FS::Path> nonexistent;
30 VirtualFileSystem(Builder &);
32 /** Gets an existing target associated with a path. If no target has claimed
33 that path, 0 is returned. */
34 FileTarget *get_target(const Msp::FS::Path &) const;
36 /** Registers a target with the VFS. A target may be registered at multiple
37 paths if building it results in multiple files. */
38 void register_path(const Msp::FS::Path &, FileTarget *);
40 /** Locates a source file. If a file is found but no target is associated
41 with it, a new package-less target is created with the appropriate tool. */
42 FileTarget *find_header(const std::string &, const SearchPath &);
44 /** Locates a library. The library name should be the same as what would be
45 used in linking with the library. If a file is found but no target is
46 associated with it, a new package-less target of appropriate type is
48 FileTarget *find_library(const std::string &, const SearchPath &, LibMode);
50 /** Locates a binary. The normal search path for binaries is used (usually
51 this means the PATH environment variable). If a file is found but no target
52 is associated with it, a new package-less Executable target is created. */
53 FileTarget *find_binary(const std::string &);
56 bool file_exists(const Msp::FS::Path &);