#include <msp/strings/lexicalcast.h>
#include "builder.h"
#include "component.h"
+#include "datafile.h"
#include "executable.h"
#include "file.h"
#include "header.h"
inst_list.push_back(ft);
}
}
+ else if(type==DATAFILE)
+ {
+ File *source;
+ if(Target *tgt=builder.get_target(files.front().str()))
+ source=dynamic_cast<File *>(tgt);
+ else
+ source=new File(builder, pkg, files.front());
+ ::DataFile *result=new ::DataFile(builder, *this, *source);
+ inst_list.push_back(result);
+ }
else
{
for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
LIBRARY,
PROGRAM,
MODULE,
+ DATAFILE,
TARBALL,
INSTALL
};
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2009 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include <msp/fs/dir.h>
+#include <msp/fs/utils.h>
+#include "builder.h"
+#include "component.h"
+#include "datacompile.h"
+#include "datafile.h"
+#include "file.h"
+#include "sourcepackage.h"
+
+using namespace Msp;
+
+DataCompile::DataCompile(Builder &b, ::DataFile &dfile):
+ ExternalAction(b)
+{
+ const Component &comp=dfile.get_component();
+
+ work_dir=comp.get_package().get_source();
+
+ argv.push_back("mspdatatool");
+ argv.push_back("-c");
+ argv.push_back("-b");
+
+ FS::Path opath=dfile.get_path();
+ argv.push_back("-o");
+ argv.push_back(relative(opath, work_dir).str());
+
+ FS::Path spath=dfile.get_source().get_path();
+ argv.push_back(relative(spath, work_dir).str());
+
+ if(!builder.get_dry_run())
+ FS::mkpath(FS::dirname(opath), 0755);
+
+ announce(comp.get_package().get_name(), "DATA", relative(opath, work_dir).str());
+
+ launch();
+}
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2009 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef DATACOMPILE_H_
+#define DATACOMPILE_H_
+
+#include "externalaction.h"
+
+class DataFile;
+
+class DataCompile: public ExternalAction
+{
+public:
+ DataCompile(Builder &, DataFile &);
+};
+
+#endif
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2009 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "component.h"
+#include "datacompile.h"
+#include "datafile.h"
+#include "file.h"
+#include "sourcepackage.h"
+
+DataFile::DataFile(Builder &b, const Component &c, File &s):
+ FileTarget(b, &c.get_package(), generate_target_path(c)),
+ component(c),
+ source(s)
+{
+ buildable=true;
+ add_depend(&source);
+}
+
+Action *DataFile::create_action()
+{
+ return new DataCompile(builder, *this);
+}
+
+Msp::FS::Path DataFile::generate_target_path(const Component &comp)
+{
+ return comp.get_package().get_out_dir()/(comp.get_name()+".dat");
+}
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2009 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef DATAFILE_H_
+#define DATAFILE_H_
+
+#include "filetarget.h"
+
+class Component;
+class File;
+
+class DataFile: public FileTarget
+{
+private:
+ const Component &component;
+ File &source;
+
+public:
+ DataFile(Builder &, const Component &, File &);
+
+ virtual const char *get_type() const { return "DataFile"; }
+ const Component &get_component() const { return component; }
+ File &get_source() const { return source; }
+
+private:
+ virtual Action *create_action();
+ static Msp::FS::Path generate_target_path(const Component &);
+};
+
+#endif
#include "builder.h"
#include "copy.h"
#include "executable.h"
+#include "datafile.h"
#include "header.h"
#include "install.h"
#include "package.h"
mid="lib";
else if(dynamic_cast<const PkgConfig *>(&tgt))
mid="lib/pkgconfig";
+ else if(dynamic_cast<const ::DataFile *>(&tgt))
+ mid="share/"+tgt.get_package()->get_name();
if(mid.empty())
throw InvalidParameterValue("Don't know where to install "+tgtname);
add("module", &Loader::component<Component::MODULE>);
add("headers", &Loader::component<Component::HEADERS>);
add("install", &Loader::component<Component::INSTALL>);
+ add("datafile", &Loader::component<Component::DATAFILE>);
add("tarball", &Loader::tarball);
add("tar_file", &Loader::tar_file);
}