]> git.tdb.fi Git - builder.git/blobdiff - source/component.cpp
Rework the Target class hierarchy
[builder.git] / source / component.cpp
index 26a0ab4b7246d5c24eccd6f26c494fa0fea54335..dd33941c7ed20f6b08b0bf8e4929f26ddf5c57fe 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2006-200 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -12,6 +12,7 @@ Distributed under the LGPL
 #include <msp/strings/lexicalcast.h>
 #include "builder.h"
 #include "component.h"
+#include "executable.h"
 #include "header.h"
 #include "install.h"
 #include "objectfile.h"
@@ -33,9 +34,6 @@ Component::Component(SourcePackage &p, Type t, const string &n):
        deflt(true)
 { }
 
-/**
-Prepares the build information for building.
-*/
 void Component::create_build_info()
 {
        build_info.add(pkg.get_build_info());
@@ -81,9 +79,6 @@ void Component::create_build_info()
        build_info.unique();
 }
 
-/**
-Creates all targets needed for building this component.
-*/
 void Component::create_targets() const
 {
        Builder &builder=pkg.get_builder();
@@ -95,7 +90,7 @@ void Component::create_targets() const
        bool build_exe=(type!=HEADERS);
 
        list<ObjectFile *> objs;
-       list<Target *> inst_tgts;
+       list<FileTarget *> inst_tgts;
        for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
        {
                string ext=FS::extpart(FS::basename(*i));
@@ -109,7 +104,7 @@ void Component::create_targets() const
                }
                else if(ext==".h")
                {
-                       Target *hdr=builder.get_target(i->str());
+                       FileTarget *hdr=dynamic_cast<FileTarget *>(builder.get_target(i->str()));
                        if(!hdr)
                                hdr=new Header(builder, this, i->str());
 
@@ -121,43 +116,40 @@ void Component::create_targets() const
 
        if(build_exe)
        {
-               Executable    *exe=0;
+               Binary *bin=0;
                StaticLibrary *slib=0;
                if(type==LIBRARY)
                {
-                       exe=new SharedLibrary(builder, *this, objs);
+                       bin=new SharedLibrary(builder, *this, objs);
                        slib=new StaticLibrary(builder, *this, objs);
                }
                else
-                       exe=new Executable(builder, *this, objs);
+                       bin=new Executable(builder, *this, objs);
 
                if(&pkg==builder.get_main_package() && deflt)
                {
-                       def_tgt->add_depend(exe);
+                       def_tgt->add_depend(bin);
                        if(slib) def_tgt->add_depend(slib);
                }
                else
                {
-                       world->add_depend(exe);
+                       world->add_depend(bin);
                        if(slib) world->add_depend(slib);
                }
 
                if(install)
                {
-                       inst_tgts.push_back(exe);
+                       inst_tgts.push_back(bin);
                        if(slib)
                                inst_tgts.push_back(slib);
                }
        }
 
        Target *inst_tgt=builder.get_target("install");
-       for(TargetList::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i)
+       for(list<FileTarget *>::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i)
                inst_tgt->add_depend(new Install(builder, pkg, **i));
 }
 
-/**
-Collects all files belonging to the component.
-*/
 PathList Component::collect_source_files() const
 {
        PathList files;