From 6d6343061110a1a9d99b6a4cb99c9710d04e6d19 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 28 Nov 2022 16:47:15 +0100 Subject: [PATCH] Android: FilePath-ify RunnerWorker Change-Id: If8e8c2ba94047bbb48a2ae5fee68d4c12d952fd6 Reviewed-by: Reviewed-by: Artem Sokolovskii Reviewed-by: hjk --- src/plugins/android/androidrunnerworker.cpp | 27 +++++++++++---------- src/plugins/android/androidrunnerworker.h | 3 ++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index 36a36a486e1..8ea3742ac77 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -29,9 +29,6 @@ #include #include -#include -#include -#include #include #include #include @@ -172,14 +169,18 @@ static FilePath debugServer(bool useLldb, const Target *target) // The new, built-in LLDB. const QDir::Filters dirFilter = HostOsInfo::isWindowsHost() ? QDir::Files : QDir::Files|QDir::Executable; - QDirIterator it(prebuilt.toString(), dirFilter, QDirIterator::Subdirectories); - while (it.hasNext()) { - it.next(); - const QString filePath = it.filePath(); - if (filePath.endsWith(abiNeedle + "/lldb-server")) { - return FilePath::fromString(filePath); + FilePath lldbServer; + const auto handleLldbServerCandidate = [&abiNeedle, &lldbServer] (const FilePath &path) { + if (path.parentDir().fileName() == abiNeedle) { + lldbServer = path; + return false; } - } + return true; + }; + prebuilt.iterateDirectory(handleLldbServerCandidate, + {{"lldb-server"}, dirFilter, QDirIterator::Subdirectories}); + if (!lldbServer.isEmpty()) + return lldbServer; // Older: Find LLDB version. sdk_definitions.json contains something like "lldb;3.1". Use that. const QStringList packages = config.defaultEssentials(); @@ -281,7 +282,7 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa for (const QString &shellCmd : postFinishCmdList.toStringList()) m_afterFinishAdbCommands.append(QString("shell %1").arg(shellCmd)); - m_debugServerPath = debugServer(m_useLldb, target).toString(); + m_debugServerPath = debugServer(m_useLldb, target); qCDebug(androidRunWorkerLog).noquote() << "Device Serial:" << m_deviceSerialNumber << ", API level:" << m_apiLevel << ", Extra Start Args:" << m_amStartExtraArgs @@ -339,7 +340,7 @@ bool AndroidRunnerWorker::uploadDebugServer(const QString &debugServerFileName) }); // Copy gdbserver to temp location - if (!runAdb({"push", m_debugServerPath , tempDebugServerPath})) { + if (!runAdb({"push", m_debugServerPath.toString(), tempDebugServerPath})) { qCDebug(androidRunWorkerLog) << "Debug server upload to temp directory failed"; return false; } @@ -545,7 +546,7 @@ void AndroidRunnerWorker::asyncStartHelper() // e.g. on Android 8 with NDK 10e runAdb({"shell", "run-as", m_packageName, "chmod", "a+x", packageDir.trimmed()}); - if (!QFileInfo::exists(m_debugServerPath)) { + if (!m_debugServerPath.exists()) { QString msg = Tr::tr("Cannot find C++ debug server in NDK installation."); if (m_useLldb) msg += "\n" + Tr::tr("The lldb-server binary has not been found."); diff --git a/src/plugins/android/androidrunnerworker.h b/src/plugins/android/androidrunnerworker.h index 0bbb0ad43be..533a73f79f6 100644 --- a/src/plugins/android/androidrunnerworker.h +++ b/src/plugins/android/androidrunnerworker.h @@ -15,6 +15,7 @@ QT_BEGIN_NAMESPACE class QProcess; QT_END_NAMESPACE +namespace Utils { class FilePath; } namespace ProjectExplorer { class RunWorker; } namespace Android { @@ -100,7 +101,7 @@ private: int m_apiLevel = -1; QString m_extraAppParams; Utils::Environment m_extraEnvVars; - QString m_debugServerPath; + Utils::FilePath m_debugServerPath; // On build device, typically as part of ndk bool m_useAppParamsForQmlDebugger = false; };