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/helpmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <utils/environment.h>
|
||||||
#include <utils/pointeralgorithm.h>
|
#include <utils/pointeralgorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -64,6 +65,8 @@ CMakeToolManager::CMakeToolManager()
|
|||||||
QTC_ASSERT(!m_instance, return);
|
QTC_ASSERT(!m_instance, return);
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
|
|
||||||
|
qRegisterMetaType<QString *>();
|
||||||
|
|
||||||
d = new CMakeToolManagerPrivate;
|
d = new CMakeToolManagerPrivate;
|
||||||
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
||||||
this, &CMakeToolManager::saveCMakeTools);
|
this, &CMakeToolManager::saveCMakeTools);
|
||||||
@@ -177,6 +180,25 @@ void CMakeToolManager::updateDocumentation()
|
|||||||
Core::HelpManager::registerDocumentation(docs);
|
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)
|
void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath, const QString &detectionSource)
|
||||||
{
|
{
|
||||||
const Id id = Id::fromString(cmakePath.toUserOutput());
|
const Id id = Id::fromString(cmakePath.toUserOutput());
|
||||||
|
@@ -63,7 +63,11 @@ public:
|
|||||||
static void updateDocumentation();
|
static void updateDocumentation();
|
||||||
|
|
||||||
public slots:
|
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:
|
signals:
|
||||||
void cmakeAdded (const Utils::Id &id);
|
void cmakeAdded (const Utils::Id &id);
|
||||||
@@ -81,3 +85,5 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CMakeProjectManager
|
} // namespace CMakeProjectManager
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QString *)
|
||||||
|
@@ -545,19 +545,15 @@ void KitDetectorPrivate::autoDetectCMake()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
emit q->logOutput('\n' + tr("Searching CMake binary..."));
|
emit q->logOutput('\n' + tr("Searching CMake binary..."));
|
||||||
|
const FilePath deviceRoot = m_device->mapToGlobalPath({});
|
||||||
QString error;
|
QString error;
|
||||||
const QStringList candidates = {"cmake"};
|
const bool res = QMetaObject::invokeMethod(cmakeManager,
|
||||||
for (const QString &candidate : candidates) {
|
"autoDetectCMakeForDevice",
|
||||||
const FilePath cmake = m_device->searchExecutableInPath(candidate);
|
Q_ARG(Utils::FilePath, deviceRoot),
|
||||||
if (!cmake.isEmpty()) {
|
Q_ARG(QString, m_sharedId),
|
||||||
emit q->logOutput(tr("Found CMake binary: %1").arg(cmake.toUserOutput()));
|
Q_ARG(QString *, &error));
|
||||||
const bool res = QMetaObject::invokeMethod(cmakeManager,
|
QTC_CHECK(res);
|
||||||
"registerCMakeByPath",
|
emit q->logOutput(error);
|
||||||
Q_ARG(Utils::FilePath, cmake),
|
|
||||||
Q_ARG(QString, m_sharedId));
|
|
||||||
QTC_CHECK(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitDetectorPrivate::autoDetectDebugger()
|
void KitDetectorPrivate::autoDetectDebugger()
|
||||||
|
Reference in New Issue
Block a user