Android: deduce the NDK path of saved toolchains from compilerCommand()

The change 290840, made AndroidToolchain tied to an NDK location, but
when restoring a toolchain the NDK wasn't being assigned. This deduces
the NDK location from the toolchain compilerCommand().

Change-Id: I3cd936ac48570fadbec15ac1e13496706718c0ea
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Assam Boudjelthia
2020-02-25 12:31:25 +02:00
parent 351f39fb3b
commit 94a9528156
2 changed files with 12 additions and 4 deletions

View File

@@ -93,14 +93,22 @@ AndroidToolChain::~AndroidToolChain() = default;
bool AndroidToolChain::isValid() const
{
if (m_ndkLocation.isEmpty()) {
QStringList ndkParts(compilerCommand().toString().split("toolchains/llvm/prebuilt/"));
if (ndkParts.size() > 1) {
QString ndkLocation(ndkParts.first());
if (ndkLocation.endsWith('/'))
ndkLocation.chop(1);
m_ndkLocation = FilePath::fromString(ndkLocation);
}
}
const bool isChildofNdk = compilerCommand().isChildOf(m_ndkLocation);
// If we're restoring a toolchain we set NDK path ourselves so it's enough to check against SDK
const bool isChildofSdk = compilerCommand().isChildOf(
AndroidConfigurations::currentConfig().sdkLocation());
return ClangToolChain::isValid() && typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID
&& targetAbi().isValid()
&& (isChildofNdk || isChildofSdk)
&& targetAbi().isValid() && (isChildofNdk || isChildofSdk)
&& !originalTargetTriple().isEmpty();
}

View File

@@ -57,7 +57,7 @@ private:
friend class AndroidToolChainFactory;
Utils::FilePath m_ndkLocation;
mutable Utils::FilePath m_ndkLocation;
};
class AndroidToolChainFactory : public ProjectExplorer::ToolChainFactory