2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#include "androidqtversion.h"
|
|
|
|
|
#include "androidconstants.h"
|
2012-12-07 19:52:56 +02:00
|
|
|
#include "androidconfigurations.h"
|
|
|
|
|
#include "androidmanager.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2012-12-07 19:52:56 +02:00
|
|
|
#include <utils/environment.h>
|
2013-02-04 13:34:09 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2012-12-07 19:52:56 +02:00
|
|
|
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2012-12-07 19:52:56 +02:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
|
|
|
|
|
2020-07-23 15:48:56 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-03-07 17:12:03 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2012-12-07 19:52:56 +02:00
|
|
|
#include <projectexplorer/kit.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2014-11-19 17:58:33 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2013-08-01 12:49:47 +02:00
|
|
|
#include <proparser/profileevaluator.h>
|
|
|
|
|
|
2020-06-16 07:48:09 +02:00
|
|
|
#include <QRegularExpression>
|
|
|
|
|
|
2012-12-07 19:52:56 +02:00
|
|
|
using namespace ProjectExplorer;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2019-02-14 12:29:00 +01:00
|
|
|
namespace Android {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
AndroidQtVersion::AndroidQtVersion()
|
|
|
|
|
: QtSupport::BaseQtVersion()
|
2019-11-18 16:57:44 +01:00
|
|
|
, m_guard(std::make_unique<QObject>())
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2019-11-18 16:57:44 +01:00
|
|
|
QObject::connect(AndroidConfigurations::instance(),
|
|
|
|
|
&AndroidConfigurations::aboutToUpdate,
|
|
|
|
|
m_guard.get(),
|
|
|
|
|
[this] { resetCache(); });
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AndroidQtVersion::isValid() const
|
|
|
|
|
{
|
|
|
|
|
if (!BaseQtVersion::isValid())
|
|
|
|
|
return false;
|
|
|
|
|
if (qtAbis().isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AndroidQtVersion::invalidReason() const
|
|
|
|
|
{
|
|
|
|
|
QString tmp = BaseQtVersion::invalidReason();
|
2019-10-08 13:07:06 +02:00
|
|
|
if (tmp.isEmpty()) {
|
2020-02-16 20:46:23 +02:00
|
|
|
if (AndroidConfigurations::currentConfig().ndkLocation(this).isEmpty())
|
2019-10-08 13:07:06 +02:00
|
|
|
return tr("NDK is not configured in Devices > Android.");
|
|
|
|
|
if (AndroidConfigurations::currentConfig().sdkLocation().isEmpty())
|
|
|
|
|
return tr("SDK is not configured in Devices > Android.");
|
|
|
|
|
if (qtAbis().isEmpty())
|
|
|
|
|
return tr("Failed to detect the ABIs used by the Qt version. Check the settings in "
|
|
|
|
|
"Devices > Android for errors.");
|
|
|
|
|
}
|
2012-04-18 20:30:57 +03:00
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-20 13:58:21 +02:00
|
|
|
bool AndroidQtVersion::supportsMultipleQtAbis() const
|
|
|
|
|
{
|
2020-10-16 13:23:25 +03:00
|
|
|
return qtVersion() >= QtSupport::QtVersionNumber{5, 14}
|
|
|
|
|
&& qtVersion() < QtSupport::QtVersionNumber{6, 0};
|
2020-08-20 13:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-27 11:04:18 +02:00
|
|
|
Abis AndroidQtVersion::detectQtAbis() const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2019-08-26 14:19:07 +03:00
|
|
|
auto androidAbi2Abi = [](const QString &androidAbi) {
|
2020-07-23 15:48:56 +02:00
|
|
|
if (androidAbi == ProjectExplorer::Constants::ANDROID_ABI_ARM64_V8A) {
|
2019-08-26 14:19:07 +03:00
|
|
|
return Abi{Abi::Architecture::ArmArchitecture,
|
|
|
|
|
Abi::OS::LinuxOS,
|
|
|
|
|
Abi::OSFlavor::AndroidLinuxFlavor,
|
|
|
|
|
Abi::BinaryFormat::ElfFormat,
|
|
|
|
|
64, androidAbi};
|
2020-07-23 15:48:56 +02:00
|
|
|
} else if (androidAbi == ProjectExplorer::Constants::ANDROID_ABI_ARMEABI_V7A) {
|
2019-08-26 14:19:07 +03:00
|
|
|
return Abi{Abi::Architecture::ArmArchitecture,
|
|
|
|
|
Abi::OS::LinuxOS,
|
|
|
|
|
Abi::OSFlavor::AndroidLinuxFlavor,
|
|
|
|
|
Abi::BinaryFormat::ElfFormat,
|
|
|
|
|
32, androidAbi};
|
2020-07-23 15:48:56 +02:00
|
|
|
} else if (androidAbi == ProjectExplorer::Constants::ANDROID_ABI_X86_64) {
|
2019-08-26 14:19:07 +03:00
|
|
|
return Abi{Abi::Architecture::X86Architecture,
|
|
|
|
|
Abi::OS::LinuxOS,
|
|
|
|
|
Abi::OSFlavor::AndroidLinuxFlavor,
|
|
|
|
|
Abi::BinaryFormat::ElfFormat,
|
|
|
|
|
64, androidAbi};
|
2020-07-23 15:48:56 +02:00
|
|
|
} else if (androidAbi == ProjectExplorer::Constants::ANDROID_ABI_X86) {
|
2019-08-26 14:19:07 +03:00
|
|
|
return Abi{Abi::Architecture::X86Architecture,
|
|
|
|
|
Abi::OS::LinuxOS,
|
|
|
|
|
Abi::OSFlavor::AndroidLinuxFlavor,
|
|
|
|
|
Abi::BinaryFormat::ElfFormat,
|
|
|
|
|
32, androidAbi};
|
|
|
|
|
} else {
|
|
|
|
|
return Abi{Abi::Architecture::UnknownArchitecture,
|
|
|
|
|
Abi::OS::LinuxOS,
|
|
|
|
|
Abi::OSFlavor::AndroidLinuxFlavor,
|
|
|
|
|
Abi::BinaryFormat::ElfFormat,
|
|
|
|
|
0, androidAbi};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
Abis abis;
|
|
|
|
|
for (const auto &abi : androidAbis())
|
|
|
|
|
abis << androidAbi2Abi(abi);
|
2013-02-20 17:05:00 +01:00
|
|
|
return abis;
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:50:37 +02:00
|
|
|
void AndroidQtVersion::addToEnvironment(const Kit *k, Utils::Environment &env) const
|
2012-12-07 19:52:56 +02:00
|
|
|
{
|
2020-04-16 14:38:46 +02:00
|
|
|
BaseQtVersion::addToEnvironment(k, env);
|
|
|
|
|
|
|
|
|
|
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
2012-12-07 19:52:56 +02:00
|
|
|
// this env vars are used by qmake mkspecs to generate makefiles (check QTDIR/mkspecs/android-g++/qmake.conf for more info)
|
2020-02-16 20:46:23 +02:00
|
|
|
env.set(QLatin1String("ANDROID_NDK_HOST"), config.toolchainHost(this));
|
|
|
|
|
env.set(QLatin1String("ANDROID_NDK_ROOT"), config.ndkLocation(this).toUserOutput());
|
2018-12-05 13:00:36 +01:00
|
|
|
env.set(QLatin1String("ANDROID_NDK_PLATFORM"),
|
2020-02-16 20:46:23 +02:00
|
|
|
config.bestNdkPlatformMatch(qMax(minimumNDK(), AndroidManager::minimumSDK(k)), this));
|
2012-12-07 19:52:56 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-27 13:12:28 +01:00
|
|
|
Utils::Environment AndroidQtVersion::qmakeRunEnvironment() const
|
|
|
|
|
{
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
2020-02-16 20:46:23 +02:00
|
|
|
env.set(QLatin1String("ANDROID_NDK_ROOT"),
|
|
|
|
|
AndroidConfigurations::currentConfig().ndkLocation(this).toUserOutput());
|
2014-03-27 13:12:28 +01:00
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
QString AndroidQtVersion::description() const
|
|
|
|
|
{
|
2012-08-01 15:25:05 +02:00
|
|
|
//: Qt Version is meant for Android
|
|
|
|
|
return tr("Android");
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
const QStringList &AndroidQtVersion::androidAbis() const
|
2013-08-01 12:49:47 +02:00
|
|
|
{
|
|
|
|
|
ensureMkSpecParsed();
|
2019-08-26 14:19:07 +03:00
|
|
|
return m_androidAbis;
|
2013-08-01 12:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 11:18:05 +01:00
|
|
|
int AndroidQtVersion::minimumNDK() const
|
2018-11-23 10:08:35 +01:00
|
|
|
{
|
|
|
|
|
ensureMkSpecParsed();
|
|
|
|
|
return m_minNdk;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-01 12:49:47 +02:00
|
|
|
void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
|
|
|
|
|
{
|
2020-10-23 16:26:49 +03:00
|
|
|
m_androidAbis = evaluator->values("ALL_ANDROID_ABIS");
|
|
|
|
|
if (m_androidAbis.isEmpty())
|
2019-08-26 14:19:07 +03:00
|
|
|
m_androidAbis = QStringList{evaluator->value("ANDROID_TARGET_ARCH")};
|
|
|
|
|
const QString androidPlatform = evaluator->value("ANDROID_PLATFORM");
|
2018-11-23 10:08:35 +01:00
|
|
|
if (!androidPlatform.isEmpty()) {
|
2020-06-16 07:48:09 +02:00
|
|
|
const QRegularExpression regex("android-(\\d+)");
|
|
|
|
|
const QRegularExpressionMatch match = regex.match(androidPlatform);
|
|
|
|
|
if (match.hasMatch()) {
|
2018-11-23 10:08:35 +01:00
|
|
|
bool ok = false;
|
2020-06-16 07:48:09 +02:00
|
|
|
int tmp = match.captured(1).toInt(&ok);
|
2018-11-23 10:08:35 +01:00
|
|
|
if (ok)
|
|
|
|
|
m_minNdk = tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-28 14:14:10 +02:00
|
|
|
BaseQtVersion::parseMkSpec(evaluator);
|
2013-08-01 12:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
QSet<Utils::Id> AndroidQtVersion::availableFeatures() const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-06-26 13:59:38 +02:00
|
|
|
QSet<Utils::Id> features = QtSupport::BaseQtVersion::availableFeatures();
|
2015-11-27 11:31:35 +01:00
|
|
|
features.insert(QtSupport::Constants::FEATURE_MOBILE);
|
|
|
|
|
features.remove(QtSupport::Constants::FEATURE_QT_CONSOLE);
|
|
|
|
|
features.remove(QtSupport::Constants::FEATURE_QT_WEBKIT);
|
2012-04-18 20:30:57 +03:00
|
|
|
return features;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
QSet<Utils::Id> AndroidQtVersion::targetDeviceTypes() const
|
2015-11-27 14:02:44 +01:00
|
|
|
{
|
2017-02-22 15:09:35 +01:00
|
|
|
return {Constants::ANDROID_DEVICE_TYPE};
|
2015-11-27 14:02:44 +01:00
|
|
|
}
|
2019-02-14 12:29:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Factory
|
|
|
|
|
|
|
|
|
|
AndroidQtVersionFactory::AndroidQtVersionFactory()
|
|
|
|
|
{
|
|
|
|
|
setQtVersionCreator([] { return new AndroidQtVersion; });
|
|
|
|
|
setSupportedType(Constants::ANDROIDQT);
|
|
|
|
|
setPriority(90);
|
|
|
|
|
|
|
|
|
|
setRestrictionChecker([](const SetupData &setup) {
|
|
|
|
|
return !setup.config.contains("android-no-sdk")
|
|
|
|
|
&& (setup.config.contains("android")
|
|
|
|
|
|| setup.platforms.contains("android"));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Android
|