X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdatatool.cpp;h=75ec2da7b750998d77395ba6ba57e8d77afd87a0;hb=HEAD;hp=b24de1396c22381ca279b9a27194f1cdc99e8541;hpb=aa053d637e8259755af7d2e4b510a242f4d29c7b;p=builder.git diff --git a/source/datatool.cpp b/source/datatool.cpp deleted file mode 100644 index b24de13..0000000 --- a/source/datatool.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include "builder.h" -#include "component.h" -#include "datacollection.h" -#include "datapack.h" -#include "datatool.h" -#include "datatransform.h" -#include "externaltask.h" -#include "sourcepackage.h" - -using namespace std; -using namespace Msp; - -DataTool::DataTool(Builder &b): - Tool(b, "DATA") -{ - set_command("mspdatatool"); - input_suffixes.push_back(".mdt"); -} - -Target *DataTool::create_source(const Component &comp, const FS::Path &path) const -{ - return new DataTransform(builder, comp, path); -} - -Target *DataTool::create_target(const vector &sources, const string &arg) -{ - if(arg=="collection") - { - if(sources.size()!=1) - throw invalid_argument("DataTool::create_target"); - DataTransform &source = dynamic_cast(*sources.front()); - DataCollection *coll = new DataCollection(builder, *source.get_component(), source); - coll->set_tool(*this); - return coll; - } - else if(arg=="pack") - { - if(sources.empty()) - throw invalid_argument("DataTool::create_target"); - vector files; - files.reserve(sources.size()); - for(Target *t: sources) - files.push_back(&dynamic_cast(*t)); - DataPack *pack = new DataPack(builder, *files.front()->get_component(), files); - pack->set_tool(*this); - return pack; - } - else - throw invalid_argument("DataTool::create_target"); -} - -string DataTool::create_build_signature(const BuildInfo &binfo) const -{ - string result = Tool::create_build_signature(binfo); - if(binfo.debug || binfo.optimize) - 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(); - FS::Path work_dir = comp.get_package().get_source_directory(); - - vector argv; - argv.push_back(executable->get_path().str()); - - argv.push_back("-o"); - argv.push_back(FS::relative(dynamic_cast(tgt).get_path(), work_dir).str()); - - BuildInfo binfo; - tgt.collect_build_info(binfo); - if(binfo.debug) - argv.push_back("-g"); - if(binfo.optimize>0) - { - argv.push_back("-b"); - if(binfo.optimize>1) - argv.push_back("-z"); - } - - if(const DataCollection *coll = dynamic_cast(&tgt)) - { - argv.push_back("-c"); - argv.push_back(FS::relative(coll->get_source().get_path(), work_dir).str()); - } - else if(const DataPack *pack = dynamic_cast(&tgt)) - { - argv.push_back("-p"); - for(const FileTarget *f: pack->get_files()) - argv.push_back(FS::relative(f->get_path(), work_dir).str()); - } - - return new ExternalTask(argv, work_dir); -}