X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinary.cpp;h=fcf30f1d1fca03170f868ac7423ced7d37605683;hb=HEAD;hp=05a475d71bb4b02ff82c8333f06cc1c976f6d40e;hpb=3f1f24c02c5ef21791e5b24ff535d59969cd7625;p=builder.git diff --git a/source/binary.cpp b/source/binary.cpp deleted file mode 100644 index 05a475d..0000000 --- a/source/binary.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include -#include -#include -#include "binary.h" -#include "builder.h" -#include "component.h" -#include "objectfile.h" -#include "sharedlibrary.h" -#include "sourcepackage.h" -#include "staticlibrary.h" -#include "tool.h" - -using namespace std; -using namespace Msp; - -Binary::Binary(Builder &b, const FS::Path &p): - FileTarget(b, p) -{ } - -Binary::Binary(Builder &b, const Component &c, const string &p, const list &objs): - FileTarget(b, c.get_package(), c.get_package().get_out_dir()/p), - objects(objs) -{ - component = &c; - for(list::const_iterator i=objects.begin(); i!=objects.end(); ++i) - add_dependency(**i); -} - -void Binary::find_dependencies() -{ - if(!component) - return; - - list queue; - list dep_libs; - queue.push_back(component); - while(!queue.empty()) - { - const Component *c = queue.front(); - queue.erase(queue.begin()); - - const BuildInfo &binfo = c->get_build_info(); - for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i) - { - BuildInfo::LibraryMode libmode = component->get_build_info().get_libmode_for(*i); - Target *lib = builder.get_vfs().find_library(*i, binfo.libpath, libmode); - if(lib) - { - Target *real = lib->get_real_target(); - if(StaticLibrary *stlib = dynamic_cast(real)) - { - dep_libs.push_back(stlib); - if(stlib->get_component()) - queue.push_back(stlib->get_component()); - } - else - dep_libs.push_back(lib); - } - else - builder.problem(package->get_name(), format("Couldn't find library %s for %s", *i, name)); - } - } - - /* Add only the last occurrence of each library to the actual dependencies. - This ensures that static library ordering is correct. */ - for(list::iterator i=dep_libs.begin(); i!=dep_libs.end(); ++i) - { - bool last = true; - for(list::iterator j=i; (last && j!=dep_libs.end()); ++j) - last = (j==i || *j!=*i); - if(last) - add_dependency(**i); - } -} - -string Binary::create_build_signature() const -{ - set object_tools; - for(list::const_iterator i=objects.begin(); i!=objects.end(); ++i) - object_tools.insert((*i)->get_tool()); - - list sigs; - sigs.push_back(tool->create_build_signature(component->get_build_info())); - for(set::const_iterator i=object_tools.begin(); i!=object_tools.end(); ++i) - sigs.push_back((*i)->create_build_signature(component->get_build_info())); - sigs.sort(); - - return join(sigs.begin(), sigs.end(), ";"); -}