Android: fix for retrieving the path to deployment file and build dir

The Android deployment file for CMake project was constructed based
on the main project target and thus was always expecting the file
to be under the build folder root path. This makes sure the correct
path to the output path is retrieved.

This practically different problems with running examples when the
main project is a Qt module, for both qmake and cmake.

Fixes: QTCREATORBUG-25793
Change-Id: I5fdedd94c7c4c84c351c28476ca14b0f95f99f22
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Assam Boudjelthia
2021-08-23 21:36:55 +03:00
parent dc71f32483
commit a2b6dba0bc
8 changed files with 77 additions and 32 deletions

View File

@@ -38,6 +38,7 @@
#include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/buildsystem.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
@@ -67,6 +68,9 @@ public:
QString nativeAndroidBuildPath() const;
Utils::FilePath androidBuildDirectory() const;
Utils::FilePath buildDirectory() const;
private:
bool init() final;
void setupOutputFormatter(OutputFormatter *formatter) final;
@@ -103,6 +107,8 @@ bool AndroidPackageInstallationStep::init()
cmd.addArgs(outerQuoted + " install", CommandLine::Raw);
processParameters()->setCommandLine(cmd);
// This is useful when running an example target from a Qt module project.
processParameters()->setWorkingDirectory(buildDirectory());
m_androidDirsToClean.clear();
// don't remove gradle's cache, it takes ages to rebuild it.
@@ -114,7 +120,7 @@ bool AndroidPackageInstallationStep::init()
QString AndroidPackageInstallationStep::nativeAndroidBuildPath() const
{
QString buildPath = buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
QString buildPath = androidBuildDirectory().toString();
if (HostOsInfo::isWindowsHost())
if (buildEnvironment().searchInPath("sh.exe").isEmpty())
buildPath = QDir::toNativeSeparators(buildPath);
@@ -122,6 +128,18 @@ QString AndroidPackageInstallationStep::nativeAndroidBuildPath() const
return buildPath;
}
FilePath AndroidPackageInstallationStep::androidBuildDirectory() const
{
return buildDirectory() / Constants::ANDROID_BUILD_DIRECTORY;
}
FilePath AndroidPackageInstallationStep::buildDirectory() const
{
if (const BuildSystem *bs = buildSystem())
return buildSystem()->buildTarget(target()->activeBuildKey()).workingDirectory;
return {};
}
void AndroidPackageInstallationStep::setupOutputFormatter(OutputFormatter *formatter)
{
formatter->addLineParser(new GnuMakeParser);