--- /dev/null
+#include <msp/path/utils.h>
+#include "buildinfo.h"
+#include "compile.h"
+#include "component.h"
+#include "package.h"
+
+using namespace std;
+using namespace Msp;
+
+Compile::Compile(Builder &b, const Path::Path &s, const Path::Path &o, const Component &c):
+ ExternalAction(b),
+ source(s),
+ object(o),
+ comp(c)
+{
+ string ext=Path::splitext(source.str()).ext;
+ const char *tool=0;
+ if(ext==".cpp" || ext==".cc")
+ {
+ tool="CXX";
+ argv.push_back("g++");
+ }
+ else
+ {
+ tool="CC";
+ argv.push_back("gcc");
+ }
+ argv.push_back("-c");
+
+ const BuildInfo &binfo=comp.get_build_info();
+ for(list<string>::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i)
+ argv.push_back(*i);
+ for(list<string>::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
+ argv.push_back("-I"+*i);
+ for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
+ argv.push_back("-D"+*i);
+
+ argv.push_back("-o");
+ argv.push_back(object.str());
+ argv.push_back(source.str());
+
+ Path::mkpath(object.subpath(0, object.size()-1), 0755);
+
+ announce(comp.get_package().get_name(), tool, relative(object.str(), comp.get_package().get_source()).str());
+
+ launch();
+}