+
+ if(!path_found)
+ {
+ 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())
+ tool.system_path.push_back(sysroot/"usr/include");
+ else if(arch.is_native())
+ tool.system_path.push_back("/usr/include");
+ else
+ tool.system_path.push_back(format("/usr/%s/include", arch.get_cross_prefix()));
+ }
+}
+
+void GnuCompiler::prepare_version(ToolData &tool) const
+{
+ const FileTarget *exe = static_cast<Tool &>(tool).get_executable();
+ if(!exe)
+ return;
+
+ string exe_path = exe->get_path().str();
+ unsigned version = query_version(exe_path, "-dumpversion");
+ if(version>=0x70000)
+ {
+ 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 &exe_path, const string &arg) const
+{
+ ExternalTask::Arguments argv;
+ argv.push_back(exe_path);
+ argv.push_back(arg);
+
+ builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
+ try
+ {
+ string version_str = strip(ExternalTask::run_and_capture_output(argv));
+
+ vector<string> version_parts = split(version_str, '.');
+ unsigned ver = 0;
+ for(unsigned i=0; (i<3 && i<version_parts.size()); ++i)
+ ver |= lexical_cast<unsigned>(version_parts[i])<<(16-8*i);
+ return ver;
+ }
+ catch(const runtime_error &)
+ { }
+
+ return 0;