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
|
||||
{
|
||||
QSet<QString> res;
|
||||
auto project = qobject_cast<QmakeProject*>(target->project());
|
||||
Q_ASSERT(project);
|
||||
if (!project)
|
||||
return {};
|
||||
|
||||
for (const QmakeProFileNode *file : project->allProFiles()) {
|
||||
TargetInformation info = file->targetInformation();
|
||||
ProjectNode *root = target->project()->rootProjectNode();
|
||||
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());
|
||||
Utils::FileName destDir = info.destDir;
|
||||
if (!destDir.isEmpty()) {
|
||||
@@ -148,39 +148,42 @@ QStringList QmakeAndroidSupport::soLibSearchPath(const ProjectExplorer::Target *
|
||||
+ '/' + destDir.toString()));
|
||||
res.insert(destDir.toString());
|
||||
}
|
||||
});
|
||||
|
||||
const QString jsonFile = targetData(Android::Constants::AndroidDeploySettingsFile, target).toString();
|
||||
QFile deploymentSettings(jsonFile);
|
||||
if (deploymentSettings.open(QIODevice::ReadOnly)) {
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(deploymentSettings.readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError)
|
||||
continue;
|
||||
|
||||
if (error.error == QJsonParseError::NoError) {
|
||||
auto rootObj = doc.object();
|
||||
auto it = rootObj.find("stdcpp-path");
|
||||
if (it != rootObj.constEnd())
|
||||
res.insert(QFileInfo(it.value().toString()).absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
return res.toList();
|
||||
}
|
||||
|
||||
QStringList QmakeAndroidSupport::projectTargetApplications(const ProjectExplorer::Target *target) const
|
||||
{
|
||||
QStringList apps;
|
||||
auto qmakeProject = qobject_cast<QmakeProject *>(target->project());
|
||||
if (!qmakeProject)
|
||||
return apps;
|
||||
for (const QmakeProFileNode *proFile : qmakeProject->applicationProFiles()) {
|
||||
if (proFile->projectType() == ProjectType::ApplicationTemplate) {
|
||||
const QString target = proFile->targetInformation().target;
|
||||
|
||||
ProjectNode *root = target->project()->rootProjectNode();
|
||||
root->forEachProjectNode([&apps](const ProjectNode *node) {
|
||||
auto qmakeNode = dynamic_cast<const QmakeProFileNode *>(node);
|
||||
if (!qmakeNode || !qmakeNode->includedInExactParse())
|
||||
return;
|
||||
if (qmakeNode->projectType() == ProjectType::ApplicationTemplate) {
|
||||
const QString target = qmakeNode->targetInformation().target;
|
||||
if (target.startsWith("lib") && target.endsWith(".so"))
|
||||
apps << target.mid(3, target.lastIndexOf('.') - 3);
|
||||
else
|
||||
apps << target;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
apps.sort();
|
||||
return apps;
|
||||
}
|
||||
|
||||
@@ -243,6 +243,12 @@ bool QmakeProFileNode::isQtcRunnable() const
|
||||
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
|
||||
{
|
||||
Q_UNUSED(files)
|
||||
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
|
||||
bool isDebugAndRelease() const;
|
||||
bool isQtcRunnable() const;
|
||||
bool includedInExactParse() const;
|
||||
|
||||
bool showInSimpleTree() const override;
|
||||
|
||||
|
||||
@@ -755,30 +755,6 @@ QmakeProFileNode *QmakeProject::rootProjectNode() const
|
||||
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()
|
||||
{
|
||||
if (m_activeTarget) {
|
||||
@@ -1031,10 +1007,19 @@ void QmakeProject::updateBuildSystemData()
|
||||
target->setDeploymentData(deploymentData);
|
||||
|
||||
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();
|
||||
if (!ti.valid)
|
||||
continue;
|
||||
return;
|
||||
|
||||
const QStringList &config = node->variableValue(Variable::Config);
|
||||
|
||||
@@ -1100,7 +1085,8 @@ void QmakeProject::updateBuildSystemData()
|
||||
};
|
||||
|
||||
appTargetList.list.append(bti);
|
||||
}
|
||||
});
|
||||
|
||||
target->setApplicationTargets(appTargetList);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,9 +66,6 @@ public:
|
||||
|
||||
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);
|
||||
|
||||
/// \internal
|
||||
|
||||
Reference in New Issue
Block a user