forked from qt-creator/qt-creator
Docker: Simple Auto-detection for cmake binaries
Change-Id: Ia7e6f648c99c87786604cb8801c1408b9e231d3d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "cmaketoolsettingsaccessor.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
@@ -69,10 +71,14 @@ CMakeToolManager::CMakeToolManager()
|
||||
connect(this, &CMakeToolManager::cmakeAdded, this, &CMakeToolManager::cmakeToolsChanged);
|
||||
connect(this, &CMakeToolManager::cmakeRemoved, this, &CMakeToolManager::cmakeToolsChanged);
|
||||
connect(this, &CMakeToolManager::cmakeUpdated, this, &CMakeToolManager::cmakeToolsChanged);
|
||||
|
||||
setObjectName("CMakeToolManager");
|
||||
ExtensionSystem::PluginManager::addObject(this);
|
||||
}
|
||||
|
||||
CMakeToolManager::~CMakeToolManager()
|
||||
{
|
||||
ExtensionSystem::PluginManager::removeObject(this);
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -171,6 +177,20 @@ void CMakeToolManager::updateDocumentation()
|
||||
Core::HelpManager::registerDocumentation(docs);
|
||||
}
|
||||
|
||||
void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath)
|
||||
{
|
||||
const Id id = Id::fromString(cmakePath.toUserOutput());
|
||||
|
||||
CMakeTool *cmakeTool = findById(id);
|
||||
if (cmakeTool)
|
||||
return;
|
||||
|
||||
auto newTool = std::make_unique<CMakeTool>(CMakeTool::ManualDetection, id);
|
||||
newTool->setFilePath(cmakePath);
|
||||
newTool->setDisplayName(cmakePath.toUserOutput());
|
||||
registerCMakeTool(std::move(newTool));
|
||||
}
|
||||
|
||||
void CMakeToolManager::notifyAboutUpdate(CMakeTool *tool)
|
||||
{
|
||||
if (!tool || !Utils::contains(d->m_cmakeTools, tool))
|
||||
|
@@ -62,6 +62,9 @@ public:
|
||||
|
||||
static void updateDocumentation();
|
||||
|
||||
public slots:
|
||||
void registerCMakeByPath(const Utils::FilePath &cmakePath);
|
||||
|
||||
signals:
|
||||
void cmakeAdded (const Utils::Id &id);
|
||||
void cmakeRemoved (const Utils::Id &id);
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "dockerconstants.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
|
||||
@@ -373,6 +375,27 @@ void DockerDevice::autoDetectToolChains()
|
||||
}
|
||||
}
|
||||
|
||||
void DockerDevice::autoDetectCMake()
|
||||
{
|
||||
QObject *cmakeManager = ExtensionSystem::PluginManager::getObjectByName("CMakeToolManager");
|
||||
if (!cmakeManager)
|
||||
return;
|
||||
|
||||
QString error;
|
||||
QString source = "docker:" + d->m_data.imageId;
|
||||
const QStringList candidates = {"/usr/local/bin/cmake", "/usr/bin/cmake"};
|
||||
for (const QString &candidate : candidates) {
|
||||
const FilePath cmake = mapToGlobalPath(FilePath::fromString(candidate));
|
||||
QTC_CHECK(hasLocalFileAccess());
|
||||
if (cmake.isExecutableFile()) {
|
||||
const bool res = QMetaObject::invokeMethod(cmakeManager,
|
||||
"registerCMakeByPath",
|
||||
Q_ARG(Utils::FilePath, cmake));
|
||||
QTC_CHECK(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DockerDevice::tryCreateLocalFileAccess() const
|
||||
{
|
||||
if (!d->m_container.isEmpty())
|
||||
@@ -798,8 +821,11 @@ public:
|
||||
device->setupId(IDevice::ManuallyAdded, Utils::Id());
|
||||
device->setType(Constants::DOCKER_DEVICE_TYPE);
|
||||
device->setMachineType(IDevice::Hardware);
|
||||
|
||||
device->tryCreateLocalFileAccess();
|
||||
device->autoDetectToolChains();
|
||||
device->autoDetectQtVersion();
|
||||
device->autoDetectCMake();
|
||||
return device;
|
||||
}
|
||||
|
||||
|
@@ -87,6 +87,7 @@ public:
|
||||
const DockerDeviceData &data() const;
|
||||
void autoDetectQtVersion() const;
|
||||
void autoDetectToolChains();
|
||||
void autoDetectCMake();
|
||||
|
||||
void tryCreateLocalFileAccess() const;
|
||||
bool hasLocalFileAccess() const;
|
||||
|
Reference in New Issue
Block a user