]> git.tdb.fi Git - builder.git/blobdiff - source/component.cpp
Revamp problem reporting system to be more useful
[builder.git] / source / component.cpp
index 6a3796d197abb29f3090cbf9d7d8a89972b3cc60..07cd6ea5aee874df889e4c34c49c77ae12ae5356 100644 (file)
@@ -7,20 +7,21 @@ Distributed under the LGPL
 
 #include <msp/core/error.h>
 #include <msp/path/utils.h>
+#include <msp/strings/lexicalcast.h>
 #include "builder.h"
 #include "component.h"
 #include "header.h"
 #include "install.h"
 #include "objectfile.h"
-#include "package.h"
 #include "sharedlibrary.h"
+#include "sourcepackage.h"
 #include "staticlibrary.h"
 #include "target.h"
 
 using namespace std;
 using namespace Msp;
 
-Component::Component(Package &p, Type t, const string &n):
+Component::Component(SourcePackage &p, Type t, const string &n):
        pkg(p),
        type(t),
        name(n),
@@ -30,15 +31,6 @@ Component::Component(Package &p, Type t, const string &n):
        deflt(true)
 { }
 
-/**
-Tries to resolve all references to packages.
-*/
-void Component::resolve_refs()
-{
-       for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
-               i->resolve();
-}
-
 /**
 Prepares the build information for building.
 */
@@ -46,12 +38,14 @@ void Component::create_build_info()
 {
        build_info.add(pkg.get_build_info());
 
-       for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
+       for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
+               build_info.add((*i)->get_exported_binfo());
+
+       if(type==PROGRAM)
        {
-               if(!i->get_package())
-                       continue;
-               //i->get_package()->create_build_info();
-               build_info.add(i->get_package()->get_exported_binfo());
+               string strip=pkg.get_config().get_option("strip").value;
+               if(lexical_cast<bool>(strip))
+                       build_info.ldflags.push_back("-s");
        }
 
        if(modular)
@@ -80,7 +74,7 @@ void Component::create_targets() const
 
        PathList files=collect_source_files();
 
-       bool build_exe=(type!=Component::HEADERS);
+       bool build_exe=(type!=HEADERS);
 
        list<ObjectFile *> objs;
        list<Target *> inst_tgts;
@@ -112,7 +106,7 @@ void Component::create_targets() const
        {
                Executable    *exe=0;
                StaticLibrary *slib=0;
-               if(type==Component::LIBRARY)
+               if(type==LIBRARY)
                {
                        exe=new SharedLibrary(builder, *this, objs);
                        slib=new StaticLibrary(builder, *this, objs);
@@ -120,7 +114,7 @@ void Component::create_targets() const
                else
                        exe=new Executable(builder, *this, objs);
 
-               if(&pkg==builder.get_default_package() && deflt)
+               if(&pkg==builder.get_main_package() && deflt)
                {
                        def_tgt->add_depend(exe);
                        if(slib) def_tgt->add_depend(slib);
@@ -188,7 +182,9 @@ void Component::Loader::source(const string &s)
 
 void Component::Loader::require(const string &n)
 {
-       comp.requires.push_back(PackageRef(comp.pkg.get_builder(), n));
+       Package *req=comp.pkg.get_builder().get_package(n);
+       if(req)
+               comp.requires.push_back(req);
 }
 
 void Component::Loader::modular()