3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/path/utils.h>
10 #include "buildinfo.h"
12 #include "component.h"
13 #include "objectfile.h"
14 #include "sourcepackage.h"
19 Compile::Compile(Builder &b, const ObjectFile &obj):
22 const Component &comp=obj.get_component();
24 const TargetList &deps=obj.get_depends();
25 Path spath=deps.front()->get_name();
27 string ext=splitext(spath.str()).ext;
29 if(ext==".cpp" || ext==".cc")
34 argv.push_back(builder.get_architecture(comp.get_package().get_arch()).get_tool(tool));
37 const BuildInfo &binfo=comp.get_build_info();
38 for(list<string>::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i)
40 for(list<string>::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
41 argv.push_back("-I"+*i);
42 for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
43 argv.push_back("-D"+*i);
45 Path opath=obj.get_name();
47 argv.push_back(opath.str());
48 argv.push_back(spath.str());
50 if(!builder.get_dry_run())
51 mkpath(opath.subpath(0, opath.size()-1), 0755);
53 announce(comp.get_package().get_name(), tool, relative(opath, comp.get_package().get_source()).str());