1 #include <msp/core/error.h>
7 Component::Component(Package &p, Type t, const string &n):
18 Tries to resolve all references to packages.
20 void Component::resolve_refs()
22 for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
27 Prepares the build information for building.
29 void Component::create_build_info()
31 build_info.add(pkg.get_build_info());
33 for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
37 //i->get_package()->create_build_info();
38 build_info.add(i->get_package()->get_exported_binfo());
43 build_info.ldflags.push_back("-rdynamic");
44 build_info.libs.push_back("dl");
48 const PathList &host_src=module_host->get_sources();
49 for(PathList::const_iterator i=host_src.begin(); i!=host_src.end(); ++i)
50 build_info.incpath.push_back(i->str());
56 Component::Loader::Loader(Component &c):
59 add("source", &Loader::source);
60 add("install", &Component::install);
61 add("install_headers", &Component::install_headers);
62 add("build_info", &Loader::build_info);
63 add("require", &Loader::require);
64 add("modular", &Loader::modular);
65 add("host", &Loader::host);
66 add("default", &Component::deflt);
69 void Component::Loader::source(const string &s)
71 comp.sources.push_back(comp.pkg.get_source()/s);
74 void Component::Loader::require(const string &n)
76 comp.requires.push_back(PackageRef(comp.pkg.get_builder(), n));
79 void Component::Loader::modular()
81 if(comp.type!=PROGRAM)
82 throw Msp::Exception("Only programs can be modular");
86 void Component::Loader::host(const string &n)
88 const ComponentList &comps=comp.pkg.get_components();
89 for(ComponentList::const_iterator i=comps.begin(); i!=comps.end(); ++i)
92 if(i->get_type()!=PROGRAM || !i->get_modular())
93 throw Msp::Exception("Module host must be a modular program");
98 throw Msp::Exception("Unknown component");
101 void Component::Loader::build_info()
103 load_sub(comp.build_info);