X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcomponent.cpp;h=cb81f8420429b78bd79b4d3f70c6021db04e4e81;hb=2edc25f87590bd81808792c3c38cab5ae8b94eb3;hp=6bef63651d9ec88f42fbe639010bc9a7935cc73b;hpb=5622fc20f0be8bff0938d24f6f45d3ab384288ca;p=builder.git diff --git a/source/component.cpp b/source/component.cpp index 6bef636..cb81f84 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -14,12 +14,14 @@ Distributed under the LGPL #include "builder.h" #include "component.h" #include "executable.h" +#include "file.h" #include "header.h" #include "install.h" #include "objectfile.h" #include "sharedlibrary.h" #include "sourcepackage.h" #include "staticlibrary.h" +#include "tarball.h" #include "target.h" using namespace std; @@ -88,22 +90,43 @@ void Component::create_targets() const PathList files=collect_source_files(); - bool build_exe=(type!=HEADERS); - - list objs; - list inst_tgts; - for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) + if(type==TARBALL) { - string ext=FS::extpart(FS::basename(*i)); - if((ext==".cpp" || ext==".c") && build_exe) + string tarname=name; + if(name=="@src") + tarname=pkg.get_name()+"-"+pkg.get_version(); + TarBall *result=new TarBall(builder, pkg, tarname); + + if(name=="@src") { - SourceFile *src=new SourceFile(builder, this, i->str()); + const TargetMap &targets=builder.get_targets(); + for(TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) + if(i->second->get_package()==&pkg && !i->second->get_buildable()) + result->add_depend(i->second); + files.push_back(pkg.get_source()/"Build"); + } - // Compile sources - ObjectFile *obj=new ObjectFile(builder, *this, *src); - objs.push_back(obj); + for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) + { + FileTarget *ft; + if(Target *tgt=builder.get_target(i->str())) + ft=dynamic_cast(tgt); + else + ft=new File(builder, *i); + result->add_depend(ft); } - else if(ext==".h") + + Target *tarbls_tgt=builder.get_target("tarballs"); + tarbls_tgt->add_depend(result); + + return; + } + + list inst_list; + for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) + { + string ext=FS::extpart(FS::basename(*i)); + if(ext==".h") { FileTarget *hdr=dynamic_cast(builder.get_target(i->str())); if(!hdr) @@ -111,43 +134,46 @@ void Component::create_targets() const // Install headers if requested if(type==HEADERS && install) - inst_tgts.push_back(hdr); + inst_list.push_back(hdr); } } - if(build_exe) + if(type==PROGRAM || type==LIBRARY || type==MODULE) { - Binary *bin=0; - StaticLibrary *slib=0; - if(type==LIBRARY) + list objs; + for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i) { - bin=new SharedLibrary(builder, *this, objs); - slib=new StaticLibrary(builder, *this, objs); + string ext=FS::extpart(FS::basename(*i)); + if((ext==".cpp" || ext==".cc" || ext==".c")) + { + SourceFile *src=new SourceFile(builder, this, i->str()); + ObjectFile *obj=new ObjectFile(builder, *this, *src); + objs.push_back(obj); + } } - else - bin=new Executable(builder, *this, objs); - if(&pkg==builder.get_main_package() && deflt) + list results; + if(type==LIBRARY) { - def_tgt->add_depend(bin); - if(slib) def_tgt->add_depend(slib); + results.push_back(new SharedLibrary(builder, *this, objs)); + results.push_back(new StaticLibrary(builder, *this, objs)); } else - { - world->add_depend(bin); - if(slib) world->add_depend(slib); - } + results.push_back(new Executable(builder, *this, objs)); - if(install) + for(list::const_iterator i=results.begin(); i!=results.end(); ++i) { - inst_tgts.push_back(bin); - if(slib) - inst_tgts.push_back(slib); + if(&pkg==builder.get_main_package() && deflt) + def_tgt->add_depend(*i); + else + world->add_depend(*i); + if(install) + inst_list.push_back(*i); } } Target *inst_tgt=builder.get_target("install"); - for(list::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i) + for(list::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i) inst_tgt->add_depend(new Install(builder, pkg, **i)); }