]> git.tdb.fi Git - builder.git/blob - source/datacompile.cpp
Add support for building datafiles
[builder.git] / source / datacompile.cpp
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include <msp/fs/dir.h>
9 #include <msp/fs/utils.h>
10 #include "builder.h"
11 #include "component.h"
12 #include "datacompile.h"
13 #include "datafile.h"
14 #include "file.h"
15 #include "sourcepackage.h"
16
17 using namespace Msp;
18
19 DataCompile::DataCompile(Builder &b, ::DataFile &dfile):
20         ExternalAction(b)
21 {
22         const Component &comp=dfile.get_component();
23
24         work_dir=comp.get_package().get_source();
25
26         argv.push_back("mspdatatool");
27         argv.push_back("-c");
28         argv.push_back("-b");
29
30         FS::Path opath=dfile.get_path();
31         argv.push_back("-o");
32         argv.push_back(relative(opath, work_dir).str());
33
34         FS::Path spath=dfile.get_source().get_path();
35         argv.push_back(relative(spath, work_dir).str());
36
37         if(!builder.get_dry_run())
38                 FS::mkpath(FS::dirname(opath), 0755);
39
40         announce(comp.get_package().get_name(), "DATA", relative(opath, work_dir).str());
41
42         launch();
43 }