1 #include <msp/core/error.h>
7 Component::Component(Package &p, Type t, const string &n):
17 Tries to resolve all references to packages.
19 void Component::resolve_refs()
21 for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
26 Prepares the build information for building.
28 void Component::create_build_info()
30 build_info.add(pkg.get_build_info());
32 for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
36 //i->get_package()->create_build_info();
37 build_info.add(i->get_package()->get_exported_binfo());
42 build_info.ldflags.push_back("-rdynamic");
43 build_info.libs.push_back("dl");
47 const PathList &host_src=module_host->get_sources();
48 for(PathList::const_iterator i=host_src.begin(); i!=host_src.end(); ++i)
49 build_info.incpath.push_back(i->str());
55 Component::Loader::Loader(Component &c):
58 add("source", &Loader::source);
59 add("install", &Component::install);
60 add("install_headers", &Component::install_headers);
61 add("build_info", &Loader::build_info);
62 add("require", &Loader::require);
63 add("modular", &Loader::modular);
64 add("host", &Loader::host);
67 void Component::Loader::source(const string &s)
69 comp.sources.push_back(comp.pkg.get_source()/s);
72 void Component::Loader::require(const string &n)
74 comp.requires.push_back(PackageRef(comp.pkg.get_builder(), n));
77 void Component::Loader::modular()
79 if(comp.type!=PROGRAM)
80 throw Msp::Exception("Only programs can be modular");
84 void Component::Loader::host(const string &n)
86 const ComponentList &comps=comp.pkg.get_components();
87 for(ComponentList::const_iterator i=comps.begin(); i!=comps.end(); ++i)
90 if(i->get_type()!=PROGRAM || !i->get_modular())
91 throw Msp::Exception("Module host must be a modular program");
96 throw Msp::Exception("Unknown component");
99 void Component::Loader::build_info()
101 load_sub(comp.build_info);