forked from qt-creator/qt-creator
Android: Allow users to select which NDK to use for kits
This adds a "Make Default" button next to the NDKs list view. The default NDK version is then used to override the NDK version for all Qt versions in the sdk_definitions.json. Fixes: QTCREATORBUG-21755 Fixes: QTCREATORBUG-22389 Fixes: QTCREATORBUG-24248 Fixes: QTCREATORBUG-26281 Change-Id: I460daafdd7f2d6380c0114bcd14cb0c46226d516 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
@@ -108,6 +108,7 @@ namespace {
|
|||||||
const QLatin1String SettingsGroup("AndroidConfigurations");
|
const QLatin1String SettingsGroup("AndroidConfigurations");
|
||||||
const QLatin1String SDKLocationKey("SDKLocation");
|
const QLatin1String SDKLocationKey("SDKLocation");
|
||||||
const QLatin1String CustomNdkLocationsKey("CustomNdkLocations");
|
const QLatin1String CustomNdkLocationsKey("CustomNdkLocations");
|
||||||
|
const QLatin1String DefaultNdkLocationKey("DefaultNdkLocation");
|
||||||
const QLatin1String SdkFullyConfiguredKey("AllEssentialsInstalled");
|
const QLatin1String SdkFullyConfiguredKey("AllEssentialsInstalled");
|
||||||
const QLatin1String SDKManagerToolArgsKey("SDKManagerToolArgs");
|
const QLatin1String SDKManagerToolArgsKey("SDKManagerToolArgs");
|
||||||
const QLatin1String OpenJDKLocationKey("OpenJDKLocation");
|
const QLatin1String OpenJDKLocationKey("OpenJDKLocation");
|
||||||
@@ -226,6 +227,8 @@ void AndroidConfig::load(const QSettings &settings)
|
|||||||
QStringList({"-netdelay", "none", "-netspeed", "full"})).toStringList();
|
QStringList({"-netdelay", "none", "-netspeed", "full"})).toStringList();
|
||||||
m_sdkLocation = FilePath::fromUserInput(settings.value(SDKLocationKey).toString()).cleanPath();
|
m_sdkLocation = FilePath::fromUserInput(settings.value(SDKLocationKey).toString()).cleanPath();
|
||||||
m_customNdkList = settings.value(CustomNdkLocationsKey).toStringList();
|
m_customNdkList = settings.value(CustomNdkLocationsKey).toStringList();
|
||||||
|
m_defaultNdk =
|
||||||
|
FilePath::fromUserInput(settings.value(DefaultNdkLocationKey).toString()).cleanPath();
|
||||||
m_sdkManagerToolArgs = settings.value(SDKManagerToolArgsKey).toStringList();
|
m_sdkManagerToolArgs = settings.value(SDKManagerToolArgsKey).toStringList();
|
||||||
m_openJDKLocation = FilePath::fromString(settings.value(OpenJDKLocationKey).toString());
|
m_openJDKLocation = FilePath::fromString(settings.value(OpenJDKLocationKey).toString());
|
||||||
m_openSslLocation = FilePath::fromString(settings.value(OpenSslPriLocationKey).toString());
|
m_openSslLocation = FilePath::fromString(settings.value(OpenSslPriLocationKey).toString());
|
||||||
@@ -246,6 +249,11 @@ void AndroidConfig::load(const QSettings &settings)
|
|||||||
// persistent settings
|
// persistent settings
|
||||||
}
|
}
|
||||||
m_customNdkList.removeAll("");
|
m_customNdkList.removeAll("");
|
||||||
|
if (!m_defaultNdk.isEmpty() && ndkVersion(m_defaultNdk).isNull()) {
|
||||||
|
if (avdConfigLog().isDebugEnabled())
|
||||||
|
qCDebug(avdConfigLog) << "Clearing invalid default NDK setting:" << m_defaultNdk.path();
|
||||||
|
m_defaultNdk.clear();
|
||||||
|
}
|
||||||
parseDependenciesJson();
|
parseDependenciesJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +266,7 @@ void AndroidConfig::save(QSettings &settings) const
|
|||||||
// user settings
|
// user settings
|
||||||
settings.setValue(SDKLocationKey, m_sdkLocation.toString());
|
settings.setValue(SDKLocationKey, m_sdkLocation.toString());
|
||||||
settings.setValue(CustomNdkLocationsKey, m_customNdkList);
|
settings.setValue(CustomNdkLocationsKey, m_customNdkList);
|
||||||
|
settings.setValue(DefaultNdkLocationKey, m_defaultNdk.toString());
|
||||||
settings.setValue(SDKManagerToolArgsKey, m_sdkManagerToolArgs);
|
settings.setValue(SDKManagerToolArgsKey, m_sdkManagerToolArgs);
|
||||||
settings.setValue(OpenJDKLocationKey, m_openJDKLocation.toString());
|
settings.setValue(OpenJDKLocationKey, m_openJDKLocation.toString());
|
||||||
settings.setValue(OpenSslPriLocationKey, m_openSslLocation.toString());
|
settings.setValue(OpenSslPriLocationKey, m_openSslLocation.toString());
|
||||||
@@ -396,6 +405,16 @@ void AndroidConfig::removeCustomNdk(const QString &customNdk)
|
|||||||
m_customNdkList.removeAll(customNdk);
|
m_customNdkList.removeAll(customNdk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidConfig::setDefaultNdk(const Utils::FilePath &defaultNdk)
|
||||||
|
{
|
||||||
|
m_defaultNdk = defaultNdk;
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePath AndroidConfig::defaultNdk() const
|
||||||
|
{
|
||||||
|
return m_defaultNdk;
|
||||||
|
}
|
||||||
|
|
||||||
FilePath AndroidConfig::openSslLocation() const
|
FilePath AndroidConfig::openSslLocation() const
|
||||||
{
|
{
|
||||||
return m_openSslLocation;
|
return m_openSslLocation;
|
||||||
@@ -927,6 +946,8 @@ void AndroidConfig::setSdkManagerToolArgs(const QStringList &args)
|
|||||||
|
|
||||||
FilePath AndroidConfig::ndkLocation(const BaseQtVersion *qtVersion) const
|
FilePath AndroidConfig::ndkLocation(const BaseQtVersion *qtVersion) const
|
||||||
{
|
{
|
||||||
|
if (!m_defaultNdk.isEmpty())
|
||||||
|
return m_defaultNdk; // A selected default NDK is good for any Qt version
|
||||||
return sdkLocation().pathAppended(ndkPathFromQtVersion(*qtVersion));
|
return sdkLocation().pathAppended(ndkPathFromQtVersion(*qtVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1005,6 +1026,9 @@ bool AndroidConfig::allEssentialsInstalled(AndroidSdkManager *sdkManager)
|
|||||||
if (essentialPkgs.isEmpty())
|
if (essentialPkgs.isEmpty())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!m_defaultNdk.isEmpty())
|
||||||
|
essentialPkgs = Utils::filtered(essentialPkgs,
|
||||||
|
[](const QString &p){ return !p.startsWith("ndk;"); });
|
||||||
return essentialPkgs.isEmpty() ? true : false;
|
return essentialPkgs.isEmpty() ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -167,6 +167,8 @@ public:
|
|||||||
QStringList getCustomNdkList() const;
|
QStringList getCustomNdkList() const;
|
||||||
void addCustomNdk(const QString &customNdk);
|
void addCustomNdk(const QString &customNdk);
|
||||||
void removeCustomNdk(const QString &customNdk);
|
void removeCustomNdk(const QString &customNdk);
|
||||||
|
void setDefaultNdk(const Utils::FilePath &defaultNdk);
|
||||||
|
Utils::FilePath defaultNdk() const;
|
||||||
|
|
||||||
Utils::FilePath openSslLocation() const;
|
Utils::FilePath openSslLocation() const;
|
||||||
void setOpenSslLocation(const Utils::FilePath &openSslLocation);
|
void setOpenSslLocation(const Utils::FilePath &openSslLocation);
|
||||||
@@ -201,6 +203,7 @@ private:
|
|||||||
SdkForQtVersions m_defaultSdkDepends;
|
SdkForQtVersions m_defaultSdkDepends;
|
||||||
QList<SdkForQtVersions> m_specificQtVersions;
|
QList<SdkForQtVersions> m_specificQtVersions;
|
||||||
QStringList m_customNdkList;
|
QStringList m_customNdkList;
|
||||||
|
Utils::FilePath m_defaultNdk;
|
||||||
bool m_sdkFullyConfigured = false;
|
bool m_sdkFullyConfigured = false;
|
||||||
|
|
||||||
//caches
|
//caches
|
||||||
|
@@ -105,6 +105,7 @@ private:
|
|||||||
|
|
||||||
void downloadSdk();
|
void downloadSdk();
|
||||||
void addCustomNdkItem();
|
void addCustomNdkItem();
|
||||||
|
bool isDefaultNdkSelected() const;
|
||||||
void validateOpenSsl();
|
void validateOpenSsl();
|
||||||
|
|
||||||
Ui_AndroidSettingsWidget m_ui;
|
Ui_AndroidSettingsWidget m_ui;
|
||||||
@@ -263,6 +264,8 @@ void AndroidSettingsWidget::updateNdkList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_ui.ndkListWidget->setCurrentRow(0);
|
m_ui.ndkListWidget->setCurrentRow(0);
|
||||||
|
|
||||||
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSettingsWidget::addCustomNdkItem()
|
void AndroidSettingsWidget::addCustomNdkItem()
|
||||||
@@ -287,6 +290,17 @@ void AndroidSettingsWidget::addCustomNdkItem()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AndroidSettingsWidget::isDefaultNdkSelected() const
|
||||||
|
{
|
||||||
|
if (!m_androidConfig.defaultNdk().isEmpty()) {
|
||||||
|
if (const QListWidgetItem *item = m_ui.ndkListWidget->currentItem()) {
|
||||||
|
return FilePath::fromUserInput(item->text()) == m_androidConfig.defaultNdk();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
AndroidSettingsWidget::AndroidSettingsWidget()
|
AndroidSettingsWidget::AndroidSettingsWidget()
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
@@ -398,9 +412,18 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
|||||||
connect(m_ui.addCustomNdkButton, &QPushButton::clicked, this,
|
connect(m_ui.addCustomNdkButton, &QPushButton::clicked, this,
|
||||||
&AndroidSettingsWidget::addCustomNdkItem);
|
&AndroidSettingsWidget::addCustomNdkItem);
|
||||||
connect(m_ui.removeCustomNdkButton, &QPushButton::clicked, this, [this] {
|
connect(m_ui.removeCustomNdkButton, &QPushButton::clicked, this, [this] {
|
||||||
|
if (isDefaultNdkSelected())
|
||||||
|
m_androidConfig.setDefaultNdk({});
|
||||||
m_androidConfig.removeCustomNdk(m_ui.ndkListWidget->currentItem()->text());
|
m_androidConfig.removeCustomNdk(m_ui.ndkListWidget->currentItem()->text());
|
||||||
m_ui.ndkListWidget->takeItem(m_ui.ndkListWidget->currentRow());
|
m_ui.ndkListWidget->takeItem(m_ui.ndkListWidget->currentRow());
|
||||||
});
|
});
|
||||||
|
connect(m_ui.makeDefaultNdkButton, &QPushButton::clicked, this, [this] {
|
||||||
|
const FilePath defaultNdk = isDefaultNdkSelected()
|
||||||
|
? FilePath()
|
||||||
|
: FilePath::fromUserInput(m_ui.ndkListWidget->currentItem()->text());
|
||||||
|
m_androidConfig.setDefaultNdk(defaultNdk);
|
||||||
|
updateUI();
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_ui.openSslPathChooser, &PathChooser::rawPathChanged,
|
connect(m_ui.openSslPathChooser, &PathChooser::rawPathChanged,
|
||||||
this, &AndroidSettingsWidget::validateOpenSsl);
|
this, &AndroidSettingsWidget::validateOpenSsl);
|
||||||
@@ -658,6 +681,22 @@ void AndroidSettingsWidget::updateUI()
|
|||||||
|
|
||||||
m_androidSummary->setSetupOk(androidSetupOk);
|
m_androidSummary->setSetupOk(androidSetupOk);
|
||||||
m_openSslSummary->setSetupOk(openSslOk);
|
m_openSslSummary->setSetupOk(openSslOk);
|
||||||
|
|
||||||
|
// Mark default entry in NDK list widget
|
||||||
|
{
|
||||||
|
const QFont font = m_ui.ndkListWidget->font();
|
||||||
|
QFont markedFont = font;
|
||||||
|
markedFont.setItalic(true);
|
||||||
|
for (int row = 0; row < m_ui.ndkListWidget->count(); ++row) {
|
||||||
|
QListWidgetItem *item = m_ui.ndkListWidget->item(row);
|
||||||
|
const bool isDefaultNdk =
|
||||||
|
FilePath::fromUserInput(item->text()) == m_androidConfig.defaultNdk();
|
||||||
|
item->setFont(isDefaultNdk ? markedFont : font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ui.makeDefaultNdkButton->setText(isDefaultNdkSelected() ? tr("Unset Default")
|
||||||
|
: tr("Make Default"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSettingsWidget::downloadSdk()
|
void AndroidSettingsWidget::downloadSdk()
|
||||||
|
@@ -62,6 +62,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="makeDefaultNdkButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Force a specific NDK installation to be used by all Android kits.<br/>Note that the forced NDK might not be compatible with all Qt registered versions.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="ndkListControlsSpacer">
|
<spacer name="ndkListControlsSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Reference in New Issue
Block a user