Android: Pull android debugging related files to a subdirectory

When building the project in QtCreator using the Debug configuration,
android deployment procedure pulls app_process from the device to
establish the debug environment. This operation litters the project
build directory with the libraries and executables that don't belong
to it. Instead of pulling the files to the root build directory, it's
better to isolate these files using subdirectory.

Fixes: QTCREATORBUG-29336
Fixes: QTBUG-113851
Fixes: QTBUG-111284
Change-Id: I32c3403dc5f79c42b1ff2bd676c2cf3ae8d43ec3
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Alexey Edelev
2023-06-28 19:17:24 +02:00
parent 627cb353f6
commit 1e81f206b0
5 changed files with 21 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ const char ANDROID_KIT_NDK[] = "Android.NDK";
const char ANDROID_KIT_SDK[] = "Android.SDK";
const char ANDROID_BUILD_DIRECTORY[] = "android-build";
const char ANDROID_APP_PROCESS_DIRECTORY[] = "android-app-process";
const char JAVA_EDITOR_ID[] = "java.editor";
const char JLS_SETTINGS_ID[] = "Java::JLSSettingsID";
const char JAVA_MIMETYPE[] = "text/x-java";

View File

@@ -138,7 +138,7 @@ void AndroidDebugSupport::start()
FilePath::removeDuplicates(solibSearchPath);
setSolibSearchPath(solibSearchPath);
qCDebug(androidDebugSupportLog).noquote() << "SoLibSearchPath: " << solibSearchPath;
setSymbolFile(buildDir.pathAppended("app_process"));
setSymbolFile(AndroidManager::androidAppProcessDir(target).pathAppended("app_process"));
setSkipExecutableValidation(true);
setUseExtendedRemote(true);
QString devicePreferredAbi = AndroidManager::apkDevicePreferredAbi(target);

View File

@@ -512,6 +512,13 @@ void AndroidDeployQtStep::runImpl(QPromise<bool> &promise)
itr.value().removeFile();
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) {
const FilePath parentDir = itr.value().parentDir();
if (!parentDir.ensureWritableDir()) {
const QString error = QString("Package deploy: Unable to create directory %1.")
.arg(parentDir.nativePath());
reportWarningOrError(error, Task::Error);
}
runCommand({m_adbPath,
AndroidDeviceInfo::adbSelector(m_serialNumber)
<< "pull" << itr.key() << itr.value().nativePath()});
@@ -528,7 +535,7 @@ void AndroidDeployQtStep::runImpl(QPromise<bool> &promise)
void AndroidDeployQtStep::gatherFilesToPull()
{
m_filesToPull.clear();
const FilePath buildDir = AndroidManager::buildDirectory(target());
const FilePath appProcessDir = AndroidManager::androidAppProcessDir(target());
if (!m_deviceInfo.isValid())
return;
@@ -538,16 +545,16 @@ void AndroidDeployQtStep::gatherFilesToPull()
const QString preferredAbi = AndroidManager::apkDevicePreferredAbi(target());
if (preferredAbi == ProjectExplorer::Constants::ANDROID_ABI_ARM64_V8A
|| preferredAbi == ProjectExplorer::Constants::ANDROID_ABI_X86_64) {
m_filesToPull["/system/bin/app_process64"] = buildDir / "app_process";
m_filesToPull["/system/bin/app_process64"] = appProcessDir / "app_process";
libDirName = "lib64";
linkerName = "linker64";
} else {
m_filesToPull["/system/bin/app_process32"] = buildDir / "app_process";
m_filesToPull["/system/bin/app_process"] = buildDir / "app_process";
m_filesToPull["/system/bin/app_process32"] = appProcessDir / "app_process";
m_filesToPull["/system/bin/app_process"] = appProcessDir / "app_process";
}
m_filesToPull["/system/bin/" + linkerName] = buildDir / linkerName;
m_filesToPull["/system/" + libDirName + "/libc.so"] = buildDir / "libc.so";
m_filesToPull["/system/bin/" + linkerName] = appProcessDir / linkerName;
m_filesToPull["/system/" + libDirName + "/libc.so"] = appProcessDir / "libc.so";
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr)
qCDebug(deployStepLog).noquote() << "Pulling file from device:" << itr.key()

View File

@@ -229,6 +229,11 @@ FilePath AndroidManager::androidBuildDirectory(const Target *target)
return buildDirectory(target) / Constants::ANDROID_BUILD_DIRECTORY;
}
FilePath AndroidManager::androidAppProcessDir(const Target *target)
{
return buildDirectory(target) / Constants::ANDROID_APP_PROCESS_DIRECTORY;
}
bool AndroidManager::isQt5CmakeProject(const ProjectExplorer::Target *target)
{
const QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(target->kit());

View File

@@ -74,6 +74,7 @@ public:
static bool isQt5CmakeProject(const ProjectExplorer::Target *target);
static Utils::FilePath androidBuildDirectory(const ProjectExplorer::Target *target);
static Utils::FilePath androidAppProcessDir(const ProjectExplorer::Target *target);
static Utils::FilePath buildDirectory(const ProjectExplorer::Target *target);
static Utils::FilePath manifestPath(const ProjectExplorer::Target *target);
static void setManifestPath(ProjectExplorer::Target *target, const Utils::FilePath &path);