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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,6 +3,7 @@
#include "toolchainsettingsaccessor.h" #include "toolchainsettingsaccessor.h"
#include "devicesupport/devicemanager.h"
#include "projectexplorerconstants.h" #include "projectexplorerconstants.h"
#include "projectexplorertr.h" #include "projectexplorertr.h"
#include "toolchain.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: // Autodetect: Pass autodetected toolchains from user file so the information can be reused:
const Toolchains autodetectedUserFileTcs const Toolchains autodetectedUserFileTcs
= Utils::filtered(userFileTcs, &ToolChain::isAutoDetected); = Utils::filtered(userFileTcs, &ToolChain::isAutoDetected);
// FIXME: Use real device?
const Toolchains autodetectedTcs = // Autodect from system paths on the desktop device.
autoDetectToolChains(ToolchainDetector(autodetectedUserFileTcs, {}, {})); // 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: // merge tool chains and register those that we need to keep:
const ToolChainOperations ops = mergeToolChainLists(systemFileTcs, userFileTcs, autodetectedTcs); const ToolChainOperations ops = mergeToolChainLists(systemFileTcs, userFileTcs, autodetectedTcs);

View File

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