]> git.tdb.fi Git - builder.git/blob - source/lib/installmap.h
Add visibility decorations to the library and plugins
[builder.git] / source / lib / installmap.h
1 #ifndef INSTALLMAP_H_
2 #define INSTALLMAP_H_
3
4 #include <vector>
5 #include <msp/datafile/objectloader.h>
6 #include <msp/fs/path.h>
7 #include "libbuilder_api.h"
8
9 class FileTarget;
10
11 /**
12 Maps install locations based on location in the source tree.  Mappings are
13 defined as pairs of source and install locations.  Targets within a source
14 location are mapped if their default install location shares a common prefix
15 with the mapped install location.  The remainder of the source location is
16 appended to the mapped install location to form the final install location.
17 */
18 class LIBBUILDER_API InstallMap
19 {
20 public:
21         class Loader: public Msp::DataFile::ObjectLoader<InstallMap>
22         {
23         private:
24                 Msp::FS::Path source_base;
25
26         public:
27                 Loader(InstallMap &, const Msp::FS::Path &);
28
29         private:
30                 void map(const std::string &, const std::string &);
31         };
32
33 private:
34         struct Entry
35         {
36                 Msp::FS::Path source;
37                 Msp::FS::Path install;
38         };
39
40         std::vector<Entry> entries;
41
42 public:
43         /** Adds an install mapping.  Multiple mappings can be specified for the
44         same source location, but the first one that matches both that and the
45         target's default install location will be used. */
46         void add_mapping(const Msp::FS::Path &, const Msp::FS::Path &);
47
48         /** Returns the install location for a target.  If no defined mappings match
49         the target, its default install location is returned. */
50         Msp::FS::Path get_install_location(const FileTarget &) const;
51 };
52
53 #endif