forked from qt-creator/qt-creator
QmakeAndroid: Reduce coupling between Qmake and QmakeAndroid
This moves most of the QmakeProject::applicationProFiles code to its only user, the android side, and only uses the new bool includedInExactParse() const hook on the qmake side. Change-Id: Ica11127c4895be22cafe56757f4cecafa02583ef Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -133,13 +133,13 @@ bool QmakeAndroidSupport::setTargetData(Core::Id role, const QVariant &value, co
|
|||||||
QStringList QmakeAndroidSupport::soLibSearchPath(const ProjectExplorer::Target *target) const
|
QStringList QmakeAndroidSupport::soLibSearchPath(const ProjectExplorer::Target *target) const
|
||||||
{
|
{
|
||||||
QSet<QString> res;
|
QSet<QString> res;
|
||||||
auto project = qobject_cast<QmakeProject*>(target->project());
|
|
||||||
Q_ASSERT(project);
|
|
||||||
if (!project)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
for (const QmakeProFileNode *file : project->allProFiles()) {
|
ProjectNode *root = target->project()->rootProjectNode();
|
||||||
TargetInformation info = file->targetInformation();
|
root->forEachProjectNode([&res](const ProjectNode *node) {
|
||||||
|
auto qmakeNode = dynamic_cast<const QmakeProFileNode *>(node);
|
||||||
|
if (!qmakeNode)
|
||||||
|
return;
|
||||||
|
TargetInformation info = qmakeNode->targetInformation();
|
||||||
res.insert(info.buildDir.toString());
|
res.insert(info.buildDir.toString());
|
||||||
Utils::FileName destDir = info.destDir;
|
Utils::FileName destDir = info.destDir;
|
||||||
if (!destDir.isEmpty()) {
|
if (!destDir.isEmpty()) {
|
||||||
@@ -148,39 +148,42 @@ QStringList QmakeAndroidSupport::soLibSearchPath(const ProjectExplorer::Target *
|
|||||||
+ '/' + destDir.toString()));
|
+ '/' + destDir.toString()));
|
||||||
res.insert(destDir.toString());
|
res.insert(destDir.toString());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const QString jsonFile = targetData(Android::Constants::AndroidDeploySettingsFile, target).toString();
|
const QString jsonFile = targetData(Android::Constants::AndroidDeploySettingsFile, target).toString();
|
||||||
QFile deploymentSettings(jsonFile);
|
QFile deploymentSettings(jsonFile);
|
||||||
if (deploymentSettings.open(QIODevice::ReadOnly)) {
|
if (deploymentSettings.open(QIODevice::ReadOnly)) {
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(deploymentSettings.readAll(), &error);
|
QJsonDocument doc = QJsonDocument::fromJson(deploymentSettings.readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError)
|
if (error.error == QJsonParseError::NoError) {
|
||||||
continue;
|
|
||||||
|
|
||||||
auto rootObj = doc.object();
|
auto rootObj = doc.object();
|
||||||
auto it = rootObj.find("stdcpp-path");
|
auto it = rootObj.find("stdcpp-path");
|
||||||
if (it != rootObj.constEnd())
|
if (it != rootObj.constEnd())
|
||||||
res.insert(QFileInfo(it.value().toString()).absolutePath());
|
res.insert(QFileInfo(it.value().toString()).absolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.toList();
|
return res.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QmakeAndroidSupport::projectTargetApplications(const ProjectExplorer::Target *target) const
|
QStringList QmakeAndroidSupport::projectTargetApplications(const ProjectExplorer::Target *target) const
|
||||||
{
|
{
|
||||||
QStringList apps;
|
QStringList apps;
|
||||||
auto qmakeProject = qobject_cast<QmakeProject *>(target->project());
|
|
||||||
if (!qmakeProject)
|
ProjectNode *root = target->project()->rootProjectNode();
|
||||||
return apps;
|
root->forEachProjectNode([&apps](const ProjectNode *node) {
|
||||||
for (const QmakeProFileNode *proFile : qmakeProject->applicationProFiles()) {
|
auto qmakeNode = dynamic_cast<const QmakeProFileNode *>(node);
|
||||||
if (proFile->projectType() == ProjectType::ApplicationTemplate) {
|
if (!qmakeNode || !qmakeNode->includedInExactParse())
|
||||||
const QString target = proFile->targetInformation().target;
|
return;
|
||||||
|
if (qmakeNode->projectType() == ProjectType::ApplicationTemplate) {
|
||||||
|
const QString target = qmakeNode->targetInformation().target;
|
||||||
if (target.startsWith("lib") && target.endsWith(".so"))
|
if (target.startsWith("lib") && target.endsWith(".so"))
|
||||||
apps << target.mid(3, target.lastIndexOf('.') - 3);
|
apps << target.mid(3, target.lastIndexOf('.') - 3);
|
||||||
else
|
else
|
||||||
apps << target;
|
apps << target;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
apps.sort();
|
apps.sort();
|
||||||
return apps;
|
return apps;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,12 @@ bool QmakeProFileNode::isQtcRunnable() const
|
|||||||
return configValues.contains(QLatin1String("qtc_runnable"));
|
return configValues.contains(QLatin1String("qtc_runnable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QmakeProFileNode::includedInExactParse() const
|
||||||
|
{
|
||||||
|
const QmakeProFile *pro = proFile();
|
||||||
|
return pro && pro->includedInExactParse();
|
||||||
|
}
|
||||||
|
|
||||||
FolderNode::AddNewInformation QmakeProFileNode::addNewInformation(const QStringList &files, Node *context) const
|
FolderNode::AddNewInformation QmakeProFileNode::addNewInformation(const QStringList &files, Node *context) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(files)
|
Q_UNUSED(files)
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ public:
|
|||||||
|
|
||||||
bool isDebugAndRelease() const;
|
bool isDebugAndRelease() const;
|
||||||
bool isQtcRunnable() const;
|
bool isQtcRunnable() const;
|
||||||
|
bool includedInExactParse() const;
|
||||||
|
|
||||||
bool showInSimpleTree() const override;
|
bool showInSimpleTree() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -755,30 +755,6 @@ QmakeProFileNode *QmakeProject::rootProjectNode() const
|
|||||||
return static_cast<QmakeProFileNode *>(Project::rootProjectNode());
|
return static_cast<QmakeProFileNode *>(Project::rootProjectNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<const QmakeProFileNode *> QmakeProject::applicationProFiles() const
|
|
||||||
{
|
|
||||||
return allProFiles({ProjectType::ApplicationTemplate, ProjectType::ScriptTemplate});
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<const QmakeProFileNode *>
|
|
||||||
QmakeProject::allProFiles(const QList<ProjectType> &projectTypes) const
|
|
||||||
{
|
|
||||||
QList<const QmakeProFileNode *> list;
|
|
||||||
|
|
||||||
rootProjectNode()->forEachProjectNode([&list, projectTypes](const ProjectNode *node) {
|
|
||||||
if (auto qmakeNode = dynamic_cast<const QmakeProFileNode *>(node)) {
|
|
||||||
QmakeProFile *file = qmakeNode->proFile();
|
|
||||||
QTC_ASSERT(file, return);
|
|
||||||
if (file->includedInExactParse()) {
|
|
||||||
if (projectTypes.isEmpty() || projectTypes.contains(file->projectType()))
|
|
||||||
list.append(qmakeNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmakeProject::activeTargetWasChanged()
|
void QmakeProject::activeTargetWasChanged()
|
||||||
{
|
{
|
||||||
if (m_activeTarget) {
|
if (m_activeTarget) {
|
||||||
@@ -1031,10 +1007,19 @@ void QmakeProject::updateBuildSystemData()
|
|||||||
target->setDeploymentData(deploymentData);
|
target->setDeploymentData(deploymentData);
|
||||||
|
|
||||||
BuildTargetInfoList appTargetList;
|
BuildTargetInfoList appTargetList;
|
||||||
for (const QmakeProFileNode * const node : applicationProFiles()) {
|
|
||||||
|
rootProjectNode()->forEachProjectNode([this, target, &appTargetList](const ProjectNode *pn) {
|
||||||
|
auto node = dynamic_cast<const QmakeProFileNode *>(pn);
|
||||||
|
if (!node || !node->includedInExactParse())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (node->projectType() != ProjectType::ApplicationTemplate
|
||||||
|
&& node->projectType() != ProjectType::ScriptTemplate)
|
||||||
|
return;
|
||||||
|
|
||||||
TargetInformation ti = node->targetInformation();
|
TargetInformation ti = node->targetInformation();
|
||||||
if (!ti.valid)
|
if (!ti.valid)
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
const QStringList &config = node->variableValue(Variable::Config);
|
const QStringList &config = node->variableValue(Variable::Config);
|
||||||
|
|
||||||
@@ -1100,7 +1085,8 @@ void QmakeProject::updateBuildSystemData()
|
|||||||
};
|
};
|
||||||
|
|
||||||
appTargetList.list.append(bti);
|
appTargetList.list.append(bti);
|
||||||
}
|
});
|
||||||
|
|
||||||
target->setApplicationTargets(appTargetList);
|
target->setApplicationTargets(appTargetList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,6 @@ public:
|
|||||||
|
|
||||||
QStringList filesGeneratedFrom(const QString &file) const final;
|
QStringList filesGeneratedFrom(const QString &file) const final;
|
||||||
|
|
||||||
const QList<const QmakeProFileNode *> allProFiles(const QList<ProjectType> &projectTypes = {}) const;
|
|
||||||
QList<const QmakeProFileNode *> applicationProFiles() const;
|
|
||||||
|
|
||||||
static void notifyChanged(const Utils::FileName &name);
|
static void notifyChanged(const Utils::FileName &name);
|
||||||
|
|
||||||
/// \internal
|
/// \internal
|
||||||
|
|||||||
Reference in New Issue
Block a user