]> git.tdb.fi Git - builder.git/blobdiff - source/datatool.cpp
Give targets the ability to gather their own build info
[builder.git] / source / datatool.cpp
index a956984a35deb6e9aa8b19eeca274fab4513db37..75ec2da7b750998d77395ba6ba57e8d77afd87a0 100644 (file)
@@ -1,6 +1,5 @@
 #include <stdexcept>
 #include <msp/fs/utils.h>
-#include <msp/strings/format.h>
 #include "builder.h"
 #include "component.h"
 #include "datacollection.h"
@@ -16,10 +15,7 @@ using namespace Msp;
 DataTool::DataTool(Builder &b):
        Tool(b, "DATA")
 {
-       executable = builder.get_vfs().find_binary("mspdatatool");
-       if(!executable)
-               builder.problem(string(), format("Can't find executable mspdatatool for tool %s", tag));
-
+       set_command("mspdatatool");
        input_suffixes.push_back(".mdt");
 }
 
@@ -28,7 +24,7 @@ Target *DataTool::create_source(const Component &comp, const FS::Path &path) con
        return new DataTransform(builder, comp, path);
 }
 
-Target *DataTool::create_target(const list<Target *> &sources, const string &arg) const
+Target *DataTool::create_target(const list<Target *> &sources, const string &arg)
 {
        if(arg=="collection")
        {
@@ -52,6 +48,20 @@ Target *DataTool::create_target(const list<Target *> &sources, const string &arg
                throw invalid_argument("DataTool::create_target");
 }
 
+string DataTool::create_build_signature(const BuildInfo &binfo) const
+{
+       string result;
+       if(binfo.debug)
+               result += 'g';
+       if(binfo.optimize>0)
+       {
+               result += 'b';
+               if(binfo.optimize>1)
+                       result += 'z';
+       }
+       return result;
+}
+
 Task *DataTool::run(const Target &tgt) const
 {
        const Component &comp = *tgt.get_component();
@@ -63,7 +73,8 @@ Task *DataTool::run(const Target &tgt) const
        argv.push_back("-o");
        argv.push_back(FS::relative(dynamic_cast<const FileTarget &>(tgt).get_path(), work_dir).str());
 
-       const BuildInfo &binfo = comp.get_build_info();
+       BuildInfo binfo;
+       tgt.collect_build_info(binfo);
        if(binfo.debug)
                argv.push_back("-g");
        if(binfo.optimize>0)