Commit 38320b15 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

QbsProjectManager: Take product profiles into account.



- Identify products by the name/profile tuple instead of just the name.
- If the product's profile differs from that of the overall
project, add it to the visual representation.

Change-Id: I4a89db60911277977458370157e435472bbe428f
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
parent 48f19e92
......@@ -549,7 +549,7 @@ void QbsGroupNode::setupFolder(ProjectExplorer::FolderNode *root,
// QbsProductNode:
// --------------------------------------------------------------------
QbsProductNode::QbsProductNode(const qbs::ProductData &prd) :
QbsProductNode::QbsProductNode(const qbs::Project &project, const qbs::ProductData &prd) :
QbsBaseProjectNode(prd.location().fileName())
{
if (m_productIcon.isNull())
......@@ -562,7 +562,7 @@ QbsProductNode::QbsProductNode(const qbs::ProductData &prd) :
prd.location().line());
addFileNodes(QList<ProjectExplorer::FileNode *>() << idx);
setQbsProductData(prd);
setQbsProductData(project, prd);
}
bool QbsProductNode::isEnabled() const
......@@ -622,7 +622,7 @@ bool QbsProductNode::removeFiles(const QStringList &filePaths, QStringList *notR
QTC_ASSERT(false, return false);
}
void QbsProductNode::setQbsProductData(const qbs::ProductData prd)
void QbsProductNode::setQbsProductData(const qbs::Project &project, const qbs::ProductData prd)
{
if (m_qbsProductData == prd)
return;
......@@ -631,7 +631,7 @@ void QbsProductNode::setQbsProductData(const qbs::ProductData prd)
bool productIsEnabled = prd.isEnabled();
bool updateExisting = productWasEnabled != productIsEnabled;
setDisplayName(prd.name());
setDisplayName(QbsProject::productDisplayName(project, prd));
setPath(prd.location().fileName());
const QString &productPath = QFileInfo(prd.location().fileName()).absolutePath();
......@@ -685,7 +685,7 @@ QList<ProjectExplorer::RunConfiguration *> QbsProductNode::runConfigurations() c
QbsRunConfiguration *qbsRc = qobject_cast<QbsRunConfiguration *>(rc);
if (!qbsRc)
continue;
if (qbsRc->qbsProduct() == qbsProductData().name())
if (qbsRc->uniqueProductName() == QbsProject::uniqueProductName(qbsProductData()))
result << qbsRc;
}
......@@ -717,13 +717,7 @@ QbsProjectNode::~QbsProjectNode()
// do not delete m_project
}
bool QbsProjectNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
{
QbsProductNode *prd = findProductNode(displayName());
return prd ? prd->addFiles(filePaths, notAdded) : false;
}
void QbsProjectNode::update(const qbs::ProjectData &prjData)
void QbsProjectNode::update(const qbs::Project &qbsProject, const qbs::ProjectData &prjData)
{
QList<ProjectExplorer::ProjectNode *> toAdd;
QList<ProjectExplorer::ProjectNode *> toRemove = subProjectNodes();
......@@ -732,20 +726,20 @@ void QbsProjectNode::update(const qbs::ProjectData &prjData)
QbsProjectNode *qn = findProjectNode(subData.name());
if (!qn) {
QbsProjectNode *subProject = new QbsProjectNode(subData.location().fileName());
subProject->update(subData);
subProject->update(qbsProject, subData);
toAdd << subProject;
} else {
qn->update(subData);
qn->update(qbsProject, subData);
toRemove.removeOne(qn);
}
}
foreach (const qbs::ProductData &prd, prjData.products()) {
QbsProductNode *qn = findProductNode(prd.name());
QbsProductNode *qn = findProductNode(QbsProject::uniqueProductName(prd));
if (!qn) {
toAdd << new QbsProductNode(prd);
toAdd << new QbsProductNode(qbsProject, prd);
} else {
qn->setQbsProductData(prd);
qn->setQbsProductData(qbsProject, prd);
toRemove.removeOne(qn);
}
}
......@@ -785,11 +779,11 @@ void QbsProjectNode::ctor()
<< new ProjectExplorer::FileNode(path(), ProjectExplorer::ProjectFileType, false));
}
QbsProductNode *QbsProjectNode::findProductNode(const QString &name)
QbsProductNode *QbsProjectNode::findProductNode(const QString &uniqueName)
{
foreach (ProjectExplorer::ProjectNode *n, subProjectNodes()) {
QbsProductNode *qn = qobject_cast<QbsProductNode *>(n);
if (qn && qn->qbsProductData().name() == name)
if (qn && QbsProject::uniqueProductName(qn->qbsProductData()) == uniqueName)
return qn;
}
return 0;
......@@ -830,7 +824,7 @@ void QbsRootProjectNode::update()
}
QbsGroupNode::setupFiles(m_buildSystemFiles, projectBuildSystemFiles, base.toString(), false);
update(m_project->qbsProjectData());
update(m_project->qbsProject(), m_project->qbsProjectData());
}
static QSet<QString> referencedBuildSystemFiles(const qbs::ProjectData &data)
......
......@@ -132,7 +132,7 @@ class QbsProductNode : public QbsBaseProjectNode
Q_OBJECT
public:
explicit QbsProductNode(const qbs::ProductData &prd);
explicit QbsProductNode(const qbs::Project &project, const qbs::ProductData &prd);
bool isEnabled() const;
bool showInSimpleTree() const;
......@@ -140,7 +140,7 @@ public:
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0);
void setQbsProductData(const qbs::ProductData prd);
void setQbsProductData(const qbs::Project &project, const qbs::ProductData prd);
const qbs::ProductData qbsProductData() const { return m_qbsProductData; }
QList<ProjectExplorer::RunConfiguration *> runConfigurations() const;
......@@ -164,8 +164,6 @@ public:
explicit QbsProjectNode(const QString &path);
~QbsProjectNode();
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
virtual QbsProject *project() const;
const qbs::Project qbsProject() const;
const qbs::ProjectData qbsProjectData() const { return m_projectData; }
......@@ -173,12 +171,12 @@ public:
bool showInSimpleTree() const;
protected:
void update(const qbs::ProjectData &prjData);
void update(const qbs::Project &qbsProject, const qbs::ProjectData &prjData);
private:
void ctor();
QbsProductNode *findProductNode(const QString &name);
QbsProductNode *findProductNode(const QString &uniqueName);
QbsProjectNode *findProjectNode(const QString &name);
static QIcon m_projectIcon;
......
......@@ -322,7 +322,7 @@ qbs::BuildJob *QbsProject::build(const qbs::BuildOptions &opts, QStringList prod
foreach (const QString &productName, productNames) {
bool found = false;
foreach (const qbs::ProductData &data, qbsProjectData().allProducts()) {
if (data.name() == productName) {
if (uniqueProductName(data) == productName) {
found = true;
products.append(data);
break;
......@@ -583,6 +583,20 @@ void QbsProject::generateErrors(const qbs::ErrorInfo &e)
}
QString QbsProject::productDisplayName(const qbs::Project &project,
const qbs::ProductData &product)
{
QString displayName = product.name();
if (product.profile() != project.profile())
displayName.append(QLatin1String(" [")).append(product.profile()).append(QLatin1Char(']'));
return displayName;
}
QString QbsProject::uniqueProductName(const qbs::ProductData &product)
{
return product.name() + QLatin1Char('.') + product.profile();
}
void QbsProject::parse(const QVariantMap &config, const Environment &env, const QString &dir)
{
prepareForParsing();
......@@ -764,14 +778,15 @@ void QbsProject::updateQmlJsCodeModel(const qbs::ProjectData &prj)
modelManager->updateProjectInfo(projectInfo, this);
}
void QbsProject::updateApplicationTargets(const qbs::ProjectData &projectData)
void QbsProject::updateApplicationTargets()
{
ProjectExplorer::BuildTargetInfoList applications;
foreach (const qbs::ProductData &productData, projectData.allProducts()) {
foreach (const qbs::ProductData &productData, m_projectData.allProducts()) {
if (!productData.isEnabled() || !productData.isRunnable())
continue;
const QString displayName = productDisplayName(m_qbsProject, productData);
if (productData.targetArtifacts().isEmpty()) { // No build yet.
applications.list << ProjectExplorer::BuildTargetInfo(productData.name(),
applications.list << ProjectExplorer::BuildTargetInfo(displayName,
Utils::FileName(),
Utils::FileName::fromString(productData.location().fileName()));
continue;
......@@ -780,7 +795,7 @@ void QbsProject::updateApplicationTargets(const qbs::ProjectData &projectData)
QTC_ASSERT(ta.isValid(), continue);
if (!ta.isExecutable())
continue;
applications.list << ProjectExplorer::BuildTargetInfo(productData.name(),
applications.list << ProjectExplorer::BuildTargetInfo(displayName,
Utils::FileName::fromString(ta.filePath()),
Utils::FileName::fromString(productData.location().fileName()));
}
......@@ -788,14 +803,14 @@ void QbsProject::updateApplicationTargets(const qbs::ProjectData &projectData)
activeTarget()->setApplicationTargets(applications);
}
void QbsProject::updateDeploymentInfo(const qbs::Project &project)
void QbsProject::updateDeploymentInfo()
{
ProjectExplorer::DeploymentData deploymentData;
if (project.isValid()) {
if (m_qbsProject.isValid()) {
qbs::InstallOptions installOptions;
installOptions.setInstallRoot(QLatin1String("/"));
foreach (const qbs::InstallableFile &f,
project.installableFilesForProject(m_projectData, installOptions)) {
foreach (const qbs::InstallableFile &f, m_qbsProject
.installableFilesForProject(m_projectData, installOptions)) {
deploymentData.addFile(f.sourceFilePath(), f.targetDirectory(), f.isExecutable()
? ProjectExplorer::DeployableFile::TypeExecutable
: ProjectExplorer::DeployableFile::TypeNormal);
......@@ -806,8 +821,8 @@ void QbsProject::updateDeploymentInfo(const qbs::Project &project)
void QbsProject::updateBuildTargetData()
{
updateApplicationTargets(m_projectData);
updateDeploymentInfo(m_qbsProject);
updateApplicationTargets();
updateDeploymentInfo();
foreach (Target *t, targets())
t->updateDefaultRunConfigurations();
}
......
......@@ -105,6 +105,10 @@ public:
bool needsSpecialDeployment() const;
void generateErrors(const qbs::ErrorInfo &e);
static QString productDisplayName(const qbs::Project &project,
const qbs::ProductData &product);
static QString uniqueProductName(const qbs::ProductData &product);
public slots:
void invalidate();
void delayParsing();
......@@ -131,8 +135,8 @@ private:
void updateDocuments(const QSet<QString> &files);
void updateCppCodeModel(const qbs::ProjectData &prj);
void updateQmlJsCodeModel(const qbs::ProjectData &prj);
void updateApplicationTargets(const qbs::ProjectData &projectData);
void updateDeploymentInfo(const qbs::Project &project);
void updateApplicationTargets();
void updateDeploymentInfo();
void updateBuildTargetData();
static bool ensureWriteableQbsFile(const QString &file);
......
......@@ -398,7 +398,7 @@ void QbsProjectManagerPlugin::buildSubprojectContextMenu()
QStringList toBuild;
foreach (const qbs::ProductData &data, subProject->qbsProjectData().allProducts())
toBuild << data.name();
toBuild << QbsProject::uniqueProductName(data);
buildProducts(m_selectedProject, toBuild);
}
......@@ -424,7 +424,7 @@ void QbsProjectManagerPlugin::buildSubproject()
QStringList toBuild;
foreach (const qbs::ProductData &data, subproject->qbsProjectData().allProducts())
toBuild << data.name();
toBuild << QbsProject::uniqueProductName(data);
buildProducts(m_editorProject, toBuild);
}
......
......@@ -63,39 +63,55 @@
using namespace ProjectExplorer;
namespace {
namespace QbsProjectManager {
namespace Internal {
const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
const char COMMAND_LINE_ARGUMENTS_KEY[] = "Qbs.RunConfiguration.CommandLineArguments";
const char USE_TERMINAL_KEY[] = "Qbs.RunConfiguration.UseTerminal";
const char USER_WORKING_DIRECTORY_KEY[] = "Qbs.RunConfiguration.UserWorkingDirectory";
QString productFromId(Core::Id id)
static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); }
static Core::Id idFromProduct(const QbsProject *project, const qbs::ProductData &product)
{
return id.suffixAfter(QBS_RC_PREFIX);
QString id = QLatin1String(QBS_RC_PREFIX);
id.append(QbsProject::uniqueProductName(product)).append(rcNameSeparator())
.append(QbsProject::productDisplayName(project->qbsProject(), product));
return Core::Id::fromString(id);
}
const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &name)
static QString uniqueProductNameFromId(Core::Id id)
{
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
return suffix.left(suffix.indexOf(rcNameSeparator()));
}
static QString productDisplayNameFromId(Core::Id id)
{
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
const int sepPos = suffix.indexOf(rcNameSeparator());
if (sepPos == -1)
return suffix;
return suffix.mid(sepPos + rcNameSeparator().count());
}
const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &uniqeName)
{
foreach (const qbs::ProductData &product, pro.allProducts()) {
if (product.name() == name)
if (QbsProject::uniqueProductName(product) == uniqeName)
return product;
}
return qbs::ProductData();
}
} // namespace
namespace QbsProjectManager {
namespace Internal {
// --------------------------------------------------------------------
// QbsRunConfiguration:
// --------------------------------------------------------------------
QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
LocalApplicationRunConfiguration(parent, id),
m_qbsProduct(productFromId(id)),
m_uniqueProductName(uniqueProductNameFromId(id)),
m_runMode(ApplicationLauncher::Gui),
m_currentInstallStep(0),
m_currentBuildStepList(0)
......@@ -107,7 +123,7 @@ QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
LocalApplicationRunConfiguration(parent, source),
m_qbsProduct(source->m_qbsProduct),
m_uniqueProductName(source->m_uniqueProductName),
m_commandLineArguments(source->m_commandLineArguments),
m_runMode(source->m_runMode),
m_userWorkingDirectory(source->m_userWorkingDirectory),
......@@ -217,7 +233,7 @@ void QbsRunConfiguration::installStepToBeRemoved(int pos)
QString QbsRunConfiguration::executable() const
{
QbsProject *pro = static_cast<QbsProject *>(target()->project());
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_qbsProduct);
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_uniqueProductName);
if (!product.isValid() || !pro->qbsProject().isValid())
return QString();
......@@ -233,7 +249,7 @@ ApplicationLauncher::Mode QbsRunConfiguration::runMode() const
bool QbsRunConfiguration::isConsoleApplication() const
{
QbsProject *pro = static_cast<QbsProject *>(target()->project());
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_qbsProduct);
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_uniqueProductName);
foreach (const qbs::TargetArtifact &ta, product.targetArtifacts()) {
if (ta.isExecutable())
return !ta.properties().getProperty(QLatin1String("consoleApplication")).toBool();
......@@ -300,7 +316,7 @@ void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
{
QbsProject *project = static_cast<QbsProject *>(target()->project());
if (project) {
const qbs::ProductData product = findProduct(project->qbsProjectData(), m_qbsProduct);
const qbs::ProductData product = findProduct(project->qbsProjectData(), m_uniqueProductName);
if (product.isValid()) {
qbs::RunEnvironment qbsRunEnv = project->qbsProject().getRunEnvironment(product, installOptions(),
env.toProcessEnvironment(), QbsManager::settings());
......@@ -318,17 +334,15 @@ void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
}
QString QbsRunConfiguration::qbsProduct() const
QString QbsRunConfiguration::uniqueProductName() const
{
return m_qbsProduct;
return m_uniqueProductName;
}
QString QbsRunConfiguration::defaultDisplayName()
{
QString defaultName;
if (!m_qbsProduct.isEmpty())
defaultName = m_qbsProduct;
else
QString defaultName = productDisplayNameFromId(id());
if (defaultName.isEmpty())
defaultName = tr("Qbs Run Configuration");
return defaultName;
}
......@@ -545,7 +559,7 @@ bool QbsRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
return false;
QbsProject *project = static_cast<QbsProject *>(parent->project());
return findProduct(project->qbsProjectData(), productFromId(id)).isValid();
return findProduct(project->qbsProjectData(), uniqueProductNameFromId(id)).isValid();
}
RunConfiguration *QbsRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
......@@ -591,7 +605,7 @@ QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(Target *parent,
foreach (const qbs::ProductData &product, project->qbsProjectData().allProducts()) {
if (product.isRunnable() && product.isEnabled())
result << Core::Id::fromString(QString::fromLatin1(QBS_RC_PREFIX) + product.name());
result << idFromProduct(project, product);
}
return result;
......@@ -599,7 +613,7 @@ QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(Target *parent,
QString QbsRunConfigurationFactory::displayNameForId(Core::Id id) const
{
return productFromId(id);
return productDisplayNameFromId(id);
}
bool QbsRunConfigurationFactory::canHandle(Target *t) const
......
......@@ -89,7 +89,7 @@ public:
void addToBaseEnvironment(Utils::Environment &env) const;
QString qbsProduct() const;
QString uniqueProductName() const;
bool isConsoleApplication() const;
signals:
......@@ -120,7 +120,7 @@ private:
void updateTarget();
QString m_qbsProduct;
QString m_uniqueProductName;
QString m_commandLineArguments;
// Cached startup sub project information
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment