class Builder;
class FileTarget;
+class Pattern;
+/**
+Provides access to the filesystem in a way that takes known targets into
+account. Thus, targets may be returned for files that do not exist yet if it's
+possible to build them.
+*/
class VirtualFileSystem
{
public:
- typedef std::list<std::string> SearchPath;
+ typedef std::list<Msp::FS::Path> SearchPath;
private:
- typedef std::map<std::string, FileTarget *> TargetMap;
+ typedef std::map<Msp::FS::Path, FileTarget *> TargetMap;
Builder &builder;
TargetMap targets;
- TargetMap include_cache;
- TargetMap library_cache;
+ std::set<Msp::FS::Path> nonexistent;
public:
VirtualFileSystem(Builder &);
+ /** Gets an existing target associated with a path. If no target has claimed
+ that path, 0 is returned. */
FileTarget *get_target(const Msp::FS::Path &) const;
+ /** Registers a target with the VFS. A target may be registered at multiple
+ paths if building it results in multiple files. */
void register_path(const Msp::FS::Path &, FileTarget *);
- /** Tries to locate a header based on location of including file and include
- path. Considers known targets as well as existing files. If a matching
- target is not found but a file exists, a new SystemHeader target will be
- created and returned. */
- FileTarget *find_header(const std::string &, const Msp::FS::Path &, const SearchPath &);
-
- /** Tries to locate a library in a library path. The library name should be
- the same as would be given to the linker with -l, i.e. without the "lib"
- prefix or extension. Considers known targets as well as existing files. If
- a matching target is not found but a file exists, a new SystemLibrary target
- will be created and returned. */
+ /** Locates a source file. If a file is found but no target is associated
+ with it, a new package-less target is created with the appropriate tool. */
+ FileTarget *find_header(const std::string &, const SearchPath &);
+
+ /** Locates a library. The library name should be the same as what would be
+ used in linking with the library. If a file is found but no target is
+ associated with it, a new package-less target of appropriate type is
+ created. */
FileTarget *find_library(const std::string &, const SearchPath &, LibMode);
+ /** Locates a binary. The normal search path for binaries is used (usually
+ this means the PATH environment variable). If a file is found but no target
+ is associated with it, a new package-less Executable target is created. */
+ FileTarget *find_binary(const std::string &);
+
private:
- /**
- Check if a header exists, either as a target or a file. Returns an existing
- target of one was found, or a new SystemHeader target if there was no known
- target but the file exists.
- */
- FileTarget *get_header(const Msp::FS::Path &);
-
- FileTarget *get_library(const std::string &, const Msp::FS::Path &, LibMode);
+ bool file_exists(const Msp::FS::Path &);
};
#endif