Target *SourceGenerator::create_target(const list<Target *> &sources, const string &)
{
- if(sources.size()!=1)
+ if(sources.empty())
throw invalid_argument("SourceGenerator::create_target");
+ if(out_suffixes.empty())
+ throw logic_error("No output suffixes");
TemplateFile &tmpl = dynamic_cast<TemplateFile &>(*sources.front());
const Component *comp = tmpl.get_component();
const SourcePackage *pkg = tmpl.get_package();
- string base = FS::basepart(FS::basename(tmpl.get_path()));
+ string base;
+ if(processing_unit==ONE_FILE)
+ base = FS::basepart(FS::basename(tmpl.get_path()));
+ else if(processing_unit==DIRECTORY)
+ base = FS::basename(FS::dirname(tmpl.get_path()));
+ else
+ base = comp->get_name();
Target *primary = 0;
for(list<string>::const_iterator i=out_suffixes.begin(); i!=out_suffixes.end(); ++i)
FS::Path fn = pkg->get_temp_directory()/comp->get_name()/(base+*i);
Target *target = tool->create_source(*comp, fn);
target->set_tool(*this);
- target->add_dependency(tmpl);
+ for(list<Target *>::const_iterator j=sources.begin(); j!=sources.end(); ++j)
+ target->add_dependency(**j);
if(primary)
primary->add_side_effect(*target);
else
primary = target;
}
+ else
+ throw runtime_error("No tool found for suffix "+*i);
}
return primary;
add("command", &Loader::command);
add("in_suffix", &Loader::in_suffix);
add("out_suffix", &Loader::out_suffix);
+ add("processing_unit", static_cast<ProcessingUnit SourceGenerator::*>(&SourceGenerator::processing_unit));
}
void SourceGenerator::Loader::argument(const string &a)