X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgnucompiler.cpp;h=a96f5a34d214faa47caa47936c25d17cd2727af8;hb=68ef01e3f94ba5d0297e7979551e7d9404906db7;hp=424a5b46c854ec9f85df8acce025b750f5c2a6d2;hpb=1009314aed27a555033e743f84a1e4347d0bad69;p=builder.git diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 424a5b4..a96f5a3 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -28,8 +28,7 @@ const char *cpus[] = } GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t): - Tool(b, &a, t), - version(0) + Tool(b, &a, t) { if(tag=="CC") { @@ -103,21 +102,23 @@ string GnuCompiler::create_build_signature(const BuildInfo &binfo) const return result; } -void GnuCompiler::do_prepare() +void GnuCompiler::do_prepare(ToolData &tool) const { - prepare_syspath(); - prepare_version(); + 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).get_tag(); - if(executable) + const FileTarget *exe = static_cast(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") @@ -145,8 +146,8 @@ void GnuCompiler::prepare_syspath() 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; } @@ -157,32 +158,35 @@ void GnuCompiler::prepare_syspath() 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).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).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); + version = query_version(exe_path, "-dumpfullversion"); + 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())); @@ -204,7 +208,7 @@ unsigned GnuCompiler::query_version(const string &arg) const Task *GnuCompiler::_run(const ObjectFile &object) { - const GnuCompiler &tool = dynamic_cast(*object.get_tool()); + const Tool &tool = *object.get_tool(); const Architecture &arch = *tool.get_architecture(); ExternalTask::Arguments argv; @@ -228,7 +232,8 @@ Task *GnuCompiler::_run(const ObjectFile &object) { 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)