forked from qt-creator/qt-creator
AppMan: Partially FilePath-ify utility function
Change-Id: I3d90b8cf3b3bdd93e6ce5107f73a39037bf58346 Reviewed-by: Dominik Holland <dominik.holland@qt.io>
This commit is contained in:
@@ -6,57 +6,45 @@
|
|||||||
|
|
||||||
#include "appmanagerconstants.h"
|
#include "appmanagerconstants.h"
|
||||||
|
|
||||||
#include <projectexplorer/deployconfiguration.h>
|
|
||||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
|
||||||
#include <projectexplorer/kitaspects.h>
|
|
||||||
#include <projectexplorer/kitmanager.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
|
||||||
#include <projectexplorer/target.h>
|
|
||||||
|
|
||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
#include <qtsupport/qtkitaspect.h>
|
#include <qtsupport/qtkitaspect.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/osspecificaspects.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace QtSupport;
|
using namespace QtSupport;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace AppManager {
|
namespace AppManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
static QString getToolPathByQtVersion(const QtVersion *qtVersion,
|
static FilePath getToolPathByQtVersion(const QtVersion *qtVersion,
|
||||||
const QString &toolname = QString(Constants::APPMAN_PACKAGER))
|
const QString &toolname = QString(Constants::APPMAN_PACKAGER))
|
||||||
{
|
{
|
||||||
if (qtVersion) {
|
if (qtVersion) {
|
||||||
const auto toolExistsInDir = [&](const QDir &dir) {
|
const auto toolExistsInDir = [&toolname](const FilePath &dir) {
|
||||||
const FilePath toolFilePath = FilePath::fromString(dir.absolutePath())
|
return dir.pathAppended(getToolNameByDevice(toolname)).isFile();
|
||||||
.pathAppended(getToolNameByDevice(toolname));
|
|
||||||
return toolFilePath.isFile();
|
|
||||||
};
|
};
|
||||||
const QDir qtHostBinsDir(qtVersion->hostBinPath().toString());
|
|
||||||
|
const FilePath qtHostBinsDir = qtVersion->hostBinPath();
|
||||||
if (toolExistsInDir(qtHostBinsDir))
|
if (toolExistsInDir(qtHostBinsDir))
|
||||||
return qtHostBinsDir.absolutePath();
|
return qtHostBinsDir.absolutePath();
|
||||||
const QDir qtBinDir(qtVersion->binPath().toString());
|
|
||||||
|
const FilePath qtBinDir = qtVersion->binPath();
|
||||||
if (toolExistsInDir(qtBinDir))
|
if (toolExistsInDir(qtBinDir))
|
||||||
return qtBinDir.absolutePath();
|
return qtBinDir.absolutePath();
|
||||||
}
|
}
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getToolFilePath(const QString &toolname, const Kit *kit, const IDevice::ConstPtr &device)
|
QString getToolFilePath(const QString &toolname, const Kit *kit, const IDevice::ConstPtr &device)
|
||||||
{
|
{
|
||||||
const bool local = !device || device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
const bool local = !device || device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
||||||
const auto path = local ?
|
const FilePath path = local ? getToolPathByQtVersion(QtKitAspect::qtVersion(kit))
|
||||||
getToolPathByQtVersion(QtKitAspect::qtVersion(kit)) :
|
: FilePath(Constants::REMOTE_DEFAULT_BIN_PATH);
|
||||||
QString(Constants::REMOTE_DEFAULT_BIN_PATH);
|
const QString name = getToolNameByDevice(toolname, device);
|
||||||
const auto name = getToolNameByDevice(toolname, device);
|
return !path.isEmpty() ? path.pathAppended(name).toString() : name;
|
||||||
return !path.isEmpty() ?
|
|
||||||
QDir(path).absoluteFilePath(name) :
|
|
||||||
name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getToolNameByDevice(const QString &baseName, const QSharedPointer<const IDevice> &device)
|
QString getToolNameByDevice(const QString &baseName, const QSharedPointer<const IDevice> &device)
|
||||||
@@ -64,5 +52,4 @@ QString getToolNameByDevice(const QString &baseName, const QSharedPointer<const
|
|||||||
return OsSpecificAspects::withExecutableSuffix(device ? device->osType() : HostOsInfo::hostOs(), baseName);
|
return OsSpecificAspects::withExecutableSuffix(device ? device->osType() : HostOsInfo::hostOs(), baseName);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // AppManager::Internal
|
||||||
} // namespace AppManager
|
|
||||||
|
|||||||
@@ -7,11 +7,9 @@
|
|||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
|
||||||
namespace AppManager {
|
namespace AppManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
QString getToolNameByDevice(const QString &baseName, const QSharedPointer<const ProjectExplorer::IDevice> &device = nullptr);
|
QString getToolNameByDevice(const QString &baseName, const QSharedPointer<const ProjectExplorer::IDevice> &device = nullptr);
|
||||||
QString getToolFilePath(const QString &toolname, const ProjectExplorer::Kit *kit, const ProjectExplorer::IDevice::ConstPtr &device);
|
QString getToolFilePath(const QString &toolname, const ProjectExplorer::Kit *kit, const ProjectExplorer::IDevice::ConstPtr &device);
|
||||||
|
|
||||||
} // namespace Internal
|
} // AppManager::Internal
|
||||||
} // namespace AppManager
|
|
||||||
|
|||||||
Reference in New Issue
Block a user