}
GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t):
- Tool(b, &a, t),
- version(0)
+ Tool(b, &a, t)
{
if(tag=="CC")
{
return result;
}
-void GnuCompiler::do_prepare()
+void GnuCompiler::do_prepare(ToolData &tool) const
{
- prepare_syspath();
- prepare_version();
+ tool.extra_data = 0U;
+ prepare_syspath(tool);
+ prepare_version(tool);
}
-void GnuCompiler::prepare_syspath()
+void GnuCompiler::prepare_syspath(ToolData &tool) const
{
bool path_found = false;
- const FS::Path &sysroot = build_info.sysroot;
+ const FS::Path &sysroot = tool.build_info.sysroot;
+ const std::string &tool_tag = static_cast<Tool &>(tool).get_tag();
- if(executable)
+ const FileTarget *exe = static_cast<Tool &>(tool).get_executable();
+ if(exe)
{
ExternalTask::Arguments argv;
- argv.push_back(executable->get_path().str());
+ argv.push_back(exe->get_path().str());
argv.push_back("-Wp,-v");
argv.push_back("-E");
if(tag=="CXX")
else if(record_path)
{
FS::Path path = strip(output.substr(start, newline-start));
- builder.get_logger().log("tools", "Got %s system path: %s", tag, path);
- system_path.push_back(path);
+ builder.get_logger().log("tools", "Got %s system path: %s", tool_tag, path);
+ tool.system_path.push_back(path);
}
start = newline+1;
}
if(!path_found)
{
- builder.get_logger().log("tools", "No %s system path found, using defaults", tag);
+ builder.get_logger().log("tools", "No %s system path found, using defaults", tool_tag);
+ const Architecture &arch = *static_cast<Tool &>(tool).get_architecture();
if(!sysroot.empty())
- system_path.push_back(sysroot/"usr/include");
- else if(architecture->is_native())
- system_path.push_back("/usr/include");
+ tool.system_path.push_back(sysroot/"usr/include");
+ else if(arch.is_native())
+ tool.system_path.push_back("/usr/include");
else
- system_path.push_back(format("/usr/%s/include", architecture->get_cross_prefix()));
+ tool.system_path.push_back(format("/usr/%s/include", arch.get_cross_prefix()));
}
}
-void GnuCompiler::prepare_version()
+void GnuCompiler::prepare_version(ToolData &tool) const
{
- if(!executable)
+ const FileTarget *exe = static_cast<Tool &>(tool).get_executable();
+ if(!exe)
return;
- string exe_path = executable->get_path().str();
- version = query_version("-dumpversion");
+ string exe_path = exe->get_path().str();
+ unsigned version = query_version(exe_path, "-dumpversion");
if(version>=0x70000)
- version = query_version("-dumpfullversion");
- builder.get_logger().log("tools", "%s version is %d.%d.%d", FS::basename(executable->get_path()), version>>16, (version>>8)&0xFF, version&0xFF);
+ {
+ unsigned v = query_version(exe_path, "-dumpfullversion");
+ if(v)
+ version = v;
+ }
+ tool.extra_data = version;
+ builder.get_logger().log("tools", "%s version is %d.%d.%d", FS::basename(exe->get_path()), version>>16, (version>>8)&0xFF, version&0xFF);
}
-unsigned GnuCompiler::query_version(const string &arg) const
+unsigned GnuCompiler::query_version(const string &exe_path, const string &arg) const
{
ExternalTask::Arguments argv;
- argv.push_back(executable->get_path().str());
+ argv.push_back(exe_path);
argv.push_back(arg);
builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
Task *GnuCompiler::_run(const ObjectFile &object)
{
- const GnuCompiler &tool = dynamic_cast<const GnuCompiler &>(*object.get_tool());
+ const Tool &tool = *object.get_tool();
const Architecture &arch = *tool.get_architecture();
ExternalTask::Arguments argv;
{
argv.push_back("-Wextra");
argv.push_back("-Wundef");
- if(tool.version>=0x80000)
+ unsigned version = tool.get_extra_data();
+ if(version>=0x80000)
argv.push_back("-Wno-cast-function-type");
}
if(binfo.warning_level>=3)