forked from qt-creator/qt-creator
Docker: Move some cmake detection logic to cmake plugin
This make the code better re-usable from other places that wish to put a cmake version into a new kit. Change-Id: I1ef7770a7f8efa36e88b2f3862b011fecd38de98 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/pointeralgorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -64,6 +65,8 @@ CMakeToolManager::CMakeToolManager()
|
||||
QTC_ASSERT(!m_instance, return);
|
||||
m_instance = this;
|
||||
|
||||
qRegisterMetaType<QString *>();
|
||||
|
||||
d = new CMakeToolManagerPrivate;
|
||||
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
||||
this, &CMakeToolManager::saveCMakeTools);
|
||||
@@ -177,6 +180,25 @@ void CMakeToolManager::updateDocumentation()
|
||||
Core::HelpManager::registerDocumentation(docs);
|
||||
}
|
||||
|
||||
void CMakeToolManager::autoDetectCMakeForDevice(const FilePath &deviceRoot,
|
||||
const QString &detectionSource,
|
||||
QString *logMessage)
|
||||
{
|
||||
QStringList messages;
|
||||
const FilePaths candidates = {FilePath::fromString("cmake").onDevice(deviceRoot)};
|
||||
const Environment env = deviceRoot.deviceEnvironment();
|
||||
for (const FilePath &candidate : candidates) {
|
||||
const FilePath cmake = candidate.searchOnDevice(env.path());
|
||||
if (!cmake.isEmpty()) {
|
||||
registerCMakeByPath(cmake, detectionSource);
|
||||
messages.append(tr("Found CMake binary: %1").arg(cmake.toUserOutput()));
|
||||
}
|
||||
}
|
||||
if (logMessage)
|
||||
*logMessage = messages.join('\n');
|
||||
}
|
||||
|
||||
|
||||
void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath, const QString &detectionSource)
|
||||
{
|
||||
const Id id = Id::fromString(cmakePath.toUserOutput());
|
||||
|
@@ -63,7 +63,11 @@ public:
|
||||
static void updateDocumentation();
|
||||
|
||||
public slots:
|
||||
void registerCMakeByPath(const Utils::FilePath &cmakePath, const QString &detectionSource);
|
||||
void autoDetectCMakeForDevice(const Utils::FilePath &deviceRoot,
|
||||
const QString &detectionSource,
|
||||
QString *logMessage);
|
||||
void registerCMakeByPath(const Utils::FilePath &cmakePath,
|
||||
const QString &detectionSource);
|
||||
|
||||
signals:
|
||||
void cmakeAdded (const Utils::Id &id);
|
||||
@@ -81,3 +85,5 @@ private:
|
||||
};
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
Q_DECLARE_METATYPE(QString *)
|
||||
|
@@ -545,19 +545,15 @@ void KitDetectorPrivate::autoDetectCMake()
|
||||
return;
|
||||
|
||||
emit q->logOutput('\n' + tr("Searching CMake binary..."));
|
||||
const FilePath deviceRoot = m_device->mapToGlobalPath({});
|
||||
QString error;
|
||||
const QStringList candidates = {"cmake"};
|
||||
for (const QString &candidate : candidates) {
|
||||
const FilePath cmake = m_device->searchExecutableInPath(candidate);
|
||||
if (!cmake.isEmpty()) {
|
||||
emit q->logOutput(tr("Found CMake binary: %1").arg(cmake.toUserOutput()));
|
||||
const bool res = QMetaObject::invokeMethod(cmakeManager,
|
||||
"registerCMakeByPath",
|
||||
Q_ARG(Utils::FilePath, cmake),
|
||||
Q_ARG(QString, m_sharedId));
|
||||
"autoDetectCMakeForDevice",
|
||||
Q_ARG(Utils::FilePath, deviceRoot),
|
||||
Q_ARG(QString, m_sharedId),
|
||||
Q_ARG(QString *, &error));
|
||||
QTC_CHECK(res);
|
||||
}
|
||||
}
|
||||
emit q->logOutput(error);
|
||||
}
|
||||
|
||||
void KitDetectorPrivate::autoDetectDebugger()
|
||||
|
Reference in New Issue
Block a user