diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 92eb11076a6..409b05db904 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -1148,8 +1148,7 @@ void AndroidConfigurations::registerNewToolchains() const Toolchains existingAndroidToolchains = ToolchainManager::toolchains(Utils::equal(&Toolchain::typeId, Id(Constants::ANDROID_TOOLCHAIN_TYPEID))); - const Toolchains newToolchains = AndroidToolchainFactory::autodetectToolchains( - existingAndroidToolchains); + const Toolchains newToolchains = autodetectToolchains(existingAndroidToolchains); for (Toolchain *tc : newToolchains) ToolchainManager::registerToolchain(tc); @@ -1310,9 +1309,8 @@ void AndroidConfigurations::registerCustomToolchainsAndDebuggers() const FilePaths customNdks = FileUtils::toFilePathList(currentConfig().getCustomNdkList()); const Toolchains customToolchains - = AndroidToolchainFactory::autodetectToolchainsFromNdks(existingAndroidToolchains, - customNdks, - true); + = autodetectToolchainsFromNdks(existingAndroidToolchains, customNdks, true); + for (Toolchain *tc : customToolchains) { ToolchainManager::registerToolchain(tc); const auto androidToolchain = static_cast(tc); diff --git a/src/plugins/android/androidtoolchain.cpp b/src/plugins/android/androidtoolchain.cpp index 72066b63c64..a89926235c5 100644 --- a/src/plugins/android/androidtoolchain.cpp +++ b/src/plugins/android/androidtoolchain.cpp @@ -134,14 +134,6 @@ GccToolchain::DetectedAbisResult AndroidToolchain::detectSupportedAbis() const // AndroidToolchainFactory -AndroidToolchainFactory::AndroidToolchainFactory() -{ - setDisplayName(Tr::tr("Android Clang")); - setSupportedToolchainType(Constants::ANDROID_TOOLCHAIN_TYPEID); - setSupportedLanguages({ProjectExplorer::Constants::CXX_LANGUAGE_ID}); - setToolchainConstructor([] { return new AndroidToolchain; }); -} - static FilePath clangPlusPlusPath(const FilePath &clangPath) { return clangPath.parentDir().pathAppended(clangPath.baseName() + "++").withExecutableSuffix(); @@ -166,13 +158,7 @@ static FilePaths uniqueNdksForCurrentQtVersions() return uniqueNdks; } -ToolchainList AndroidToolchainFactory::autodetectToolchains(const ToolchainList &alreadyKnown) -{ - const QList uniqueNdks = uniqueNdksForCurrentQtVersions(); - return autodetectToolchainsFromNdks(alreadyKnown, uniqueNdks); -} - -ToolchainList AndroidToolchainFactory::autodetectToolchainsFromNdks( +ToolchainList autodetectToolchainsFromNdks( const ToolchainList &alreadyKnown, const QList &ndkLocations, const bool isCustom) @@ -248,6 +234,24 @@ ToolchainList AndroidToolchainFactory::autodetectToolchainsFromNdks( return result; } +ToolchainList autodetectToolchains(const ToolchainList &alreadyKnown) +{ + const QList uniqueNdks = uniqueNdksForCurrentQtVersions(); + return autodetectToolchainsFromNdks(alreadyKnown, uniqueNdks); +} + +class AndroidToolchainFactory final : public ToolchainFactory +{ +public: + AndroidToolchainFactory() + { + setDisplayName(Tr::tr("Android Clang")); + setSupportedToolchainType(Constants::ANDROID_TOOLCHAIN_TYPEID); + setSupportedLanguages({ProjectExplorer::Constants::CXX_LANGUAGE_ID}); + setToolchainConstructor([] { return new AndroidToolchain; }); + } +}; + void setupAndroidToolchain() { static AndroidToolchainFactory theAndroidToolchainFactory; diff --git a/src/plugins/android/androidtoolchain.h b/src/plugins/android/androidtoolchain.h index 8e8551e141b..f336bc257b8 100644 --- a/src/plugins/android/androidtoolchain.h +++ b/src/plugins/android/androidtoolchain.h @@ -14,6 +14,7 @@ using ToolchainList = QList; class AndroidToolchain : public ProjectExplorer::GccToolchain { public: + explicit AndroidToolchain(); ~AndroidToolchain() override; bool isValid() const override; @@ -30,32 +31,13 @@ protected: DetectedAbisResult detectSupportedAbis() const override; private: - explicit AndroidToolchain(); - - friend class AndroidToolchainFactory; - mutable Utils::FilePath m_ndkLocation; }; -class AndroidToolchainFactory : public ProjectExplorer::ToolchainFactory -{ -public: - AndroidToolchainFactory(); - - class AndroidToolchainInformation - { - public: - Utils::Id language; - Utils::FilePath compilerCommand; - ProjectExplorer::Abi abi; - QString version; - }; - - static ToolchainList autodetectToolchains(const ToolchainList &alreadyKnown); - static ToolchainList autodetectToolchainsFromNdks(const ToolchainList &alreadyKnown, - const QList &ndkLocations, - const bool isCustom = false); -}; +ToolchainList autodetectToolchains(const ToolchainList &alreadyKnown); +ToolchainList autodetectToolchainsFromNdks(const ToolchainList &alreadyKnown, + const QList &ndkLocations, + const bool isCustom = false); void setupAndroidToolchain(); diff --git a/src/plugins/projectexplorer/gcctoolchain.h b/src/plugins/projectexplorer/gcctoolchain.h index cdf6206f3fc..a875b7cb4b6 100644 --- a/src/plugins/projectexplorer/gcctoolchain.h +++ b/src/plugins/projectexplorer/gcctoolchain.h @@ -84,13 +84,13 @@ public: bool matchesCompilerCommand(const Utils::FilePath &command) const override; void setPriority(int priority) { m_priority = priority; } + void setOriginalTargetTriple(const QString &targetTriple); protected: using CacheItem = QPair; using GccCache = QVector; void setSupportedAbis(const Abis &abis); - void setOriginalTargetTriple(const QString &targetTriple); void setInstallDir(const Utils::FilePath &installDir); void setMacroCache(const QStringList &allCxxflags, const Macros ¯oCache) const; Macros macroCache(const QStringList &allCxxflags) const; @@ -150,7 +150,6 @@ private: friend class Internal::GccToolchainConfigWidget; friend class Internal::GccToolchainFactory; - friend class ToolchainFactory; // "resolved" on macOS from /usr/bin/clang(++) etc to /usr/bin/clang(++) // which is used for comparison with matchesCompilerCommand