]> git.tdb.fi Git - builder.git/blobdiff - source/sourcegenerator.cpp
Support conditionals inside source generator definitions
[builder.git] / source / sourcegenerator.cpp
index c09e5c7d9527c3b60f17ce2bcef6069fac239144..76d6c892a20942647316b8c2eb8ac83629c215f0 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/fs/utils.h>
+#include <msp/strings/format.h>
 #include "builder.h"
 #include "executable.h"
 #include "externaltask.h"
@@ -49,14 +50,6 @@ Target *SourceGenerator::create_target(const list<Target *> &sources, const stri
        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<const SourceFile &>(target);
@@ -77,7 +70,8 @@ Task *SourceGenerator::run(const Target &target) const
 
 
 SourceGenerator::Loader::Loader(SourceGenerator &sg):
-       DataFile::ObjectLoader<SourceGenerator>(sg)
+       DataFile::ObjectLoader<SourceGenerator>(sg),
+       ConditionalLoader(sg.package, format("%s/%s", sg.package.get_name(), sg.tag))
 {
        add("command",    &Loader::command);
        add("in_suffix",  &Loader::in_suffix);
@@ -86,7 +80,7 @@ SourceGenerator::Loader::Loader(SourceGenerator &sg):
 
 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)