3 This file is part of builder
4 Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/fs/dir.h>
9 #include <msp/fs/utils.h>
11 #include "buildinfo.h"
13 #include "component.h"
14 #include "objectfile.h"
15 #include "sourcefile.h"
16 #include "sourcepackage.h"
21 Compile::Compile(Builder &b, const ObjectFile &obj):
24 const Component &comp = obj.get_component();
26 work_dir = comp.get_package().get_source();
28 FS::Path spath = obj.get_source().get_path();
30 string ext = FS::extpart(spath.str());
32 if(ext==".cpp" || ext==".cc")
37 argv.push_back(builder.get_current_arch().get_tool(tool));
40 const BuildInfo &binfo = comp.get_build_info();
41 for(list<string>::const_iterator i=binfo.warnings.begin(); i!=binfo.warnings.end(); ++i)
42 argv.push_back("-W"+*i);
43 for(list<string>::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i)
45 for(list<string>::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
46 argv.push_back("-I"+*i);
47 for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
48 argv.push_back("-D"+*i);
50 FS::Path opath = obj.get_path();
52 argv.push_back(relative(opath, work_dir).str());
53 argv.push_back(relative(spath, work_dir).str());
55 if(!builder.get_dry_run())
56 FS::mkpath(FS::dirname(opath), 0755);
58 announce(comp.get_package().get_name(), tool, basename(opath));