]> git.tdb.fi Git - builder.git/blob - source/datapackcomponent.cpp
Replace basic for loops with range-based loops or algorithms
[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         for(const FS::Path &s: collect_source_files())
22         {
23                 string ext = FS::extpart(FS::basename(s));
24                 if(ext==".mdt")
25                 {
26                         Target *src = dcomp.create_source(*this, s);
27                         files.push_back(dcomp.create_target(*src, "collection"));
28                 }
29                 else if(Target *tgt = builder.get_vfs().get_target(s))
30                         files.push_back(tgt);
31                 else
32                         files.push_back(new DataSourceFile(builder, *this, s));
33         }
34
35         Target *result = dcomp.create_target(files, "pack");
36
37         BuildGraph &build_graph = builder.get_build_graph();
38         build_graph.add_primary_target(*result);
39         if(install)
40                 build_graph.add_installed_target(*result);
41 }