forked from qt-creator/qt-creator
Fixed loading of build configurations.
Change-Id: Ib9c7924c503440982455b5fc58c8fa2decd9301a Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
132
src/plugins/vcprojectmanager/utils.cpp
Normal file
132
src/plugins/vcprojectmanager/utils.cpp
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (c) 2014 Bojan Petrovic
|
||||||
|
** Copyright (c) 2014 Radovan Zivkovic
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** 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
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vcschemamanager.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QXmlSchema>
|
||||||
|
#include <QXmlSchemaValidator>
|
||||||
|
|
||||||
|
namespace VcProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
|
bool checkIfVersion2003(const QString &filePath)
|
||||||
|
{
|
||||||
|
VcSchemaManager *schemaMgr = VcSchemaManager::instance();
|
||||||
|
QString vc2003Schema = schemaMgr->documentSchema(Constants::SV_2003);
|
||||||
|
|
||||||
|
if (vc2003Schema.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile schemaFile(vc2003Schema);
|
||||||
|
schemaFile.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QXmlSchema schema;
|
||||||
|
schema.load(&schemaFile, QUrl::fromLocalFile(schemaFile.fileName()));
|
||||||
|
|
||||||
|
if (schema.isValid()) {
|
||||||
|
QFile file(filePath);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QXmlSchemaValidator validator(schema);
|
||||||
|
if (validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkIfVersion2005(const QString &filePath)
|
||||||
|
{
|
||||||
|
VcSchemaManager *schemaMgr = VcSchemaManager::instance();
|
||||||
|
QString vc2005Schema = schemaMgr->documentSchema(Constants::SV_2005);
|
||||||
|
if (vc2005Schema.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QFile schemaFile(vc2005Schema);
|
||||||
|
schemaFile.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QXmlSchema schema;
|
||||||
|
schema.load(&schemaFile, QUrl::fromLocalFile(schemaFile.fileName()));
|
||||||
|
|
||||||
|
if (schema.isValid()) {
|
||||||
|
QFile file(filePath);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QXmlSchemaValidator validator(schema);
|
||||||
|
if (validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkIfVersion2008(const QString &filePath)
|
||||||
|
{
|
||||||
|
VcSchemaManager *schemaMgr = VcSchemaManager::instance();
|
||||||
|
QString vc2008Schema = schemaMgr->documentSchema(Constants::SV_2008);
|
||||||
|
if (vc2008Schema.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QFile schemaFile(vc2008Schema);
|
||||||
|
schemaFile.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QXmlSchema schema;
|
||||||
|
schema.load(&schemaFile, QUrl::fromLocalFile(schemaFile.fileName()));
|
||||||
|
|
||||||
|
if (schema.isValid()) {
|
||||||
|
QFile file(filePath);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QXmlSchemaValidator validator(schema);
|
||||||
|
if (validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
VcDocConstants::DocumentVersion getProjectVersion(const QString &projectPath)
|
||||||
|
{
|
||||||
|
if (checkIfVersion2003(projectPath))
|
||||||
|
return VcDocConstants::DV_MSVC_2003;
|
||||||
|
else if (checkIfVersion2005(projectPath))
|
||||||
|
return VcDocConstants::DV_MSVC_2005;
|
||||||
|
else if (checkIfVersion2008(projectPath))
|
||||||
|
return VcDocConstants::DV_MSVC_2008;
|
||||||
|
|
||||||
|
return VcDocConstants::DV_UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Utils
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace VcProjectManager
|
47
src/plugins/vcprojectmanager/utils.h
Normal file
47
src/plugins/vcprojectmanager/utils.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (c) 2014 Bojan Petrovic
|
||||||
|
** Copyright (c) 2014 Radovan Zivkovic
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** 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
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef VCPROJECTMANAGER_INTERNAL_UTILS_H
|
||||||
|
#define VCPROJECTMANAGER_INTERNAL_UTILS_H
|
||||||
|
|
||||||
|
#include "vcprojectmodel/vcprojectdocument_constants.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace VcProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
|
VcDocConstants::DocumentVersion getProjectVersion(const QString &projectPath);
|
||||||
|
|
||||||
|
} // namespace Utils
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace VcProjectManager
|
||||||
|
|
||||||
|
#endif // VCPROJECTMANAGER_INTERNAL_UTILS_H
|
@@ -196,14 +196,10 @@ QString VcMakeStepConfigWidget::displayName() const
|
|||||||
|
|
||||||
QString VcMakeStepConfigWidget::summaryText() const
|
QString VcMakeStepConfigWidget::summaryText() const
|
||||||
{
|
{
|
||||||
VcProjectBuildConfiguration *bc = m_makeStep->vcProjectBuildConfiguration();
|
|
||||||
ProjectExplorer::Project *project = bc->target()->project();
|
|
||||||
VcProjectFile* document = static_cast<VcProjectFile *>(project->document());
|
|
||||||
MsBuildInformation *msBuild = VcProjectKitInformation::msBuildInfo(m_makeStep->target()->kit());
|
MsBuildInformation *msBuild = VcProjectKitInformation::msBuildInfo(m_makeStep->target()->kit());
|
||||||
|
|
||||||
QFileInfo fileInfo(msBuild->m_executable);
|
QFileInfo fileInfo(msBuild->m_executable);
|
||||||
return QString(QLatin1String("<b>MsBuild:</b> %1 %2 %3")).arg(fileInfo.fileName())
|
return QString(QLatin1String("<b>MsBuild:</b> %1 %2")).arg(fileInfo.fileName())
|
||||||
.arg(document->filePath())
|
|
||||||
.arg(m_makeStep->buildArgumentsToString());
|
.arg(m_makeStep->buildArgumentsToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "vcproject.h"
|
#include "vcproject.h"
|
||||||
|
|
||||||
|
#include "vcmakestep.h"
|
||||||
#include "vcprojectbuildconfiguration.h"
|
#include "vcprojectbuildconfiguration.h"
|
||||||
#include "vcprojectfile.h"
|
#include "vcprojectfile.h"
|
||||||
#include "vcprojectkitinformation.h"
|
#include "vcprojectkitinformation.h"
|
||||||
@@ -53,6 +55,8 @@
|
|||||||
|
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
|
#include <projectexplorer/buildinfo.h>
|
||||||
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/headerpath.h>
|
#include <projectexplorer/headerpath.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
@@ -135,17 +139,6 @@ QStringList VcProject::files(Project::FilesMode fileMode) const
|
|||||||
return sl;
|
return sl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VcProject::defaultBuildDirectory() const
|
|
||||||
{
|
|
||||||
VcProjectFile* vcFile = static_cast<VcProjectFile *>(document());
|
|
||||||
return defaultBuildDirectory(vcFile->filePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString VcProject::defaultBuildDirectory(const QString &fileName)
|
|
||||||
{
|
|
||||||
return QFileInfo(fileName).absolutePath() /* + QLatin1String("-build")*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VcProject::needsConfiguration() const
|
bool VcProject::needsConfiguration() const
|
||||||
{
|
{
|
||||||
return targets().isEmpty() || !activeTarget() || activeTarget()->buildConfigurations().isEmpty();
|
return targets().isEmpty() || !activeTarget() || activeTarget()->buildConfigurations().isEmpty();
|
||||||
@@ -221,14 +214,6 @@ bool VcProject::fromMap(const QVariantMap &map)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VcProject::setupTarget(ProjectExplorer::Target *t)
|
|
||||||
{
|
|
||||||
t->updateDefaultBuildConfigurations();
|
|
||||||
t->updateDefaultDeployConfigurations();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Visit folder node recursive and accumulate Source and Header files
|
* @brief Visit folder node recursive and accumulate Source and Header files
|
||||||
*/
|
*/
|
||||||
@@ -331,21 +316,6 @@ void VcProject::importBuildConfigurations()
|
|||||||
addTarget(createTarget(kit));
|
addTarget(createTarget(kit));
|
||||||
}
|
}
|
||||||
|
|
||||||
VcProjectBuildConfiguration *VcProject::findBuildConfiguration(Target *target, const QString &buildConfigurationName) const
|
|
||||||
{
|
|
||||||
if (target) {
|
|
||||||
QList<ProjectExplorer::BuildConfiguration *> buildConfigurationList = target->buildConfigurations();
|
|
||||||
|
|
||||||
foreach (ProjectExplorer::BuildConfiguration *bc, buildConfigurationList) {
|
|
||||||
VcProjectBuildConfiguration *vcBc = qobject_cast<VcProjectBuildConfiguration *>(bc);
|
|
||||||
if (vcBc && vcBc->displayName() == buildConfigurationName)
|
|
||||||
return vcBc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VcProject::allProjectFile(QStringList &allFiles) const
|
void VcProject::allProjectFile(QStringList &allFiles) const
|
||||||
{
|
{
|
||||||
if (m_projectFile && m_projectFile->documentModel() && m_projectFile->documentModel()->vcProjectDocument()) {
|
if (m_projectFile && m_projectFile->documentModel() && m_projectFile->documentModel()->vcProjectDocument()) {
|
||||||
|
@@ -63,8 +63,6 @@ public:
|
|||||||
ProjectExplorer::IProjectManager *projectManager() const;
|
ProjectExplorer::IProjectManager *projectManager() const;
|
||||||
ProjectExplorer::ProjectNode *rootProjectNode() const;
|
ProjectExplorer::ProjectNode *rootProjectNode() const;
|
||||||
QStringList files(FilesMode fileMode) const;
|
QStringList files(FilesMode fileMode) const;
|
||||||
QString defaultBuildDirectory() const;
|
|
||||||
static QString defaultBuildDirectory(const QString &fileName);
|
|
||||||
bool needsConfiguration() const;
|
bool needsConfiguration() const;
|
||||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const;
|
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const;
|
||||||
|
|
||||||
@@ -76,14 +74,13 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool fromMap(const QVariantMap &map);
|
bool fromMap(const QVariantMap &map);
|
||||||
bool setupTarget(ProjectExplorer::Target *t);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addCxxModelFiles(const ProjectExplorer::FolderNode *node, QStringList &sourceFiles);
|
void addCxxModelFiles(const ProjectExplorer::FolderNode *node, QStringList &sourceFiles);
|
||||||
void updateCodeModels();
|
void updateCodeModels();
|
||||||
void importBuildConfigurations();
|
void importBuildConfigurations();
|
||||||
VcProjectBuildConfiguration *findBuildConfiguration(ProjectExplorer::Target *target, const QString &buildConfigurationName) const;
|
|
||||||
void allProjectFile(QStringList &allFiles) const;
|
void allProjectFile(QStringList &allFiles) const;
|
||||||
|
|
||||||
VcManager *m_projectManager;
|
VcManager *m_projectManager;
|
||||||
VcProjectFile *m_projectFile;
|
VcProjectFile *m_projectFile;
|
||||||
VcDocProjectNode *m_rootNode;
|
VcDocProjectNode *m_rootNode;
|
||||||
|
@@ -28,8 +28,19 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "vcmakestep.h"
|
#include "vcmakestep.h"
|
||||||
|
|
||||||
|
#include "interfaces/ivisualstudioproject.h"
|
||||||
|
#include "interfaces/iconfiguration.h"
|
||||||
|
#include "interfaces/iconfigurations.h"
|
||||||
|
#include "interfaces/ifile.h"
|
||||||
|
#include "interfaces/ifilecontainer.h"
|
||||||
|
|
||||||
#include "vcprojectbuildconfiguration.h"
|
#include "vcprojectbuildconfiguration.h"
|
||||||
|
#include "vcprojectfile.h"
|
||||||
#include "vcprojectmanagerconstants.h"
|
#include "vcprojectmanagerconstants.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vcprojectmodel/configurationcontainer.h"
|
||||||
|
#include "vcprojectmodel/vcdocumentmodel.h"
|
||||||
|
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <projectexplorer/buildinfo.h>
|
#include <projectexplorer/buildinfo.h>
|
||||||
@@ -59,7 +70,8 @@ namespace Internal {
|
|||||||
VcProjectBuildConfiguration::VcProjectBuildConfiguration(Target *parent) :
|
VcProjectBuildConfiguration::VcProjectBuildConfiguration(Target *parent) :
|
||||||
BuildConfiguration(parent, Core::Id(VC_PROJECT_BC_ID))
|
BuildConfiguration(parent, Core::Id(VC_PROJECT_BC_ID))
|
||||||
{
|
{
|
||||||
m_buildDirectory = static_cast<VcProject *>(parent->project())->defaultBuildDirectory();
|
QFileInfo info(static_cast<VcProjectFile *>(parent->project()->document())->documentModel()->vcProjectDocument()->filePath());
|
||||||
|
m_buildDirectory = info.canonicalPath() + QLatin1String("-build");
|
||||||
}
|
}
|
||||||
|
|
||||||
VcProjectBuildConfiguration::~VcProjectBuildConfiguration()
|
VcProjectBuildConfiguration::~VcProjectBuildConfiguration()
|
||||||
@@ -131,20 +143,46 @@ int VcProjectBuildConfigurationFactory::priority(const Kit *k, const QString &pr
|
|||||||
QList<BuildInfo *> VcProjectBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
QList<BuildInfo *> VcProjectBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
||||||
{
|
{
|
||||||
QList<BuildInfo *> result;
|
QList<BuildInfo *> result;
|
||||||
result << createBuildInfo(parent->kit(),
|
|
||||||
parent->project()->projectDirectory());
|
VcProjectFile *vcProjectFile = qobject_cast<VcProjectFile *>(parent->project()->document());
|
||||||
|
QTC_ASSERT(vcProjectFile, return result);
|
||||||
|
|
||||||
|
IVisualStudioProject *vsProject = vcProjectFile->documentModel()->vcProjectDocument();
|
||||||
|
QTC_ASSERT(vsProject, return result);
|
||||||
|
|
||||||
|
QTC_ASSERT(vsProject->configurations(), return result);
|
||||||
|
QTC_ASSERT(vsProject->configurations()->configurationContainer(), return result);
|
||||||
|
|
||||||
|
for (int i = 0; i < vsProject->configurations()->configurationContainer()->configurationCount(); ++i) {
|
||||||
|
IConfiguration *config = vsProject->configurations()->configurationContainer()->configuration(i);
|
||||||
|
QTC_ASSERT(config, continue);
|
||||||
|
|
||||||
|
result << createBuildInfo(parent->kit(), config);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<BuildInfo *> VcProjectBuildConfigurationFactory::availableSetups(
|
QList<BuildInfo *> VcProjectBuildConfigurationFactory::availableSetups(
|
||||||
const Kit *k, const QString &projectPath) const
|
const Kit *k, const QString &projectPath) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(k);
|
||||||
QList<BuildInfo *> result;
|
QList<BuildInfo *> result;
|
||||||
// TODO: Populate from Configuration
|
|
||||||
BuildInfo *info = createBuildInfo(k,
|
VcDocConstants::DocumentVersion docVersion = Utils::getProjectVersion(projectPath);
|
||||||
Utils::FileName::fromString(VcProject::defaultBuildDirectory(projectPath)));
|
VcDocumentModel documentModel = VcDocumentModel(projectPath, docVersion);
|
||||||
info->displayName = tr("Default");
|
IVisualStudioProject *vsProject = documentModel.vcProjectDocument();
|
||||||
result << info;
|
QTC_ASSERT(vsProject, return result);
|
||||||
|
|
||||||
|
QTC_ASSERT(vsProject->configurations(), return result);
|
||||||
|
QTC_ASSERT(vsProject->configurations()->configurationContainer(), return result);
|
||||||
|
|
||||||
|
for (int i = 0; i < vsProject->configurations()->configurationContainer()->configurationCount(); ++i) {
|
||||||
|
IConfiguration *config = vsProject->configurations()->configurationContainer()->configuration(i);
|
||||||
|
QTC_ASSERT(config, continue);
|
||||||
|
|
||||||
|
result << createBuildInfo(k, config);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,10 +193,29 @@ VcProjectBuildConfiguration *VcProjectBuildConfigurationFactory::create(Target *
|
|||||||
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
||||||
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
||||||
|
|
||||||
|
VcProjectFile *vcProjectFile = qobject_cast<VcProjectFile *>(parent->project()->document());
|
||||||
|
QTC_ASSERT(vcProjectFile, return 0);
|
||||||
|
|
||||||
VcProjectBuildConfiguration *bc = new VcProjectBuildConfiguration(parent);
|
VcProjectBuildConfiguration *bc = new VcProjectBuildConfiguration(parent);
|
||||||
bc->setDisplayName(info->displayName);
|
bc->setDisplayName(info->displayName);
|
||||||
bc->setDefaultDisplayName(info->displayName);
|
bc->setDefaultDisplayName(info->displayName);
|
||||||
bc->setBuildDirectory(info->buildDirectory);
|
|
||||||
|
BuildStepList *buildSteps = bc->stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD));
|
||||||
|
BuildStepList *cleanSteps = bc->stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN));
|
||||||
|
QTC_ASSERT(buildSteps, return 0);
|
||||||
|
QTC_ASSERT(cleanSteps, return 0);
|
||||||
|
|
||||||
|
VcMakeStep *makeStep = new VcMakeStep(buildSteps);
|
||||||
|
QString argument(QLatin1String("/p:configuration=\"") + info->displayName + QLatin1String("\""));
|
||||||
|
makeStep->addBuildArgument(vcProjectFile->filePath());
|
||||||
|
makeStep->addBuildArgument(argument);
|
||||||
|
buildSteps->insertStep(0, makeStep);
|
||||||
|
|
||||||
|
makeStep = new VcMakeStep(cleanSteps);
|
||||||
|
argument = QLatin1String("/p:configuration=\"") + info->displayName + QLatin1String("\" /t:Clean");
|
||||||
|
makeStep->addBuildArgument(vcProjectFile->filePath());
|
||||||
|
makeStep->addBuildArgument(argument);
|
||||||
|
cleanSteps->insertStep(0, makeStep);
|
||||||
|
|
||||||
return bc;
|
return bc;
|
||||||
}
|
}
|
||||||
@@ -203,15 +260,15 @@ bool VcProjectBuildConfigurationFactory::canHandle(const Target *t) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
BuildInfo *VcProjectBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k,
|
BuildInfo *VcProjectBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k,
|
||||||
const Utils::FileName &buildDir) const
|
IConfiguration *config) const
|
||||||
{
|
{
|
||||||
BuildInfo *info = new BuildInfo(this);
|
ProjectExplorer::BuildInfo *buildInfo = new ProjectExplorer::BuildInfo(this);
|
||||||
info->typeName = tr("Build");
|
buildInfo->displayName = config->fullName();
|
||||||
info->buildDirectory = buildDir;
|
buildInfo->kitId = k->id();
|
||||||
info->kitId = k->id();
|
buildInfo->supportsShadowBuild = true;
|
||||||
info->supportsShadowBuild = true;
|
buildInfo->typeName = config->fullName();
|
||||||
|
|
||||||
return info;
|
return buildInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -74,7 +74,6 @@ class VcProjectBuildConfigurationFactory : public ProjectExplorer::IBuildConfigu
|
|||||||
public:
|
public:
|
||||||
explicit VcProjectBuildConfigurationFactory(QObject *parent = 0);
|
explicit VcProjectBuildConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(const ProjectExplorer::Target *parent) const;
|
|
||||||
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const;
|
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const;
|
||||||
QList<ProjectExplorer::BuildInfo *> availableSetups(const ProjectExplorer::Kit *k, const QString &projectPath) const;
|
QList<ProjectExplorer::BuildInfo *> availableSetups(const ProjectExplorer::Kit *k, const QString &projectPath) const;
|
||||||
bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||||
@@ -89,7 +88,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool canHandle(const ProjectExplorer::Target *t) const;
|
bool canHandle(const ProjectExplorer::Target *t) const;
|
||||||
ProjectExplorer::BuildInfo *createBuildInfo(const ProjectExplorer::Kit *k,
|
ProjectExplorer::BuildInfo *createBuildInfo(const ProjectExplorer::Kit *k,
|
||||||
const Utils::FileName &buildDir) const;
|
IConfiguration *config) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "vcprojectmanager.h"
|
#include "vcprojectmanager.h"
|
||||||
#include "vcprojectmanagerconstants.h"
|
#include "vcprojectmanagerconstants.h"
|
||||||
#include "vcschemamanager.h"
|
#include "vcschemamanager.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "vcprojectmodel/vcprojectdocument_constants.h"
|
#include "vcprojectmodel/vcprojectdocument_constants.h"
|
||||||
|
|
||||||
#include <QtXmlPatterns/QXmlSchema>
|
#include <QtXmlPatterns/QXmlSchema>
|
||||||
@@ -65,14 +66,7 @@ ProjectExplorer::Project *VcManager::openProject(const QString &fileName, QStrin
|
|||||||
|
|
||||||
// check if project is a valid vc project
|
// check if project is a valid vc project
|
||||||
// versions supported are 2003, 2005 and 2008
|
// versions supported are 2003, 2005 and 2008
|
||||||
VcDocConstants::DocumentVersion docVersion = VcDocConstants::DV_UNRECOGNIZED;
|
VcDocConstants::DocumentVersion docVersion = Utils::getProjectVersion(canonicalFilePath);
|
||||||
|
|
||||||
if (checkIfVersion2003(canonicalFilePath))
|
|
||||||
docVersion = VcDocConstants::DV_MSVC_2003;
|
|
||||||
else if (checkIfVersion2005(canonicalFilePath))
|
|
||||||
docVersion = VcDocConstants::DV_MSVC_2005;
|
|
||||||
else if (checkIfVersion2008(canonicalFilePath))
|
|
||||||
docVersion = VcDocConstants::DV_MSVC_2008;
|
|
||||||
|
|
||||||
if (docVersion != VcDocConstants::DV_UNRECOGNIZED)
|
if (docVersion != VcDocConstants::DV_UNRECOGNIZED)
|
||||||
return new VcProject(this, canonicalFilePath, docVersion);
|
return new VcProject(this, canonicalFilePath, docVersion);
|
||||||
@@ -87,82 +81,5 @@ void VcManager::updateContextMenu(Project *project, ProjectExplorer::Node *node)
|
|||||||
m_contextProject = project;
|
m_contextProject = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VcManager::checkIfVersion2003(const QString &filePath) const
|
|
||||||
{
|
|
||||||
VcSchemaManager *schemaMgr = VcSchemaManager::instance();
|
|
||||||
QString vc2003Schema = schemaMgr->documentSchema(Constants::SV_2003);
|
|
||||||
|
|
||||||
if (vc2003Schema.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile schemaFile(vc2003Schema);
|
|
||||||
schemaFile.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
QXmlSchema schema;
|
|
||||||
schema.load(&schemaFile, QUrl::fromLocalFile(schemaFile.fileName()));
|
|
||||||
|
|
||||||
if (schema.isValid()) {
|
|
||||||
QFile file(filePath);
|
|
||||||
file.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
QXmlSchemaValidator validator(schema);
|
|
||||||
if (validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VcManager::checkIfVersion2005(const QString &filePath) const
|
|
||||||
{
|
|
||||||
VcSchemaManager *schemaMgr = VcSchemaManager::instance();
|
|
||||||
QString vc2005Schema = schemaMgr->documentSchema(Constants::SV_2005);
|
|
||||||
if (vc2005Schema.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QFile schemaFile(vc2005Schema);
|
|
||||||
schemaFile.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
QXmlSchema schema;
|
|
||||||
schema.load(&schemaFile, QUrl::fromLocalFile(schemaFile.fileName()));
|
|
||||||
|
|
||||||
if (schema.isValid()) {
|
|
||||||
QFile file(filePath);
|
|
||||||
file.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
QXmlSchemaValidator validator(schema);
|
|
||||||
if (validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VcManager::checkIfVersion2008(const QString &filePath) const
|
|
||||||
{
|
|
||||||
VcSchemaManager *schemaMgr = VcSchemaManager::instance();
|
|
||||||
QString vc2008Schema = schemaMgr->documentSchema(Constants::SV_2008);
|
|
||||||
if (vc2008Schema.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QFile schemaFile(vc2008Schema);
|
|
||||||
schemaFile.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
QXmlSchema schema;
|
|
||||||
schema.load(&schemaFile, QUrl::fromLocalFile(schemaFile.fileName()));
|
|
||||||
|
|
||||||
if (schema.isValid()) {
|
|
||||||
QFile file(filePath);
|
|
||||||
file.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
QXmlSchemaValidator validator(schema);
|
|
||||||
if (validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace VcProjectManager
|
} // namespace VcProjectManager
|
||||||
|
@@ -51,11 +51,6 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node);
|
void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node);
|
||||||
|
|
||||||
private:
|
|
||||||
bool checkIfVersion2003(const QString &filePath) const;
|
|
||||||
bool checkIfVersion2005(const QString &filePath) const;
|
|
||||||
bool checkIfVersion2008(const QString &filePath) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectExplorer::Project *m_contextProject;
|
ProjectExplorer::Project *m_contextProject;
|
||||||
VcProjectBuildOptionsPage *m_configPage;
|
VcProjectBuildOptionsPage *m_configPage;
|
||||||
|
@@ -13,7 +13,8 @@ HEADERS = vcprojectmanagerplugin.h \
|
|||||||
msbuildversionmanager.h \
|
msbuildversionmanager.h \
|
||||||
vcprojectbuildoptionspage.h \
|
vcprojectbuildoptionspage.h \
|
||||||
vcschemamanager.h \
|
vcschemamanager.h \
|
||||||
menuhandler.h
|
menuhandler.h \
|
||||||
|
utils.h
|
||||||
|
|
||||||
SOURCES = vcprojectmanagerplugin.cpp \
|
SOURCES = vcprojectmanagerplugin.cpp \
|
||||||
vcprojectmanager.cpp \
|
vcprojectmanager.cpp \
|
||||||
@@ -26,7 +27,8 @@ SOURCES = vcprojectmanagerplugin.cpp \
|
|||||||
msbuildversionmanager.cpp \
|
msbuildversionmanager.cpp \
|
||||||
vcprojectbuildoptionspage.cpp \
|
vcprojectbuildoptionspage.cpp \
|
||||||
vcschemamanager.cpp \
|
vcschemamanager.cpp \
|
||||||
menuhandler.cpp
|
menuhandler.cpp \
|
||||||
|
utils.cpp
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
VcProject.mimetypes.xml
|
VcProject.mimetypes.xml
|
||||||
|
Reference in New Issue
Block a user