#include <stdexcept>
#include <msp/fs/utils.h>
-#include <msp/strings/format.h>
#include "builder.h"
#include "component.h"
#include "datacollection.h"
void DataTool::do_prepare()
{
- executable = builder.get_vfs().find_binary("mspdatatool");
- if(!executable)
- builder.problem(string(), format("Can't find executable mspdatatool for tool %s", tag));
+ set_executable("mspdatatool");
}
Task *DataTool::run(const Target &tgt) const
#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
-#include <msp/strings/format.h>
#include <stdexcept>
#include "builder.h"
#include "component.h"
void GnuArchiver::do_prepare()
{
- string command = "ar";
- if(architecture->is_cross())
- command = format("%s-%s", architecture->get_cross_prefix(), command);
- executable = builder.get_vfs().find_binary(command);
+ set_executable("ar", true);
}
Task *GnuArchiver::run(const Target &target) const
void GnuCompiler::do_prepare()
{
- if(architecture->is_cross())
- command = format("%s-%s", architecture->get_cross_prefix(), command);
- executable = builder.get_vfs().find_binary(command);
- if(!executable)
- builder.problem(string(), format("Can't find executable %s for tool %s", command, tag));
+ set_executable(command, true);
}
Task *GnuCompiler::run(const Target &target) const
command = "g++";
else
throw invalid_argument("GnuLinker::Linker::Linker");
- if(architecture->is_cross())
- command = format("%s-%s", architecture->get_cross_prefix(), command);
- executable = builder.get_vfs().find_binary(command);
+
+ set_executable(command, true);
}
}
#include <cstdlib>
#include <msp/fs/utils.h>
#include <msp/strings/format.h>
-#include "architecture.h"
#include "builder.h"
#include "component.h"
#include "exportdefinitions.h"
void MingwDllTool::do_prepare()
{
- string command = "dlltool";
- if(architecture->is_cross())
- command = format("%s-%s", architecture->get_cross_prefix(), command);
- executable = builder.get_vfs().find_binary(command);
+ set_executable("dlltool", true);
}
Task *MingwDllTool::run(const Target &target) const
#include <algorithm>
+#include <msp/strings/format.h>
+#include "architecture.h"
+#include "builder.h"
#include "tool.h"
using namespace std;
+using namespace Msp;
Tool::Tool(Builder &b, const string &t):
builder(b),
do_prepare();
}
+void Tool::set_executable(const string &command, bool cross)
+{
+ if(cross && architecture->is_cross())
+ return set_executable(format("%s-%s", architecture->get_cross_prefix(), command), false);
+
+ executable = builder.get_vfs().find_binary(command);
+ if(!executable)
+ builder.problem(string(), format("Can't find executable %s for tool %s", command, tag));
+}
+
SubTool::SubTool(Tool &p):
Tool(p),
protected:
virtual void do_prepare() { }
+ /** Locates an executable for the tool from the VFS. If it isn't found, a
+ problem is reported. If cross is true and the architecture is not native,
+ a cross prefix is added to the command. */
+ void set_executable(const std::string &command, bool cross = false);
+
public:
/** Invokes the tool to build a target. This should not be called directly;
use Target::build() instead. */