TextEditor::Keywords CMakeTool::keywords() { if (m_functions.isEmpty()) { Utils::SynchronousProcessResponse response; response = run({ "--help-command-list" }); if (response.result == Utils::SynchronousProcessResponse::Finished) m_functions = response.stdOut().split('\n'); response = run({ "--help-commands" }); if (response.result == Utils::SynchronousProcessResponse::Finished) parseFunctionDetailsOutput(response.stdOut()); response = run({ "--help-property-list" }); if (response.result == Utils::SynchronousProcessResponse::Finished) m_variables = parseVariableOutput(response.stdOut()); response = run({ "--help-variable-list" }); if (response.result == Utils::SynchronousProcessResponse::Finished) { m_variables.append(parseVariableOutput(response.stdOut())); m_variables = Utils::filteredUnique(m_variables); Utils::sort(m_variables); } } return TextEditor::Keywords(m_variables, m_functions, m_functionArgs); }
void CMakeTool::fetchFromCapabilities() const { Utils::SynchronousProcessResponse response = run({ "-E", "capabilities" }, true); if (response.result != Utils::SynchronousProcessResponse::Finished) return; auto doc = QJsonDocument::fromJson(response.stdOut().toUtf8()); if (!doc.isObject()) return; const QVariantMap data = doc.object().toVariantMap(); m_hasServerMode = data.value("serverMode").toBool(); const QVariantList generatorList = data.value("generators").toList(); for (const QVariant &v : generatorList) { const QVariantMap gen = v.toMap(); m_generators.append(Generator(gen.value("name").toString(), gen.value("extraGenerators").toStringList(), gen.value("platformSupport").toBool(), gen.value("toolsetSupport").toBool())); } const QVariantMap versionInfo = data.value("version").toMap(); m_version.major = versionInfo.value("major").toInt(); m_version.minor = versionInfo.value("minor").toInt(); m_version.patch = versionInfo.value("patch").toInt(); m_version.fullVersion = versionInfo.value("string").toByteArray(); }
void CMakeTool::fetchGeneratorsFromHelp() const { Utils::SynchronousProcessResponse response = run({ "--help" }); if (response.result != Utils::SynchronousProcessResponse::Finished) return; bool inGeneratorSection = false; QHash<QString, QStringList> generatorInfo; const QStringList lines = response.stdOut().split('\n'); foreach (const QString &line, lines) { if (line.isEmpty()) continue; if (line == "Generators") { inGeneratorSection = true; continue; } if (!inGeneratorSection) continue; if (line.startsWith(" ") && line.at(3) != ' ') { int pos = line.indexOf('='); if (pos < 0) pos = line.length(); if (pos >= 0) { --pos; while (pos > 2 && line.at(pos).isSpace()) --pos; } if (pos > 2) { const QString fullName = line.mid(2, pos - 1); const int dashPos = fullName.indexOf(" - "); QString generator; QString extra; if (dashPos < 0) { generator = fullName; } else { extra = fullName.mid(0, dashPos); generator = fullName.mid(dashPos + 3); } QStringList value = generatorInfo.value(generator); if (!extra.isEmpty()) value.append(extra); generatorInfo.insert(generator, value); } } } // Populate genertor list: for (auto it = generatorInfo.constBegin(); it != generatorInfo.constEnd(); ++it) m_generators.append(Generator(it.key(), it.value())); }
static int updateVersionHelper(const QString &command) { Utils::SynchronousProcess process; Utils::SynchronousProcessResponse response = process.runBlocking(command, QStringList() << QLatin1String("--version")); if (response.result != Utils::SynchronousProcessResponse::Finished) return 0; // Astyle prints the version on stdout or stderr, depending on platform const int version = parseVersion(response.stdOut().trimmed()); if (version != 0) return version; return parseVersion(response.stdErr().trimmed()); }
ClangExecutableVersion clangExecutableVersion(const QString &executable) { const ClangExecutableVersion invalidVersion; // Sanity checks const QFileInfo fileInfo(executable); const bool isExecutableFile = fileInfo.isFile() && fileInfo.isExecutable(); if (!isExecutableFile) return invalidVersion; // Get version output Utils::Environment environment = Utils::Environment::systemEnvironment(); Utils::Environment::setupEnglishOutput(&environment); Utils::SynchronousProcess runner; runner.setEnvironment(environment.toStringList()); runner.setTimeoutS(10); // We would prefer "-dumpversion", but that one returns some old version number. const QStringList arguments(QLatin1String(("--version"))); const Utils::SynchronousProcessResponse response = runner.runBlocking(executable, arguments); if (response.result != Utils::SynchronousProcessResponse::Finished) return invalidVersion; const QString output = response.stdOut(); // Parse version output const QRegularExpression re(QLatin1String("clang version (\\d+)\\.(\\d+)\\.(\\d+)")); const QRegularExpressionMatch reMatch = re.match(output); if (re.captureCount() != 3) return invalidVersion; const QString majorString = reMatch.captured(1); bool convertedSuccessfully = false; const int major = majorString.toInt(&convertedSuccessfully); if (!convertedSuccessfully) return invalidVersion; const QString minorString = reMatch.captured(2); const int minor = minorString.toInt(&convertedSuccessfully); if (!convertedSuccessfully) return invalidVersion; const QString patchString = reMatch.captured(3); const int patch = patchString.toInt(&convertedSuccessfully); if (!convertedSuccessfully) return invalidVersion; return ClangExecutableVersion(major, minor, patch); }
void IosProbe::detectDeveloperPaths() { QString program = QLatin1String("/usr/bin/xcode-select"); QStringList arguments(QLatin1String("--print-path")); Utils::SynchronousProcess selectedXcode; selectedXcode.setTimeoutS(5); Utils::SynchronousProcessResponse response = selectedXcode.run(program, arguments); if (response.result != Utils::SynchronousProcessResponse::Finished) { qCWarning(probeLog) << QString::fromLatin1("Could not detect selected xcode with /usr/bin/xcode-select"); } else { QString path = response.stdOut(); path.chop(1); addDeveloperPath(path); } addDeveloperPath(QLatin1String("/Applications/Xcode.app/Contents/Developer")); }
void CMakeTool::fetchVersionFromVersionOutput() const { Utils::SynchronousProcessResponse response = run({ "--version" }); if (response.result != Utils::SynchronousProcessResponse::Finished) return; QRegularExpression versionLine("^cmake version ((\\d+).(\\d+).(\\d+).*)$"); const QString responseText = response.stdOut(); for (const QStringRef &line : responseText.splitRef(QLatin1Char('\n'))) { QRegularExpressionMatch match = versionLine.match(line); if (!match.hasMatch()) continue; m_version.major = match.captured(2).toInt(); m_version.minor = match.captured(3).toInt(); m_version.patch = match.captured(4).toInt(); m_version.fullVersion = match.captured(1).toUtf8(); break; } }