QList<AndroidToolChainFactory::AndroidToolChainInformation> AndroidToolChainFactory::toolchainPathsForNdk(const FileName &ndkPath) { QList<AndroidToolChainInformation> result; if (ndkPath.isEmpty()) return result; QRegExp versionRegExp(NDKGccVersionRegExp); FileName path = ndkPath; QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(), QStringList() << QLatin1String("*"), QDir::Dirs); while (it.hasNext()) { const QString &fileName = FileName::fromString(it.next()).fileName(); int idx = versionRegExp.indexIn(fileName); if (idx == -1) continue; for (const ToolChain::Language lang : { ToolChain::Language::Cxx, ToolChain::Language::C }) { AndroidToolChainInformation ati; ati.language = lang; ati.version = fileName.mid(idx + 1); QString platform = fileName.left(idx); ati.abi = AndroidConfig::abiForToolChainPrefix(platform); if (ati.abi.architecture() == Abi::UnknownArchitecture) // e.g. mipsel which is not yet supported continue; ati.compilerCommand = AndroidConfigurations::currentConfig().gccPath(ati.abi, lang, ati.version); result.append(ati); } } return result; }
RvctToolChain::RvctVersion RvctToolChain::version(const Utils::FileName &rvctPath) { RvctToolChain::RvctVersion v; QProcess armcc; armcc.start(rvctPath.toString(), QStringList(QLatin1String("--version_number"))); if (!armcc.waitForStarted()) { qWarning("Unable to run rvct binary '%s' when trying to determine version.", qPrintable(rvctPath.toUserOutput())); return v; } armcc.closeWriteChannel(); if (!armcc.waitForFinished()) { Utils::SynchronousProcess::stopProcess(armcc); qWarning("Timeout running rvct binary '%s' trying to determine version.", qPrintable(rvctPath.toUserOutput())); return v; } if (armcc.exitStatus() != QProcess::NormalExit) { qWarning("A crash occurred when running rvct binary '%s' trying to determine version.", qPrintable(rvctPath.toUserOutput())); return v; } QString versionLine = QString::fromLocal8Bit(armcc.readAllStandardOutput()); versionLine += QString::fromLocal8Bit(armcc.readAllStandardError()); QRegExp versionRegExp(QLatin1String("^(\\d)(\\d)0*([1-9]\\d*)"), Qt::CaseInsensitive); Q_ASSERT(versionRegExp.isValid()); if (versionRegExp.indexIn(versionLine) != -1) { v.majorVersion = versionRegExp.cap(1).toInt(); v.minorVersion = versionRegExp.cap(2).toInt(); v.build = versionRegExp.cap(3).toInt(); } return v; }
bool AndroidToolChain::fromMap(const QVariantMap &data) { if (!GccToolChain::fromMap(data)) return false; if (data.contains(QLatin1String(ANDROID_QT_VERSION_KEY))) { QString command = compilerCommand().toString(); QString ndkPath = AndroidConfigurations::currentConfig().ndkLocation().toString(); if (!command.startsWith(ndkPath)) return false; command = command.mid(ndkPath.length()); if (!command.startsWith(QLatin1String("/toolchains/"))) return false; command = command.mid(12); int index = command.indexOf(QLatin1Char('/')); if (index == -1) return false; command = command.left(index); QRegExp versionRegExp(NDKGccVersionRegExp); index = versionRegExp.indexIn(command); if (index == -1) return false; m_ndkToolChainVersion = command.mid(index + 1); QString platform = command.left(index); setTargetAbi(AndroidConfig::abiForToolChainPrefix(platform)); } else { m_ndkToolChainVersion = data.value(QLatin1String(ANDROID_NDK_TC_VERION)).toString(); } Abi abi = targetAbi(); m_secondaryToolChain = AndroidToolChainFactory::versionCompareLess(AndroidToolChainFactory::versionNumberFromString(m_ndkToolChainVersion), AndroidToolChainFactory::newestToolChainVersionForArch(abi)); return isValid(); }
QList<AndroidToolChainFactory::AndroidToolChainInformation> AndroidToolChainFactory::toolchainPathsForNdk(const Utils::FileName &ndkPath) { QList<AndroidToolChainInformation> result; if (ndkPath.isEmpty()) return result; QRegExp versionRegExp(NDKGccVersionRegExp); FileName path = ndkPath; QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(), QStringList() << QLatin1String("*"), QDir::Dirs); while (it.hasNext()) { const QString &fileName = QFileInfo(it.next()).fileName(); int idx = versionRegExp.indexIn(fileName); if (idx == -1) continue; AndroidToolChainInformation ati; ati.version = fileName.mid(idx + 1); QString platform = fileName.left(idx); ati.architecture = AndroidConfig::architectureForToolChainPrefix(platform); if (ati.architecture == Abi::UnknownArchitecture) // e.g. mipsel which is not yet supported continue; // AndroidToolChain *tc = new AndroidToolChain(arch, version, true); ati.compilerCommand = AndroidConfigurations::currentConfig().gccPath(ati.architecture, ati.version); // tc->setCompilerCommand(compilerPath); result.append(ati); } return result; }
QList<ToolChain *> AndroidToolChainFactory::autodetectToolChainsForNdk(const FileName &ndkPath, const QList<ToolChain *> &alreadyKnown) { QList<ToolChain *> result; if (ndkPath.isEmpty()) return result; QRegExp versionRegExp(NDKGccVersionRegExp); FileName path = ndkPath; QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(), QStringList() << QLatin1String("*"), QDir::Dirs); QHash<Abi, QList<AndroidToolChain *>> newestToolChainForArch; while (it.hasNext()) { const QString &fileName = FileName::fromString(it.next()).fileName(); int idx = versionRegExp.indexIn(fileName); if (idx == -1) continue; QString version = fileName.mid(idx + 1); QString platform = fileName.left(idx); Abi abi = AndroidConfig::abiForToolChainPrefix(platform); if (abi.architecture() == Abi::UnknownArchitecture) // e.g. mipsel which is not yet supported continue; QList<AndroidToolChain *> toolChainBundle; for (ToolChain::Language lang : { ToolChain::Language::Cxx, ToolChain::Language::C }) { FileName compilerPath = AndroidConfigurations::currentConfig().gccPath(abi, lang, version); AndroidToolChain *tc = findToolChain(compilerPath, lang, alreadyKnown); if (!tc) { tc = new AndroidToolChain(abi, version, lang, ToolChain::AutoDetection); tc->resetToolChain(compilerPath); } result.append(tc); toolChainBundle.append(tc); } auto it = newestToolChainForArch.constFind(abi); if (it == newestToolChainForArch.constEnd()) newestToolChainForArch.insert(abi, toolChainBundle); else if (versionCompareLess(it.value(), toolChainBundle)) newestToolChainForArch[abi] = toolChainBundle; } foreach (ToolChain *tc, result) { AndroidToolChain *atc = static_cast<AndroidToolChain *>(tc); atc->setSecondaryToolChain(!newestToolChainForArch.value(atc->targetAbi()).contains(atc)); }
QList<ToolChain *> AndroidToolChainFactory::autodetectToolChainsForNdk(const FileName &ndkPath, const QList<ToolChain *> &alreadyKnown) { QList<ToolChain *> result; if (ndkPath.isEmpty()) return result; QRegExp versionRegExp(NDKGccVersionRegExp); FileName path = ndkPath; QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(), QStringList("*"), QDir::Dirs); QHash<Abi, QList<AndroidToolChain *>> newestToolChainForArch; while (it.hasNext()) { const QString &fileName = FileName::fromString(it.next()).fileName(); int idx = versionRegExp.indexIn(fileName); if (idx == -1) continue; QString version = fileName.mid(idx + 1); QString platform = fileName.left(idx); Abi abi = AndroidConfig::abiForToolChainPrefix(platform); if (abi.architecture() == Abi::UnknownArchitecture) continue; QList<AndroidToolChain *> toolChainBundle; for (Core::Id lang : {ProjectExplorer::Constants::CXX_LANGUAGE_ID, ProjectExplorer::Constants::C_LANGUAGE_ID}) { FileName compilerPath = AndroidConfigurations::currentConfig().gccPath(abi, lang, version); AndroidToolChain *tc = findToolChain(compilerPath, lang, alreadyKnown); if (!tc || tc->originalTargetTriple().isEmpty()) { tc = new AndroidToolChain(abi, version, lang, ToolChain::AutoDetection); tc->resetToolChain(compilerPath); QTC_ASSERT(!tc->originalTargetTriple().isEmpty(), delete tc; continue); } result.append(tc); toolChainBundle.append(tc); } QTC_ASSERT(!toolChainBundle.isEmpty(), continue); auto it = newestToolChainForArch.constFind(abi); if (it == newestToolChainForArch.constEnd()) newestToolChainForArch.insert(abi, toolChainBundle); else if (versionCompareLess(it.value(), toolChainBundle)) newestToolChainForArch[abi] = toolChainBundle; }
QList<ToolChain *> AndroidToolChainFactory::createToolChainsForNdk(const Utils::FileName &ndkPath) { QList<ToolChain *> result; if (ndkPath.isEmpty()) return result; QRegExp versionRegExp(NDKGccVersionRegExp); FileName path = ndkPath; QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(), QStringList() << QLatin1String("*"), QDir::Dirs); QMap<Abi::Architecture, AndroidToolChain *> newestToolChainForArch; while (it.hasNext()) { const QString &fileName = QFileInfo(it.next()).fileName(); int idx = versionRegExp.indexIn(fileName); if (idx == -1) continue; QString version = fileName.mid(idx + 1); QString platform = fileName.left(idx); Abi::Architecture arch = AndroidConfig::architectureForToolChainPrefix(platform); if (arch == Abi::UnknownArchitecture) // e.g. mipsel which is not yet supported continue; AndroidToolChain *tc = new AndroidToolChain(arch, version, ToolChain::AutoDetection); FileName compilerPath = AndroidConfigurations::currentConfig().gccPath(arch, version); tc->setCompilerCommand(compilerPath); result.append(tc); QMap<Abi::Architecture, AndroidToolChain *>::const_iterator it = newestToolChainForArch.constFind(arch); if (it == newestToolChainForArch.constEnd()) newestToolChainForArch.insert(arch, tc); else if (versionCompareLess(it.value(), tc)) newestToolChainForArch[arch] = tc; } foreach (ToolChain *tc, result) { AndroidToolChain *atc = static_cast<AndroidToolChain *>(tc); if (newestToolChainForArch.value(atc->targetAbi().architecture()) != atc) atc->setSecondaryToolChain(true); }
void KPBinaryIface::setVersion(QString& version) { QRegExp versionRegExp("\\d*(\\.\\d+)*"); version.indexOf(versionRegExp); m_version = versionRegExp.capturedTexts()[0]; }
static int tryCheck(int write_fd, const QString &absFile) { KLibrary _handle(absFile); if (!_handle.load()) { kDebug(1433) << " - open failed with message " << _handle.errorString() << ", skipping " << endl; return 1; } // ask for name and description QString name = i18n("Unnamed plugin"); QString description; NPError (*func_GetValue)(void *, NPPVariable, void *) = (NPError(*)(void *, NPPVariable, void *)) _handle.resolveFunction("NP_GetValue"); if ( func_GetValue ) { // get name char *buf = 0; NPError err = func_GetValue( 0, NPPVpluginNameString, (void*)&buf ); if ( err==NPERR_NO_ERROR ) name = QString::fromLatin1( buf ); kDebug() << "name = " << name; // get name NPError nperr = func_GetValue( 0, NPPVpluginDescriptionString, (void*)&buf ); if ( nperr==NPERR_NO_ERROR ) description = QString::fromLatin1( buf ); kDebug() << "description = " << description; } else kWarning() << "Plugin doesn't implement NP_GetValue" ; // get mime description function pointer char* (*func_GetMIMEDescription)() = (char *(*)())_handle.resolveFunction("NP_GetMIMEDescription"); if ( !func_GetMIMEDescription ) { kDebug(1433) << " - no GetMIMEDescription, skipping"; _handle.unload(); return 1; } // ask for mime information QString mimeInfo = func_GetMIMEDescription(); if ( mimeInfo.isEmpty() ) { kDebug(1433) << " - no mime info returned, skipping"; _handle.unload(); return 1; } // remove version info, as it is not used at the moment QRegExp versionRegExp(";version=[^:]*:"); mimeInfo.replace( versionRegExp, ":"); if (!mimeInfo.isEmpty() && !mimeInfo.endsWith(';')) { mimeInfo += ';'; // XDG compliance } // unload plugin lib kDebug(1433) << " - unloading plugin"; _handle.unload(); // create a QDataStream for our IPC pipe (to send plugin info back to the parent) QFile stream_file; stream_file.open(write_fd, QIODevice::WriteOnly); QDataStream stream(&stream_file); // return the gathered info to the parent stream << name; stream << description; stream << mimeInfo; return 0; }