]> git.tdb.fi Git - builder.git/blobdiff - source/virtualfilesystem.h
Rewrite the find_* functions
[builder.git] / source / virtualfilesystem.h
index 5ecc04b414f04f15ea059c48af19470312dfc4a8..f0cb7383fc9e26ea093d558cbb5bc2885d574f89 100644 (file)
@@ -9,6 +9,11 @@ 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:
@@ -19,40 +24,29 @@ private:
 
        Builder &builder;
        TargetMap targets;
-       TargetMap include_cache;
-       TargetMap library_cache;
+       std::set<Msp::FS::Path> nonexistent;
 
 public:
        VirtualFileSystem(Builder &);
 
        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);
 
 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);
-
-       void fill_candidates(std::list<std::string> &, const std::list<Pattern> &, const std::string &);
+       bool file_exists(const Msp::FS::Path &);
 };
 
 #endif