X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsourcegenerator.cpp;h=f00b26bc8a5dc06bf1dddf2d0e79ac89ed171389;hb=5033a9de732963dfcadc42ad381df00b69cf624d;hp=c09e5c7d9527c3b60f17ce2bcef6069fac239144;hpb=6140518acb736f9020005245686bfbc5fca2d329;p=builder.git diff --git a/source/sourcegenerator.cpp b/source/sourcegenerator.cpp index c09e5c7..f00b26b 100644 --- a/source/sourcegenerator.cpp +++ b/source/sourcegenerator.cpp @@ -1,4 +1,5 @@ #include +#include #include "builder.h" #include "executable.h" #include "externaltask.h" @@ -23,6 +24,8 @@ Target *SourceGenerator::create_target(const list &sources, const stri { if(sources.size()!=1) throw invalid_argument("SourceGenerator::create_target"); + if(out_suffixes.empty()) + throw logic_error("No output suffixes"); TemplateFile &tmpl = dynamic_cast(*sources.front()); const Component *comp = tmpl.get_component(); @@ -44,19 +47,13 @@ Target *SourceGenerator::create_target(const list &sources, const stri else primary = target; } + else + throw runtime_error("No tool found for suffix "+*i); } return primary; } -void SourceGenerator::do_prepare() -{ - FS::Path exe_fn = package.get_source_directory()/command; - executable = builder.get_vfs().get_target(exe_fn); - if(!executable) - executable = new Executable(builder, exe_fn); -} - Task *SourceGenerator::run(const Target &target) const { const SourceFile &out_src = dynamic_cast(target); @@ -64,6 +61,7 @@ Task *SourceGenerator::run(const Target &target) const vector args; args.push_back(executable->get_path().str()); + args.insert(args.end(), arguments.begin(), arguments.end()); const Target::Dependencies &deps = target.get_dependencies(); for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i) @@ -77,16 +75,23 @@ Task *SourceGenerator::run(const Target &target) const SourceGenerator::Loader::Loader(SourceGenerator &sg): - DataFile::ObjectLoader(sg) + DataFile::ObjectLoader(sg), + ConditionalLoader(sg.package, format("%s/%s", sg.package.get_name(), sg.tag)) { + add("argument", &Loader::argument); add("command", &Loader::command); add("in_suffix", &Loader::in_suffix); add("out_suffix", &Loader::out_suffix); } +void SourceGenerator::Loader::argument(const string &a) +{ + obj.arguments.push_back(a); +} + void SourceGenerator::Loader::command(const string &c) { - obj.set_command(c); + obj.set_command((obj.package.get_source_directory()/c).str()); } void SourceGenerator::Loader::in_suffix(const string &s)