]> git.tdb.fi Git - builder.git/blob - source/datapackcomponent.cpp
Attach component information to data source files
[builder.git] / source / datapackcomponent.cpp
1 #include <msp/fs/utils.h>
2 #include "builder.h"
3 #include "datapackcomponent.h"
4 #include "datasourcefile.h"
5 #include "sourcepackage.h"
6 #include "tool.h"
7
8 using namespace std;
9 using namespace Msp;
10
11 DataPackComponent::DataPackComponent(SourcePackage &p, const string &n):
12         Component(p, n)
13 { }
14
15 void DataPackComponent::create_targets() const
16 {
17         Builder &builder = package.get_builder();
18         Tool &dcomp = builder.get_toolchain().get_tool("DATA");
19
20         list<Target *> files;
21         SourceList source_filenames = collect_source_files();
22         for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
23         {
24                 string ext = FS::extpart(FS::basename(*i));
25                 if(ext==".mdt")
26                 {
27                         Target *src = dcomp.create_source(*this, *i);
28                         files.push_back(dcomp.create_target(*src, "collection"));
29                 }
30                 else if(Target *tgt = builder.get_vfs().get_target(*i))
31                         files.push_back(tgt);
32                 else
33                         files.push_back(new DataSourceFile(builder, *this, *i));
34         }
35
36         Target *result = dcomp.create_target(files, "pack");
37
38         BuildGraph &build_graph = builder.get_build_graph();
39         build_graph.add_primary_target(*result);
40         if(install)
41                 build_graph.add_installed_target(*result);
42 }