]> git.tdb.fi Git - builder.git/blobdiff - source/datapackcomponent.cpp
Split Component into several subclasses
[builder.git] / source / datapackcomponent.cpp
diff --git a/source/datapackcomponent.cpp b/source/datapackcomponent.cpp
new file mode 100644 (file)
index 0000000..f936e91
--- /dev/null
@@ -0,0 +1,42 @@
+#include <msp/fs/utils.h>
+#include "builder.h"
+#include "datapackcomponent.h"
+#include "file.h"
+#include "sourcepackage.h"
+#include "tool.h"
+
+using namespace std;
+using namespace Msp;
+
+DataPackComponent::DataPackComponent(SourcePackage &p, const string &n):
+       Component(p, n)
+{ }
+
+void DataPackComponent::create_targets() const
+{
+       Builder &builder = package.get_builder();
+       Tool &dcomp = builder.get_toolchain().get_tool("DATA");
+
+       list<Target *> files;
+       SourceList source_filenames = collect_source_files();
+       for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+       {
+               string ext = FS::extpart(FS::basename(*i));
+               if(ext==".mdt")
+               {
+                       Target *src = dcomp.create_source(*this, *i);
+                       files.push_back(dcomp.create_target(*src, "collection"));
+               }
+               else if(Target *tgt = builder.get_vfs().get_target(*i))
+                       files.push_back(tgt);
+               else
+                       files.push_back(new File(builder, package, *i));
+       }
+
+       Target *result = dcomp.create_target(files, "pack");
+
+       BuildGraph &build_graph = builder.get_build_graph();
+       build_graph.add_primary_target(*result);
+       if(install)
+               build_graph.add_installed_target(*result);
+}