X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgnucompiler.cpp;h=4ee09ed5d97593c74c1130d509337ddec39b2ad0;hb=c5942a5c2fe7677a77b88254ee874bc09a5aa725;hp=086a1ed4a684984a06f2e8f3af4e761ea552619b;hpb=d10be3251b2b6605723c6c753a4c9a9ba35c9950;p=builder.git diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 086a1ed..4ee09ed 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,24 @@ 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(); + 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).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 +147,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,31 +159,39 @@ 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; - prepare_version("-dumpversion"); + string exe_path = exe->get_path().str(); + unsigned version = query_version(exe_path, "-dumpversion"); if(version>=0x70000) - prepare_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); } -void GnuCompiler::prepare_version(const string &arg) +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())); @@ -190,17 +200,20 @@ void GnuCompiler::prepare_version(const string &arg) string version_str = strip(ExternalTask::run_and_capture_output(argv)); vector version_parts = split(version_str, '.'); - version = 0; + unsigned ver = 0; for(unsigned i=0; (i<3 && i(version_parts[i])<<(16-8*i); + ver |= lexical_cast(version_parts[i])<<(16-8*i); + return ver; } catch(const runtime_error &) { } + + return 0; } 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; @@ -224,7 +237,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)