forked from qt-creator/qt-creator
Android: get essential platforms and build-tools packages from BuiltWith
The commit 1180d5b8a270cfe7bd1c501c892d1c38ee7425de added information
about the ndk and android api level used at build time, ndk version has
already been accounted for in b73d6f3be8.
This now accounts for "platforms;android-xx" and "build-tools;xx.x.x"
packages.
Fixes: QTCREATORBUG-30404
Change-Id: I78b8885b88294404bc29c41a7b9491a331fcd709
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -126,6 +126,15 @@ static QString ndkPackageMarker()
|
|||||||
return QLatin1String(Constants::ndkPackageName) + ";";
|
return QLatin1String(Constants::ndkPackageName) + ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString platformsPackageMarker()
|
||||||
|
{
|
||||||
|
return QLatin1String(Constants::platformsPackageName) + ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString buildToolsPackageMarker()
|
||||||
|
{
|
||||||
|
return QLatin1String(Constants::buildToolsPackageName) + ";";
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// AndroidConfig
|
// AndroidConfig
|
||||||
@@ -951,15 +960,59 @@ bool AndroidConfig::sdkToolsOk() const
|
|||||||
return exists && writable && sdkToolsExist;
|
return exists && writable && sdkToolsExist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QStringList packagesExcludingBuiltWithDefaults(const QStringList &packages)
|
||||||
|
{
|
||||||
|
return Utils::filtered(packages, [] (const QString &p) {
|
||||||
|
return !p.startsWith(ndkPackageMarker()) && !p.startsWith(platformsPackageMarker())
|
||||||
|
&& !p.startsWith(buildToolsPackageMarker()); });
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString essentialBuiltWithBuildToolsPackage(int builtWithApiVersion)
|
||||||
|
{
|
||||||
|
// For build-tools, to avoid the situation of potentially having the essential packages
|
||||||
|
// invalidated whenever a new minor version is released, check if any version with major
|
||||||
|
// version matching builtWith apiVersion and use it as essential, otherwise use the any
|
||||||
|
// other one that has an minimum major version of builtWith apiVersion.
|
||||||
|
const BuildToolsList buildTools =
|
||||||
|
AndroidConfigurations::sdkManager()->filteredBuildTools(builtWithApiVersion);
|
||||||
|
const BuildToolsList apiBuildTools
|
||||||
|
= Utils::filtered(buildTools, [builtWithApiVersion] (const BuildTools *pkg) {
|
||||||
|
return pkg->revision().majorVersion() == builtWithApiVersion; });
|
||||||
|
const QString installedBuildTool = [apiBuildTools] () -> QString {
|
||||||
|
for (const BuildTools *pkg : apiBuildTools) {
|
||||||
|
if (pkg->state() == AndroidSdkPackage::Installed)
|
||||||
|
return pkg->sdkStylePath();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (installedBuildTool.isEmpty()) {
|
||||||
|
if (!apiBuildTools.isEmpty())
|
||||||
|
return apiBuildTools.first()->sdkStylePath();
|
||||||
|
else if (!buildTools.isEmpty())
|
||||||
|
return buildTools.first()->sdkStylePath();
|
||||||
|
// This means there's something wrong with sdkmanager, return a default version anyway
|
||||||
|
else
|
||||||
|
return buildToolsPackageMarker() + QString::number(builtWithApiVersion) + ".0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return installedBuildTool;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList AndroidConfig::essentialsFromQtVersion(const QtVersion &version) const
|
QStringList AndroidConfig::essentialsFromQtVersion(const QtVersion &version) const
|
||||||
{
|
{
|
||||||
if (auto androidQtVersion = dynamic_cast<const AndroidQtVersion *>(&version)) {
|
if (auto androidQtVersion = dynamic_cast<const AndroidQtVersion *>(&version)) {
|
||||||
bool ok;
|
bool ok;
|
||||||
const AndroidQtVersion::BuiltWith bw = androidQtVersion->builtWith(&ok);
|
const AndroidQtVersion::BuiltWith bw = androidQtVersion->builtWith(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
const QString ndkPackage = ndkPackageMarker() + bw.ndkVersion.toString();
|
QStringList builtWithPackages;
|
||||||
return QStringList(ndkPackage)
|
builtWithPackages.append(ndkPackageMarker() + bw.ndkVersion.toString());
|
||||||
+ packagesWithoutNdks(m_defaultSdkDepends.essentialPackages);
|
const QString apiVersion = QString::number(bw.apiVersion);
|
||||||
|
builtWithPackages.append(platformsPackageMarker() + "android-" + apiVersion);
|
||||||
|
builtWithPackages.append(essentialBuiltWithBuildToolsPackage(bw.apiVersion));
|
||||||
|
|
||||||
|
return builtWithPackages + packagesExcludingBuiltWithDefaults(
|
||||||
|
m_defaultSdkDepends.essentialPackages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ const Utils::Id AndroidAvdPath = "AndroidAvdPath";
|
|||||||
// SDK Tools
|
// SDK Tools
|
||||||
const char cmdlineToolsName[] = "cmdline-tools";
|
const char cmdlineToolsName[] = "cmdline-tools";
|
||||||
const char ndkPackageName[] = "ndk";
|
const char ndkPackageName[] = "ndk";
|
||||||
|
const char platformsPackageName[] = "platforms";
|
||||||
|
const char buildToolsPackageName[] = "build-tools";
|
||||||
|
|
||||||
// For AndroidQtVersion
|
// For AndroidQtVersion
|
||||||
const char ArmToolsDisplayName[] = "arm";
|
const char ArmToolsDisplayName[] = "arm";
|
||||||
|
|||||||
Reference in New Issue
Block a user