#include <list>
#include <map>
+#include <set>
#include <msp/fs/path.h>
+#include "buildinfo.h"
class Builder;
class FileTarget;
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
void register_path(const Msp::FS::Path &, FileTarget *);
/** 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 &);
+ 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);
/** 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);
+ 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:
- FileTarget *get_header(const Msp::FS::Path &, const Tool &);
- FileTarget *get_library(const std::string &, const Msp::FS::Path &, LibMode);
- Msp::FS::Path try_patterns(const Msp::FS::Path &, const std::list<Pattern> &, const std::string &);
+ bool file_exists(const Msp::FS::Path &);
};
#endif