1 #include <msp/fs/utils.h>
2 #include <msp/strings/format.h>
3 #include <msp/strings/utils.h>
7 #include "objectfile.h"
8 #include "sharedlibrary.h"
9 #include "sourcepackage.h"
10 #include "staticlibrary.h"
16 Binary::Binary(Builder &b, const FS::Path &p):
20 Binary::Binary(Builder &b, const Component &c, const string &p, const list<ObjectFile *> &objs):
21 FileTarget(b, c.get_package(), c.get_package().get_output_directory()/p),
25 for(list<ObjectFile *>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
28 nested_build_sig = true;
29 arch_in_build_sig = true;
32 void Binary::find_dependencies()
37 list<const Component *> queue;
38 list<Target *> dep_libs;
39 set<string> missing_libs;
40 queue.push_back(component);
43 const Component *c = queue.front();
44 queue.erase(queue.begin());
46 const BuildInfo &binfo = c->get_build_info();
47 for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
49 if(i->size()>10 && !i->compare(i->size()-10, 10, ".framework"))
52 BuildInfo::LibraryMode libmode = component->get_build_info().get_libmode_for(*i);
53 Target *lib = builder.get_vfs().find_library(*i, binfo.libpath, libmode);
56 Target *real = lib->get_real_target();
57 if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(real))
59 dep_libs.push_back(stlib);
60 if(stlib->get_component())
61 queue.push_back(stlib->get_component());
64 dep_libs.push_back(lib);
66 else if(missing_libs.insert(*i).second)
67 problems.push_back(format("Required library %s not found", *i));
71 /* Add only the last occurrence of each library to the actual dependencies.
72 This ensures that static library ordering is correct. */
73 for(list<Target *>::iterator i=dep_libs.begin(); i!=dep_libs.end(); ++i)
76 for(list<Target *>::iterator j=i; (last && j!=dep_libs.end()); ++j)
77 last = (j==i || *j!=*i);