]> git.tdb.fi Git - builder.git/blobdiff - source/installcomponent.cpp
Split Component into several subclasses
[builder.git] / source / installcomponent.cpp
diff --git a/source/installcomponent.cpp b/source/installcomponent.cpp
new file mode 100644 (file)
index 0000000..9584a51
--- /dev/null
@@ -0,0 +1,29 @@
+#include "installcomponent.h"
+#include "builder.h"
+#include "file.h"
+#include "sourcepackage.h"
+#include "tool.h"
+
+using namespace std;
+
+InstallComponent::InstallComponent(SourcePackage &p, const string &n):
+       Component(p, n)
+{ }
+
+void InstallComponent::create_targets() const
+{
+       Builder &builder = package.get_builder();
+       Target *inst = builder.get_build_graph().get_target("install");
+       Tool &copy = builder.get_toolchain().get_tool("CP");
+
+       SourceList source_filenames = collect_source_files();
+       for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+       {
+               FileTarget *ft;
+               if(Target *tgt = builder.get_vfs().get_target(*i))
+                       ft = dynamic_cast<FileTarget *>(tgt);
+               else
+                       ft = new File(builder, package, *i);
+               inst->add_dependency(*copy.create_target(*ft, name));
+       }
+}