summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kde.org>2019-10-18 09:25:14 +0300
committerBogDan Vatra <bogdan@kdab.com>2019-10-28 05:47:53 +0000
commite3904f3b135564834ae78245d79818e72d2edd7b (patch)
tree7e8f2ad00af56fdf14af2271754f7082fa158247 /src/plugins
parentafd22a75c18ad15293ed612f0a85a52a45e37881 (diff)
downloadqt-creator-e3904f3b135564834ae78245d79818e72d2edd7b.tar.gz
CMake: Add Android Multi ABI support
Change-Id: Ia5b3fcda29705fefca85833ebc28b4154defba5f Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/android/androidbuildapkstep.cpp8
-rw-r--r--src/plugins/android/androidconstants.h1
-rw-r--r--src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp37
3 files changed, 38 insertions, 8 deletions
diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp
index bf89bd4a93..ccd9bec14d 100644
--- a/src/plugins/android/androidbuildapkstep.cpp
+++ b/src/plugins/android/androidbuildapkstep.cpp
@@ -393,6 +393,10 @@ void AndroidBuildApkStep::doRun()
if (!node)
return false;
+ FilePath deploymentSettingsFile = FilePath::fromString(node->data(Android::Constants::AndroidDeploySettingsFile).toString());
+ if (deploymentSettingsFile.exists())
+ return true; // cmake creates this file for us
+
auto targets = node->data(Android::Constants::AndroidTargets).toStringList();
if (targets.isEmpty())
return true; // qmake does this job for us
@@ -449,7 +453,7 @@ void AndroidBuildApkStep::doRun()
qmlRootPath = target()->project()->rootProjectDirectory().toString();
deploySettings["qml-root-path"] = qmlRootPath;
- QFile f{bc->buildDirectory().pathAppended("android_deployment_settings.json").toString()};
+ QFile f{deploymentSettingsFile.toString()};
if (!f.open(QIODevice::WriteOnly))
return false;
f.write(QJsonDocument{deploySettings}.toJson());
@@ -518,6 +522,8 @@ QVariant AndroidBuildApkStep::data(Core::Id id) const
return AndroidConfigurations::currentConfig().bestNdkPlatformMatch(AndroidManager::minimumSDK(target())).mid(8);
if (id == Constants::NdkLocation)
return QVariant::fromValue(AndroidConfigurations::currentConfig().ndkLocation());
+ if (id == Constants::SdkLocation)
+ return QVariant::fromValue(AndroidConfigurations::currentConfig().sdkLocation());
if (id == Constants::AndroidABIs)
return AndroidManager::applicationAbis(target());
diff --git a/src/plugins/android/androidconstants.h b/src/plugins/android/androidconstants.h
index b617087787..8c8f638555 100644
--- a/src/plugins/android/androidconstants.h
+++ b/src/plugins/android/androidconstants.h
@@ -82,6 +82,7 @@ const char AndroidManifest[] = "Android.Manifest"; // QStringList
const char AndroidNdkPlatform[] = "AndroidNdkPlatform"; //QString
const char NdkLocation[] = "NdkLocation"; // FileName
+const char SdkLocation[] = "SdkLocation"; // FileName
const char AndroidABIs[] = "AndroidABIs"; // QString
} // namespace Constants;
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
index ba698b9d70..adbf2bc3f8 100644
--- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
@@ -48,6 +48,7 @@
#include <projectexplorer/projectmacroexpander.h>
#include <projectexplorer/target.h>
+#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
#include <utils/algorithm.h>
@@ -199,11 +200,13 @@ void CMakeBuildConfiguration::initialize()
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"ANDROID_NDK",
CMakeProjectManager::CMakeConfigItem::Type::PATH,
"Android NDK PATH",
- ndkLocation.toUserOutput().toUtf8()});
+ ndkLocation.toString().toUtf8()});
+
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_TOOLCHAIN_FILE",
CMakeProjectManager::CMakeConfigItem::Type::PATH,
"Android CMake toolchain file",
- ndkLocation.pathAppended("build/cmake/android.toolchain.cmake").toUserOutput().toUtf8()});
+ ndkLocation.pathAppended("build/cmake/android.toolchain.cmake").toString().toUtf8()});
+
auto androidAbis = bs->data(Android::Constants::AndroidABIs).toStringList();
QString preferredAbi;
if (androidAbis.contains("arm64-v8a")) {
@@ -219,14 +222,23 @@ void CMakeBuildConfiguration::initialize()
"Android ABI",
preferredAbi.toLatin1(),
androidAbis});
+
+ QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target()->kit());
+ if (qt->qtVersion() >= QtSupport::QtVersionNumber{5, 14, 0}) {
+ auto sdkLocation = bs->data(Android::Constants::SdkLocation).value<FilePath>();
+ m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"ANDROID_SDK",
+ CMakeProjectManager::CMakeConfigItem::Type::PATH,
+ "Android SDK PATH",
+ sdkLocation.toString().toUtf8()});
+
+ }
+
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"ANDROID_STL",
CMakeProjectManager::CMakeConfigItem::Type::STRING,
"Android STL",
"c++_shared"});
- m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "BOTH"});
- m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "BOTH"});
- m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_INCLUDE", "BOTH"});
- m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_PACKAGE", "BOTH"});
+
+ m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH", "%{Qt:QT_INSTALL_PREFIX}"});
}
BuildStepList *cleanSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
@@ -434,6 +446,16 @@ void CMakeBuildConfiguration::setConfigurationForCMake(const QList<ConfigModel::
const CMakeConfig config = configurationForCMake() + newConfig;
setConfigurationForCMake(config);
+
+ if (Utils::indexOf(newConfig, [](const CMakeConfigItem &item){
+ return item.key.startsWith("ANDROID_BUILD_ABI_");
+ }) != -1) {
+ // We always need to clean when we change the ANDROID_BUILD_ABI_ variables
+ QList<ProjectExplorer::BuildStepList *> stepLists;
+ const Core::Id clean = ProjectExplorer::Constants::BUILDSTEPS_CLEAN;
+ stepLists << stepList(clean);
+ BuildManager::buildLists(stepLists, QStringList() << ProjectExplorerPlugin::displayNameForStepId(clean));
+ }
}
void CMakeBuildConfiguration::clearError(ForceEnabledChanged fec)
@@ -471,7 +493,8 @@ void CMakeBuildConfiguration::setConfigurationForCMake(const CMakeConfig &config
{
auto configs = removeDuplicates(config);
if (m_configurationForCMake.isEmpty())
- m_configurationForCMake = removeDuplicates(configs + m_initialConfiguration);
+ m_configurationForCMake = removeDuplicates(m_initialConfiguration +
+ CMakeConfigurationKitAspect::configuration(target()->kit()) + configs);
else
m_configurationForCMake = configs;