ProjectExplorer: Run toolchain autodetection on startup

... explicitly only for the Desktop device. This was implicitly done in
some cases by assuming 'no device' == 'desktop'. Make that explicit now.

Change-Id: I2ce86702a9b5b795fb4832301a11a8c8b40e77ea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2023-04-17 10:12:53 +02:00
parent 3b76420e0f
commit cacc4aeede
7 changed files with 19 additions and 16 deletions

View File

@@ -15,6 +15,7 @@
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/gcctoolchain.h>
@@ -573,7 +574,7 @@ IosToolChainFactory::IosToolChainFactory()
Toolchains IosToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
if (detector.device)
if (detector.device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return {};
QList<ClangToolChain *> existingClangToolChains = clangToolChains(detector.alreadyKnown);

View File

@@ -35,10 +35,7 @@ Toolchains NimToolChainFactory::autoDetect(const ToolchainDetector &detector) co
{
Toolchains result;
IDevice::ConstPtr dev =
detector.device ? detector.device : DeviceManager::defaultDesktopDevice();
const FilePath compilerPath = dev->searchExecutableInPath("nim");
const FilePath compilerPath = detector.device->searchExecutableInPath("nim");
if (compilerPath.isEmpty())
return result;

View File

@@ -1040,10 +1040,9 @@ GccToolChainFactory::GccToolChainFactory()
Toolchains GccToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
// GCC is almost never what you want on macOS, but it is by default found in /usr/bin
if (HostOsInfo::isMacHost()
&& (!detector.device || detector.device->type() == Constants::DESKTOP_DEVICE_TYPE)) {
if (HostOsInfo::isMacHost() && detector.device->type() == Constants::DESKTOP_DEVICE_TYPE)
return {};
}
Toolchains tcs;
static const auto tcChecker = [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor
@@ -1086,7 +1085,7 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
{
const IDevice::ConstPtr device = detector.device;
const QFileInfo fi(compilerName);
if (device.isNull() && fi.isAbsolute() && fi.isFile())
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE && fi.isAbsolute() && fi.isFile())
return {FilePath::fromString(compilerName)};
QStringList nameFilters(compilerName);

View File

@@ -3,6 +3,7 @@
#include "msvctoolchain.h"
#include "devicesupport/idevice.h"
#include "gcctoolchain.h"
#include "msvcparser.h"
#include "projectexplorer.h"
@@ -1909,7 +1910,7 @@ static void detectCppBuildTools2015(Toolchains *list)
Toolchains MsvcToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
if (!detector.device.isNull()) {
if (detector.device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
// FIXME currently no support for msvc toolchains on a device
return {};
}
@@ -2024,7 +2025,7 @@ bool ClangClToolChainFactory::canCreate() const
Toolchains ClangClToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
if (!detector.device.isNull()) {
if (detector.device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
// FIXME currently no support for msvc toolchains on a device
return {};
}

View File

@@ -674,7 +674,9 @@ ToolchainDetector::ToolchainDetector(const Toolchains &alreadyKnown,
const IDevice::ConstPtr &device,
const FilePaths &searchPaths)
: alreadyKnown(alreadyKnown), device(device), searchPaths(searchPaths)
{}
{
QTC_CHECK(device);
}
BadToolchain::BadToolchain(const Utils::FilePath &filePath)
: BadToolchain(filePath, filePath.symLinkTarget(), filePath.lastModified())

View File

@@ -3,6 +3,7 @@
#include "toolchainsettingsaccessor.h"
#include "devicesupport/devicemanager.h"
#include "projectexplorerconstants.h"
#include "projectexplorertr.h"
#include "toolchain.h"
@@ -192,9 +193,11 @@ Toolchains ToolChainSettingsAccessor::restoreToolChains(QWidget *parent) const
// Autodetect: Pass autodetected toolchains from user file so the information can be reused:
const Toolchains autodetectedUserFileTcs
= Utils::filtered(userFileTcs, &ToolChain::isAutoDetected);
// FIXME: Use real device?
const Toolchains autodetectedTcs =
autoDetectToolChains(ToolchainDetector(autodetectedUserFileTcs, {}, {}));
// Autodect from system paths on the desktop device.
// The restriction is intentional to keep startup and automatic validation a limited effort
ToolchainDetector detector(autodetectedUserFileTcs, DeviceManager::defaultDesktopDevice(), {});
const Toolchains autodetectedTcs = autoDetectToolChains(detector);
// merge tool chains and register those that we need to keep:
const ToolChainOperations ops = mergeToolChainLists(systemFileTcs, userFileTcs, autodetectedTcs);

View File

@@ -96,7 +96,7 @@ static Toolchains doAutoDetect(const ToolchainDetector &detector)
if (!WebAssemblyEmSdk::isValid(sdk))
return {};
if (detector.device) {
if (detector.device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
// Only detect toolchains from the emsdk installation device
const FilePath deviceRoot = detector.device->rootPath();
if (deviceRoot.host() != sdk.host())