forked from qt-creator/qt-creator
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:
@@ -93,14 +93,22 @@ AndroidToolChain::~AndroidToolChain() = default;
|
|||||||
|
|
||||||
bool AndroidToolChain::isValid() const
|
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);
|
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(
|
const bool isChildofSdk = compilerCommand().isChildOf(
|
||||||
AndroidConfigurations::currentConfig().sdkLocation());
|
AndroidConfigurations::currentConfig().sdkLocation());
|
||||||
|
|
||||||
return ClangToolChain::isValid() && typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID
|
return ClangToolChain::isValid() && typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID
|
||||||
&& targetAbi().isValid()
|
&& targetAbi().isValid() && (isChildofNdk || isChildofSdk)
|
||||||
&& (isChildofNdk || isChildofSdk)
|
|
||||||
&& !originalTargetTriple().isEmpty();
|
&& !originalTargetTriple().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ private:
|
|||||||
|
|
||||||
friend class AndroidToolChainFactory;
|
friend class AndroidToolChainFactory;
|
||||||
|
|
||||||
Utils::FilePath m_ndkLocation;
|
mutable Utils::FilePath m_ndkLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AndroidToolChainFactory : public ProjectExplorer::ToolChainFactory
|
class AndroidToolChainFactory : public ProjectExplorer::ToolChainFactory
|
||||||
|
|||||||
Reference in New Issue
Block a user