X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinarycomponent.cpp;h=49c4897ce69d7d25492ebe1521257dca04c77062;hb=HEAD;hp=0d3e253b3d5d4afc8714fe8e16eff45724ab348c;hpb=35f2979869bff43706f3163ec0979c7084aaa3c4;p=builder.git diff --git a/source/binarycomponent.cpp b/source/binarycomponent.cpp deleted file mode 100644 index 0d3e253..0000000 --- a/source/binarycomponent.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include -#include "binarycomponent.h" -#include "builder.h" -#include "filetarget.h" -#include "sourcepackage.h" -#include "tool.h" - -using namespace std; -using namespace Msp; - -BinaryComponent::BinaryComponent(SourcePackage &p, const string &n, Type t): - Component(p, n), - type(t) -{ } - -void BinaryComponent::create_build_info() -{ - Component::create_build_info(); - - for(UseList::const_iterator i=uses.begin(); i!=uses.end(); ++i) - { - /* Select an include path that contains all the sources for this and the - used component. This should produce a sensible result in most cases. */ - FS::Path base; - for(SourceList::const_iterator j=sources.begin(); j!=sources.end(); ++j) - base = base.empty() ? *j : FS::common_ancestor(base, *j); - const SourceList &use_sources = (*i)->get_sources(); - for(SourceList::const_iterator j=use_sources.begin(); j!=use_sources.end(); ++j) - base = FS::common_ancestor(base, *j); - build_info.incpath.push_back(base); - build_info.libs.push_back((*i)->get_name()); - if(!(*i)->get_install()) - { - build_info.libmodes[(*i)->get_name()] = BuildInfo::STATIC; - build_info.libpath.push_back((*i)->get_package().get_source_directory()); - } - } - - if(type==LIBRARY || type==MODULE) - if(build_info.libmode objs; - SourceList source_filenames = collect_source_files(); - for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) - { - string ext = FS::extpart(FS::basename(*i)); - Target *src = 0; - - Tool *gen = pkg_tools.get_tool_for_suffix(ext); - if(gen) - { - Target *tmpl = gen->create_source(*this, *i); - if(tmpl) - { - src = gen->create_target(*tmpl); - ext = FS::extpart(FS::basename(dynamic_cast(*src).get_path())); - } - } - - Tool *tool = toolchain.get_tool_for_suffix(ext, true); - if(tool) - { - if(!src) - src = tool->create_source(*this, *i); - if(!src) - continue; - - if(tool->accepts_suffix(ext)) - { - Target *obj = tool->create_target(*src); - objs.push_back(obj); - } - - if(type==LIBRARY && install) - { - if(dynamic_cast(src)->is_installable()) - build_graph.add_installed_target(*src); - - const Target::Dependencies &side_effects = src->get_side_effects(); - for(Target::Dependencies::const_iterator j=side_effects.begin(); j!=side_effects.end(); ++j) - if(dynamic_cast(*j)->is_installable()) - build_graph.add_installed_target(**j); - } - } - } - - Tool &linker = toolchain.get_tool("LINK"); - - list results; - if(type==LIBRARY) - { - Tool &archiver = toolchain.get_tool("AR"); - results.push_back(linker.create_target(objs, "shared")); - results.push_back(archiver.create_target(objs)); - } - else if(type==MODULE) - results.push_back(linker.create_target(objs, "shared")); - else - results.push_back(linker.create_target(objs)); - - for(list::const_iterator i=results.begin(); i!=results.end(); ++i) - { - build_graph.add_primary_target(**i); - if(install) - build_graph.add_installed_target(**i); - } -} - -BinaryComponent::Loader::Loader(BinaryComponent &c): - DerivedObjectLoader(c) -{ - add("use", &Loader::use); -} - -void BinaryComponent::Loader::use(const string &n) -{ - const BinaryComponent *comp = dynamic_cast(&obj.package.get_component(n)); - if(!comp || comp->type!=LIBRARY) - throw logic_error(n+" is not a library"); - - obj.uses.push_back(comp); -}