+++ /dev/null
-#include <msp/fs/utils.h>
-#include <msp/strings/format.h>
-#include <msp/strings/utils.h>
-#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<ObjectFile *> &objs):
- FileTarget(b, c.get_package(), c.get_package().get_output_directory()/p),
- objects(objs)
-{
- component = &c;
- for(list<ObjectFile *>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
- add_dependency(**i);
-
- nested_build_sig = true;
- arch_in_build_sig = true;
-}
-
-void Binary::find_dependencies()
-{
- if(!component)
- return;
-
- list<const Component *> queue;
- list<Target *> dep_libs;
- set<string> missing_libs;
- queue.push_back(component);
- while(!queue.empty())
- {
- queue.erase(queue.begin());
-
- BuildInfo binfo;
- collect_build_info(binfo);
-
- for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
- {
- if(i->size()>10 && !i->compare(i->size()-10, 10, ".framework"))
- continue;
-
- 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<StaticLibrary *>(real))
- {
- dep_libs.push_back(stlib);
- if(stlib->get_component())
- queue.push_back(stlib->get_component());
- }
- else
- dep_libs.push_back(lib);
- }
- else if(missing_libs.insert(*i).second)
- problems.push_back(format("Required library %s not found", *i));
- }
- }
-
- /* Add only the last occurrence of each library to the actual dependencies.
- This ensures that static library ordering is correct. */
- for(list<Target *>::iterator i=dep_libs.begin(); i!=dep_libs.end(); ++i)
- {
- bool last = true;
- for(list<Target *>::iterator j=i; (last && j!=dep_libs.end()); ++j)
- last = (j==i || *j!=*i);
- if(last)
- add_dependency(**i);
- }
-}