]> git.tdb.fi Git - builder.git/blobdiff - source/component.cpp
Replace per-file copyright notices with a single file
[builder.git] / source / component.cpp
index c440e4c90df9c07c30db084f75d5fc8678963d73..ea53d23ea94693fb35e79a290bd5a9364215b018 100644 (file)
@@ -1,12 +1,4 @@
-/* $Id$
-
-This file is part of builder
-Copyright © 2006-2010  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <algorithm>
-#include <msp/core/except.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
@@ -35,11 +27,18 @@ Component::Component(SourcePackage &p, Type t, const string &n):
        type(t),
        name(n),
        install(false),
-       module_host(0),
-       modular(false),
        deflt(true)
 { }
 
+void Component::configure(const StringMap &opts, unsigned flag)
+{
+       for(StringList::iterator i=sources.begin(); i!=sources.end(); ++i)
+               *i = (pkg.get_source()/pkg.expand_string(*i)).str();
+
+       for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+               (*i)->configure(opts, flag&2);
+}
+
 void Component::create_build_info()
 {
        const PackageList &pkg_reqs = pkg.get_requires();
@@ -92,18 +91,6 @@ void Component::create_build_info()
                build_info.cflags.push_back("-fPIC");
        }
 
-       if(modular)
-       {
-               build_info.ldflags.push_back("-rdynamic");
-               build_info.libs.push_back("dl");
-       }
-       else if(module_host)
-       {
-               const PathList &host_src = module_host->get_sources();
-               for(PathList::const_iterator i=host_src.begin(); i!=host_src.end(); ++i)
-                       build_info.incpath.push_back(i->str());
-       }
-
        build_info.unique();
 }
 
@@ -245,16 +232,17 @@ void Component::create_targets() const
 PathList Component::collect_source_files() const
 {
        PathList files;
-       for(PathList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+       for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
        {
-               if(FS::is_dir(*i))
+               FS::Path path(*i);
+               if(FS::is_dir(path))
                {
-                       list<string> sfiles = list_files(*i);
+                       list<string> sfiles = list_files(path);
                        for(list<string>::iterator j=sfiles.begin(); j!=sfiles.end(); ++j)
-                               files.push_back(*i / *j);
+                               files.push_back(path / *j);
                }
                else
-                       files.push_back(*i);
+                       files.push_back(path);
        }
 
        return files;
@@ -287,7 +275,7 @@ void Component::Loader::finish()
 
 void Component::Loader::source(const string &s)
 {
-       comp.sources.push_back(comp.pkg.get_source()/s);
+       comp.sources.push_back(s);
 }
 
 void Component::Loader::require(const string &n)
@@ -299,24 +287,14 @@ void Component::Loader::require(const string &n)
 
 void Component::Loader::modular()
 {
-       if(comp.type!=PROGRAM)
-               throw Exception("Only programs can be modular");
-       comp.modular = true;
+       IO::print("%s: Note: modular is deprecated\n", get_source());
+       comp.build_info.ldflags.push_back("-rdynamic");
+       comp.build_info.libs.push_back("dl");
 }
 
-void Component::Loader::host(const string &n)
+void Component::Loader::host(const string &)
 {
-       const ComponentList &comps = comp.pkg.get_components();
-       for(ComponentList::const_iterator i=comps.begin(); i!=comps.end(); ++i)
-               if(i->get_name()==n)
-               {
-                       if(i->get_type()!=PROGRAM || !i->is_modular())
-                               throw Exception("Module host must be a modular program");
-                       comp.module_host = &*i;
-                       return;
-               }
-
-       throw KeyError("Unknown component", n);
+       IO::print("%s: Note: host is deprecated\n", get_source());
 }
 
 void Component::Loader::install_headers(const string &p)