X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvirtualfilesystem.h;h=a3327de2490001c1f3e3c349ac284e66fb9c7611;hb=f5413fd8f007164591af26be9ded15ee7c707540;hp=16f8c6d9e7e2a3e0bfafd3fb5a7f9a01c0828d62;hpb=bd2a50ecb9f582c6e9569ffc9f33d41f10363c5f;p=builder.git diff --git a/source/virtualfilesystem.h b/source/virtualfilesystem.h index 16f8c6d..a3327de 100644 --- a/source/virtualfilesystem.h +++ b/source/virtualfilesystem.h @@ -3,53 +3,61 @@ #include #include +#include #include +#include "buildinfo.h" 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 SearchPath; + typedef std::list SearchPath; private: - typedef std::map TargetMap; + typedef std::map TargetMap; Builder &builder; TargetMap targets; - TargetMap include_cache; - TargetMap library_cache; + std::set 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 &); + /** 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. If + use_syspath is true, the system path reported by the tool is also searched. */ + FileTarget *find_header(const std::string &, Tool *, const SearchPath &, bool use_syspath = true); - /** 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. */ - FileTarget *find_library(const std::string &, const SearchPath &, LibMode); + /** 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. If use_syspath is true, the system path reported by the LINK tool + is also searched. */ + FileTarget *find_library(const std::string &, const SearchPath &, BuildInfo::LibraryMode, bool use_syspath = true); + + /** 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