+++ /dev/null
-#include <msp/fs/dir.h>
-#include <msp/fs/utils.h>
-#include "builder.h"
-#include "component.h"
-#include "externaltask.h"
-#include "gnucompiler.h"
-#include "objectfile.h"
-#include "sourcefile.h"
-#include "sourcepackage.h"
-
-using namespace std;
-using namespace Msp;
-
-GnuCompiler::GnuCompiler(Builder &b, const string &t, const string &n):
- Tool(b, t),
- name(n)
-{ }
-
-Target *GnuCompiler::create_source(const Component &comp, const FS::Path &path) const
-{
- return new SourceFile(builder, comp, path);
-}
-
-Target *GnuCompiler::create_target(const list<Target *> &sources, const std::string &) const
-{
- if(sources.size()!=1)
- throw invalid_argument("GnuCCompiler::create_target");
- SourceFile &source = dynamic_cast<SourceFile &>(*sources.front());
- ObjectFile *obj = new ObjectFile(builder, *source.get_component(), source);
- obj->set_tool(*this);
- return obj;
-}
-
-Task *GnuCompiler::run(const Target &target) const
-{
- const ObjectFile &object = dynamic_cast<const ObjectFile &>(target);
- const Component &comp = object.get_component();
-
- vector<string> argv;
- argv.push_back(name);
- argv.push_back("-c");
-
- const BuildInfo &binfo = comp.get_build_info();
- for(list<string>::const_iterator i=binfo.warnings.begin(); i!=binfo.warnings.end(); ++i)
- argv.push_back("-W"+*i);
- 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);
-
- FS::Path obj_path = object.get_path();
- FS::Path src_path = object.get_source().get_path();
- FS::Path work_dir = comp.get_package().get_source();
-
- argv.push_back("-o");
- argv.push_back(relative(obj_path, work_dir).str());
- argv.push_back(relative(src_path, work_dir).str());
-
- if(!builder.get_dry_run())
- FS::mkpath(FS::dirname(obj_path), 0755);
-
- return new ExternalTask(argv, work_dir);
-}