2013-01-30 18:19:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
2013-01-30 18:19:31 +01: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.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsnodes.h"
|
|
|
|
|
|
2017-02-17 13:17:31 +01:00
|
|
|
#include "qbsnodetreebuilder.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
#include "qbsproject.h"
|
2013-10-14 14:42:07 +02:00
|
|
|
#include "qbsprojectmanagerconstants.h"
|
2019-06-03 17:36:02 +02:00
|
|
|
#include "qbsprojectmanagerplugin.h"
|
2019-06-28 14:30:32 +02:00
|
|
|
#include "qbssession.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2019-04-03 18:10:35 +02:00
|
|
|
#include <android/androidconstants.h>
|
2013-04-17 13:07:43 +02:00
|
|
|
#include <coreplugin/fileiconprovider.h>
|
2013-05-16 16:24:37 +02:00
|
|
|
#include <coreplugin/idocument.h>
|
2013-06-18 14:05:31 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-05-16 16:31:07 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2013-04-17 13:07:43 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2015-10-30 14:13:24 +01:00
|
|
|
#include <resourceeditor/resourcenode.h>
|
2015-03-10 16:41:59 +01:00
|
|
|
#include <utils/algorithm.h>
|
2013-03-25 12:03:37 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2015-11-10 17:23:29 +01:00
|
|
|
#include <QtDebug>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <QDir>
|
2017-03-21 10:35:50 +01:00
|
|
|
#include <QIcon>
|
2019-06-28 14:30:32 +02:00
|
|
|
#include <QJsonArray>
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2017-03-15 15:46:48 +01:00
|
|
|
using namespace ProjectExplorer;
|
2019-06-28 14:30:32 +02:00
|
|
|
using namespace Utils;
|
2017-03-15 15:46:48 +01:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
|
// Helpers:
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
|
|
2013-05-17 13:16:09 +02:00
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
const QbsProductNode *parentQbsProductNode(const ProjectExplorer::Node *node)
|
|
|
|
|
{
|
|
|
|
|
for (; node; node = node->parentFolderNode()) {
|
|
|
|
|
const auto prdNode = dynamic_cast<const QbsProductNode *>(node);
|
|
|
|
|
if (prdNode)
|
|
|
|
|
return prdNode;
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
2019-06-28 14:30:32 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
2015-07-28 16:59:06 +02:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsGroupNode:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
QbsGroupNode::QbsGroupNode(const QJsonObject &grp) : ProjectNode(FilePath()), m_groupData(grp)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2020-04-29 17:03:26 +02:00
|
|
|
static QIcon groupIcon = QIcon(QString(ProjectExplorer::Constants::FILEOVERLAY_GROUP));
|
2017-03-21 10:35:50 +01:00
|
|
|
setIcon(groupIcon);
|
2019-06-28 14:30:32 +02:00
|
|
|
setDisplayName(grp.value("name").toString());
|
|
|
|
|
setEnabled(grp.value("is-enabled").toBool());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2018-05-24 17:01:10 +02:00
|
|
|
FolderNode::AddNewInformation QbsGroupNode::addNewInformation(const QStringList &files,
|
|
|
|
|
Node *context) const
|
|
|
|
|
{
|
2019-02-26 16:47:40 +01:00
|
|
|
AddNewInformation info = ProjectNode::addNewInformation(files, context);
|
2018-05-24 17:01:10 +02:00
|
|
|
if (context != this)
|
|
|
|
|
--info.priority;
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-16 17:06:29 +02:00
|
|
|
QVariant QbsGroupNode::data(Core::Id role) const
|
|
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
if (role == ProjectExplorer::Constants::QT_KEYWORDS_ENABLED) {
|
|
|
|
|
QJsonObject modProps = m_groupData.value("module-properties").toObject();
|
|
|
|
|
if (modProps.isEmpty()) {
|
|
|
|
|
const QbsProductNode * const prdNode = parentQbsProductNode(this);
|
|
|
|
|
QTC_ASSERT(prdNode, return QVariant());
|
|
|
|
|
modProps = prdNode->productData().value("module-properties").toObject();
|
|
|
|
|
}
|
|
|
|
|
return modProps.value("Qt.core.enableKeywords").toBool();
|
|
|
|
|
}
|
2019-07-16 17:06:29 +02:00
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsProductNode:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
QbsProductNode::QbsProductNode(const QJsonObject &prd) : ProjectNode(FilePath()), m_productData(prd)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
static QIcon productIcon = Core::FileIconProvider::directoryIcon(
|
2020-04-29 17:03:26 +02:00
|
|
|
ProjectExplorer::Constants::FILEOVERLAY_PRODUCT);
|
2017-03-21 10:35:50 +01:00
|
|
|
setIcon(productIcon);
|
2019-06-28 14:30:32 +02:00
|
|
|
if (prd.value("is-runnable").toBool()) {
|
2019-09-24 14:39:50 +02:00
|
|
|
setProductType(ProductType::App);
|
|
|
|
|
} else {
|
2019-06-28 14:30:32 +02:00
|
|
|
const QJsonArray type = prd.value("type").toArray();
|
|
|
|
|
if (type.contains("dynamiclibrary") || type.contains("staticlibrary"))
|
|
|
|
|
setProductType(ProductType::Lib);
|
|
|
|
|
else
|
|
|
|
|
setProductType(ProductType::Other);
|
2019-09-24 14:39:50 +02:00
|
|
|
}
|
2019-06-28 14:30:32 +02:00
|
|
|
setEnabled(prd.value("is-enabled").toBool());
|
|
|
|
|
setDisplayName(prd.value("full-display-name").toString());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-06-03 17:36:02 +02:00
|
|
|
void QbsProductNode::build()
|
|
|
|
|
{
|
|
|
|
|
QbsProjectManagerPlugin::buildNamedProduct(static_cast<QbsProject *>(getProject()),
|
2019-06-28 14:30:32 +02:00
|
|
|
m_productData.value("full-display-name").toString());
|
2019-06-03 17:36:02 +02:00
|
|
|
}
|
|
|
|
|
|
2018-12-17 15:18:32 +01:00
|
|
|
QStringList QbsProductNode::targetApplications() const
|
|
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
return QStringList{m_productData.value("target-executable").toString()};
|
2018-12-17 15:18:32 +01:00
|
|
|
}
|
|
|
|
|
|
2019-12-04 17:23:02 +01:00
|
|
|
QString QbsProductNode::fullDisplayName() const
|
2018-11-28 18:45:18 +01:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
return m_productData.value("full-display-name").toString();
|
2018-11-28 18:45:18 +01:00
|
|
|
}
|
|
|
|
|
|
2019-12-04 17:23:02 +01:00
|
|
|
QString QbsProductNode::buildKey() const
|
|
|
|
|
{
|
2020-04-09 13:30:39 +02:00
|
|
|
return getBuildKey(productData());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsProductNode::getBuildKey(const QJsonObject &product)
|
|
|
|
|
{
|
|
|
|
|
return product.value("name").toString() + '.'
|
|
|
|
|
+ product.value("multiplex-configuration-id").toString();
|
2019-12-04 17:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2019-04-03 18:10:35 +02:00
|
|
|
QVariant QbsProductNode::data(Core::Id role) const
|
|
|
|
|
{
|
|
|
|
|
if (role == Android::Constants::AndroidDeploySettingsFile) {
|
2019-06-28 14:30:32 +02:00
|
|
|
for (const auto &a : m_productData.value("generated-artifacts").toArray()) {
|
|
|
|
|
const QJsonObject artifact = a.toObject();
|
|
|
|
|
if (artifact.value("file-tags").toArray().contains("qt_androiddeployqt_input"))
|
|
|
|
|
return artifact.value("file-path").toString();
|
2019-04-03 18:10:35 +02:00
|
|
|
}
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (role == Android::Constants::AndroidSoLibPath) {
|
2019-06-28 14:30:32 +02:00
|
|
|
QStringList ret{m_productData.value("build-directory").toString()};
|
|
|
|
|
forAllArtifacts(m_productData, ArtifactType::Generated, [&ret](const QJsonObject &artifact) {
|
|
|
|
|
if (artifact.value("file-tags").toArray().contains("dynamiclibrary"))
|
|
|
|
|
ret << QFileInfo(artifact.value("file-path").toString()).path();
|
|
|
|
|
});
|
2019-04-03 18:10:35 +02:00
|
|
|
ret.removeDuplicates();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (role == Android::Constants::AndroidManifest) {
|
2019-06-28 14:30:32 +02:00
|
|
|
for (const auto &a : m_productData.value("generated-artifacts").toArray()) {
|
|
|
|
|
const QJsonObject artifact = a.toObject();
|
|
|
|
|
if (artifact.value("file-tags").toArray().contains("android.manifest_final"))
|
|
|
|
|
return artifact.value("file-path").toString();
|
2019-04-03 18:10:35 +02:00
|
|
|
}
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-15 10:13:03 +03:00
|
|
|
if (role == Android::Constants::AndroidApk)
|
2019-06-28 14:30:32 +02:00
|
|
|
return m_productData.value("target-executable").toString();
|
2019-04-03 18:10:35 +02:00
|
|
|
|
2019-07-16 17:06:29 +02:00
|
|
|
if (role == ProjectExplorer::Constants::QT_KEYWORDS_ENABLED)
|
2019-06-28 14:30:32 +02:00
|
|
|
return m_productData.value("module-properties").toObject()
|
|
|
|
|
.value("Qt.core.enableKeywords").toBool();
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
}
|
2019-07-16 17:06:29 +02:00
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
QJsonObject QbsProductNode::mainGroup() const
|
|
|
|
|
{
|
|
|
|
|
for (const QJsonValue &g : m_productData.value("groups").toArray()) {
|
|
|
|
|
const QJsonObject grp = g.toObject();
|
|
|
|
|
if (grp.value("name") == m_productData.value("name")
|
|
|
|
|
&& grp.value("location") == m_productData.value("location")) {
|
|
|
|
|
return grp;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-03 18:10:35 +02:00
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsProjectNode:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
QbsProjectNode::QbsProjectNode(const QJsonObject &projectData)
|
|
|
|
|
: ProjectNode(FilePath()), m_projectData(projectData)
|
2013-06-18 13:09:06 +02:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
static QIcon projectIcon = Core::FileIconProvider::directoryIcon(
|
|
|
|
|
ProjectExplorer::Constants::FILEOVERLAY_QT);
|
2017-03-21 10:35:50 +01:00
|
|
|
setIcon(projectIcon);
|
2019-06-28 14:30:32 +02:00
|
|
|
setDisplayName(projectData.value("name").toString());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|