// Copyright (C) 2019 Luxoft Sweden AB // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "appmanagerutilities.h" #include "appmanagerconstants.h" #include #include #include #include #include #include #include #include #include #include #include #include using namespace ProjectExplorer; using namespace QtSupport; using namespace Utils; namespace AppManager { namespace Internal { static QString getToolPathByQtVersion(const QtVersion *qtVersion, const QString &toolname = QString(Constants::APPMAN_PACKAGER)) { if (qtVersion) { const auto toolExistsInDir = [&](const QDir &dir) { const FilePath toolFilePath = FilePath::fromString(dir.absolutePath()) .pathAppended(getToolNameByDevice(toolname)); return toolFilePath.isFile(); }; const QDir qtHostBinsDir(qtVersion->hostBinPath().toString()); if (toolExistsInDir(qtHostBinsDir)) return qtHostBinsDir.absolutePath(); const QDir qtBinDir(qtVersion->binPath().toString()); if (toolExistsInDir(qtBinDir)) return qtBinDir.absolutePath(); } return QString(); } QString getToolFilePath(const QString &toolname, const Kit *kit, const IDevice::ConstPtr &device) { const bool local = !device || device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; const auto path = local ? getToolPathByQtVersion(QtKitAspect::qtVersion(kit)) : QString(Constants::REMOTE_DEFAULT_BIN_PATH); const auto name = getToolNameByDevice(toolname, device); return !path.isEmpty() ? QDir(path).absoluteFilePath(name) : name; } QString getToolNameByDevice(const QString &baseName, const QSharedPointer &device) { return OsSpecificAspects::withExecutableSuffix(device ? device->osType() : HostOsInfo::hostOs(), baseName); } } // namespace Internal } // namespace AppManager