diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp index 93c00fb2ee6..4ba74298a9b 100644 --- a/src/plugins/ios/iosconfigurations.cpp +++ b/src/plugins/ios/iosconfigurations.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -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 existingClangToolChains = clangToolChains(detector.alreadyKnown); diff --git a/src/plugins/nim/project/nimtoolchainfactory.cpp b/src/plugins/nim/project/nimtoolchainfactory.cpp index 4301140865a..01ec5373b55 100644 --- a/src/plugins/nim/project/nimtoolchainfactory.cpp +++ b/src/plugins/nim/project/nimtoolchainfactory.cpp @@ -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; diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index b145ba56b6b..7212e24dd5d 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -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); diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 1eebcc68069..334777c24e2 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -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 {}; } diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index dfca4040fe3..8b8cfce2c80 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -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()) diff --git a/src/plugins/projectexplorer/toolchainsettingsaccessor.cpp b/src/plugins/projectexplorer/toolchainsettingsaccessor.cpp index 4152e9882ee..d7db868e856 100644 --- a/src/plugins/projectexplorer/toolchainsettingsaccessor.cpp +++ b/src/plugins/projectexplorer/toolchainsettingsaccessor.cpp @@ -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); diff --git a/src/plugins/webassembly/webassemblytoolchain.cpp b/src/plugins/webassembly/webassemblytoolchain.cpp index e38b00dac6d..4ee3eff5916 100644 --- a/src/plugins/webassembly/webassemblytoolchain.cpp +++ b/src/plugins/webassembly/webassemblytoolchain.cpp @@ -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())