2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakebuildconfiguration.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
#include "qmakebuildinfo.h"
|
2013-10-11 23:05:04 +08:00
|
|
|
#include "qmakekitinformation.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeproject.h"
|
|
|
|
|
#include "qmakeprojectconfigwidget.h"
|
|
|
|
|
#include "qmakeprojectmanagerconstants.h"
|
|
|
|
|
#include "qmakenodes.h"
|
2010-03-17 17:45:33 +01:00
|
|
|
#include "qmakestep.h"
|
|
|
|
|
#include "makestep.h"
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2013-08-16 17:45:16 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2010-09-09 17:00:26 +02:00
|
|
|
#include <limits>
|
2013-07-22 15:53:57 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/mimedatabase.h>
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-05-30 16:45:32 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2012-10-18 15:35:10 +02:00
|
|
|
#include <projectexplorer/toolchainmanager.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2011-08-18 16:46:44 +02:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2013-07-22 15:53:57 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2010-02-19 10:51:40 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QInputDialog>
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
namespace QmakeProjectManager {
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2013-08-13 10:52:57 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// Helpers:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static Utils::FileName defaultBuildDirectory(bool supportsShadowBuild,
|
|
|
|
|
const QString &projectPath,
|
|
|
|
|
const ProjectExplorer::Kit *k,
|
|
|
|
|
const QString &suffix)
|
|
|
|
|
{
|
|
|
|
|
if (supportsShadowBuild)
|
2013-10-29 14:22:31 +01:00
|
|
|
return Utils::FileName::fromString(QmakeProject::shadowBuildDirectory(projectPath, k, suffix));
|
2014-05-02 12:53:36 +02:00
|
|
|
return ProjectExplorer::Project::projectDirectory(Utils::FileName::fromString(projectPath));
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-29 23:17:42 +02:00
|
|
|
using namespace Internal;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace QtSupport;
|
|
|
|
|
using namespace Utils;
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2013-10-29 16:08:37 +01:00
|
|
|
const char QMAKE_BC_ID[] = "Qt4ProjectManager.Qt4BuildConfiguration";
|
2012-08-29 23:17:42 +02:00
|
|
|
const char USE_SHADOW_BUILD_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild";
|
|
|
|
|
const char BUILD_CONFIGURATION_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration";
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
enum { debug = 0 };
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target) :
|
2013-10-29 16:08:37 +01:00
|
|
|
BuildConfiguration(target, Core::Id(QMAKE_BC_ID)),
|
2010-03-25 11:55:29 +01:00
|
|
|
m_shadowBuild(true),
|
2011-01-19 15:46:01 +01:00
|
|
|
m_isEnabled(false),
|
2010-01-13 18:00:02 +01:00
|
|
|
m_qmakeBuildConfiguration(0),
|
2012-05-04 16:25:41 +03:00
|
|
|
m_subNodeBuild(0),
|
|
|
|
|
m_fileNodeBuild(0)
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
ctor();
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target, const Core::Id id) :
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration(target, id),
|
2010-03-25 11:55:29 +01:00
|
|
|
m_shadowBuild(true),
|
2011-01-19 15:46:01 +01:00
|
|
|
m_isEnabled(false),
|
2010-01-18 12:11:04 +01:00
|
|
|
m_qmakeBuildConfiguration(0),
|
2012-05-04 16:25:41 +03:00
|
|
|
m_subNodeBuild(0),
|
|
|
|
|
m_fileNodeBuild(0)
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
ctor();
|
2009-12-08 12:21:11 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target, QmakeBuildConfiguration *source) :
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration(target, source),
|
2009-12-08 12:21:11 +01:00
|
|
|
m_shadowBuild(source->m_shadowBuild),
|
2011-01-19 15:46:01 +01:00
|
|
|
m_isEnabled(false),
|
2010-01-13 18:00:02 +01:00
|
|
|
m_qmakeBuildConfiguration(source->m_qmakeBuildConfiguration),
|
2012-05-04 16:25:41 +03:00
|
|
|
m_subNodeBuild(0), // temporary value, so not copied
|
|
|
|
|
m_fileNodeBuild(0)
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
cloneSteps(source);
|
2010-01-18 12:11:04 +01:00
|
|
|
ctor();
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::~QmakeBuildConfiguration()
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
}
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QVariantMap QmakeBuildConfiguration::toMap() const
|
2010-01-18 12:11:04 +01:00
|
|
|
{
|
|
|
|
|
QVariantMap map(BuildConfiguration::toMap());
|
|
|
|
|
map.insert(QLatin1String(USE_SHADOW_BUILD_KEY), m_shadowBuild);
|
|
|
|
|
map.insert(QLatin1String(BUILD_CONFIGURATION_KEY), int(m_qmakeBuildConfiguration));
|
|
|
|
|
return map;
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfiguration::fromMap(const QVariantMap &map)
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!BuildConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2010-03-25 11:55:29 +01:00
|
|
|
m_shadowBuild = map.value(QLatin1String(USE_SHADOW_BUILD_KEY), true).toBool();
|
2012-08-29 23:17:42 +02:00
|
|
|
m_qmakeBuildConfiguration = BaseQtVersion::QmakeBuildConfigs(map.value(QLatin1String(BUILD_CONFIGURATION_KEY)).toInt());
|
2011-03-23 13:32:42 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
m_qtVersionSupportsShadowBuilds = supportsShadowBuilds();
|
2010-09-22 15:14:07 +02:00
|
|
|
|
2012-10-18 15:35:10 +02:00
|
|
|
m_lastKitState = LastKitState(target()->kit());
|
|
|
|
|
|
2013-05-16 13:40:15 +02:00
|
|
|
connect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
|
|
|
|
|
this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
|
2012-10-18 15:35:10 +02:00
|
|
|
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
|
|
|
|
|
this, SLOT(qtVersionsChanged(QList<int>,QList<int>,QList<int>)));
|
2010-02-08 15:50:06 +01:00
|
|
|
return true;
|
2009-12-08 12:21:11 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::ctor()
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
2011-04-20 21:16:17 +02:00
|
|
|
connect(this, SIGNAL(environmentChanged()),
|
2012-07-17 15:56:43 +02:00
|
|
|
this, SLOT(emitProFileEvaluateNeeded()));
|
2012-09-03 18:31:44 +02:00
|
|
|
connect(target(), SIGNAL(kitChanged()),
|
|
|
|
|
this, SLOT(kitChanged()));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
2010-10-06 13:47:01 +02:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::kitChanged()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-10-18 15:35:10 +02:00
|
|
|
LastKitState newState = LastKitState(target()->kit());
|
|
|
|
|
if (newState != m_lastKitState) {
|
|
|
|
|
// This only checks if the ids have changed!
|
2013-10-16 14:00:45 +02:00
|
|
|
// For that reason the QmakeBuildConfiguration is also connected
|
2012-10-18 15:35:10 +02:00
|
|
|
// to the toolchain and qtversion managers
|
|
|
|
|
emitProFileEvaluateNeeded();
|
2013-09-06 12:19:38 +02:00
|
|
|
updateShadowBuild();
|
2012-10-18 15:35:10 +02:00
|
|
|
m_lastKitState = newState;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::toolChainUpdated(ProjectExplorer::ToolChain *tc)
|
2012-10-18 15:35:10 +02:00
|
|
|
{
|
|
|
|
|
if (ToolChainKitInformation::toolChain(target()->kit()) == tc)
|
|
|
|
|
emitProFileEvaluateNeeded();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::qtVersionsChanged(const QList<int> &,const QList<int> &, const QList<int> &changed)
|
2012-10-18 15:35:10 +02:00
|
|
|
{
|
|
|
|
|
if (changed.contains(QtKitInformation::qtVersionId(target()->kit())))
|
|
|
|
|
emitProFileEvaluateNeeded();
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::updateShadowBuild()
|
2010-10-06 13:47:01 +02:00
|
|
|
{
|
2014-03-04 00:12:11 +01:00
|
|
|
// We also emit buildDirectoryChanged if the Qt version's supportShadowBuild changed
|
2013-09-06 12:19:38 +02:00
|
|
|
bool currentShadowBuild = supportsShadowBuilds();
|
|
|
|
|
if (currentShadowBuild != m_qtVersionSupportsShadowBuilds) {
|
|
|
|
|
if (!currentShadowBuild)
|
2014-05-02 12:53:36 +02:00
|
|
|
setBuildDirectory(target()->project()->projectDirectory());
|
2013-09-06 12:19:38 +02:00
|
|
|
m_qtVersionSupportsShadowBuilds = currentShadowBuild;
|
2010-10-06 13:47:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
NamedWidget *QmakeBuildConfiguration::createConfigWidget()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-10-29 15:15:10 +01:00
|
|
|
return new QmakeProjectConfigWidget(this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QString QmakeBuildConfiguration::defaultShadowBuildDirectory() const
|
2011-03-23 13:32:42 +01:00
|
|
|
{
|
|
|
|
|
// todo displayName isn't ideal
|
2014-05-02 12:22:58 +02:00
|
|
|
return QmakeProject::shadowBuildDirectory(target()->project()->projectFilePath().toString(),
|
|
|
|
|
target()->kit(), displayName());
|
2011-03-23 13:32:42 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfiguration::supportsShadowBuilds()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-04 18:04:16 +02:00
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit());
|
2012-04-24 15:49:09 +02:00
|
|
|
return !version || version->supportsShadowBuilds();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-13 18:00:02 +01:00
|
|
|
/// If only a sub tree should be build this function returns which sub node
|
|
|
|
|
/// should be build
|
2013-10-16 14:00:45 +02:00
|
|
|
/// \see QMakeBuildConfiguration::setSubNodeBuild
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProFileNode *QmakeBuildConfiguration::subNodeBuild() const
|
2010-01-13 18:00:02 +01:00
|
|
|
{
|
|
|
|
|
return m_subNodeBuild;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A sub node build on builds a sub node of the project
|
|
|
|
|
/// That is triggered by a right click in the project explorer tree
|
|
|
|
|
/// The sub node to be build is set via this function immediately before
|
|
|
|
|
/// calling BuildManager::buildProject( BuildConfiguration * )
|
|
|
|
|
/// and reset immediately afterwards
|
|
|
|
|
/// That is m_subNodesBuild is set only temporarly
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeBuildConfiguration::setSubNodeBuild(QmakeProFileNode *node)
|
2010-01-13 18:00:02 +01:00
|
|
|
{
|
|
|
|
|
m_subNodeBuild = node;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
FileNode *QmakeBuildConfiguration::fileNodeBuild() const
|
2012-05-04 16:25:41 +03:00
|
|
|
{
|
|
|
|
|
return m_fileNodeBuild;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::setFileNodeBuild(FileNode *node)
|
2012-05-04 16:25:41 +03:00
|
|
|
{
|
|
|
|
|
m_fileNodeBuild = node;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-07 15:55:00 +01:00
|
|
|
/// returns whether this is a shadow build configuration or not
|
|
|
|
|
/// note, even if shadowBuild() returns true, it might be using the
|
2010-01-11 10:22:55 +01:00
|
|
|
/// source directory as the shadow build directory, thus it
|
|
|
|
|
/// still is a in-source build
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfiguration::isShadowBuild() const
|
2009-12-07 15:55:00 +01:00
|
|
|
{
|
2014-05-02 12:53:36 +02:00
|
|
|
return buildDirectory() != target()->project()->projectDirectory();
|
2009-12-07 15:55:00 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::setBuildDirectory(const FileName &directory)
|
2009-12-07 15:55:00 +01:00
|
|
|
{
|
2013-09-06 12:14:50 +02:00
|
|
|
if (directory == buildDirectory())
|
|
|
|
|
return;
|
2013-08-16 17:45:16 +02:00
|
|
|
BuildConfiguration::setBuildDirectory(directory);
|
|
|
|
|
QTC_CHECK(supportsShadowBuilds()
|
|
|
|
|
|| (!supportsShadowBuilds()
|
2014-05-02 12:53:36 +02:00
|
|
|
&& buildDirectory() == target()->project()->projectDirectory()));
|
2013-09-06 12:14:50 +02:00
|
|
|
emitProFileEvaluateNeeded();
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QString QmakeBuildConfiguration::makefile() const
|
2010-10-05 17:38:45 +02:00
|
|
|
{
|
2013-10-29 14:22:31 +01:00
|
|
|
return static_cast<QmakeProject *>(target()->project())->rootQmakeProjectNode()->makefile();
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
BaseQtVersion::QmakeBuildConfigs QmakeBuildConfiguration::qmakeBuildConfiguration() const
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
return m_qmakeBuildConfiguration;
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::setQMakeBuildConfiguration(BaseQtVersion::QmakeBuildConfigs config)
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
if (m_qmakeBuildConfiguration == config)
|
2009-12-03 18:37:27 +01:00
|
|
|
return;
|
2009-12-08 12:21:11 +01:00
|
|
|
m_qmakeBuildConfiguration = config;
|
2010-03-10 16:55:37 +01:00
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
emit qmakeBuildConfigurationChanged();
|
2012-07-17 15:56:43 +02:00
|
|
|
emitProFileEvaluateNeeded();
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::emitProFileEvaluateNeeded()
|
2010-09-01 12:33:53 +02:00
|
|
|
{
|
2012-07-17 15:56:43 +02:00
|
|
|
Target *t = target();
|
|
|
|
|
Project *p = t->project();
|
|
|
|
|
if (t->activeBuildConfiguration() == this && p->activeTarget() == t)
|
2013-10-29 14:22:31 +01:00
|
|
|
static_cast<QmakeProject *>(p)->scheduleAsyncUpdate();
|
2010-09-01 12:33:53 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::emitQMakeBuildConfigurationChanged()
|
2010-01-12 17:20:15 +01:00
|
|
|
{
|
|
|
|
|
emit qmakeBuildConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QStringList QmakeBuildConfiguration::configCommandLineArguments() const
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
2010-09-01 12:33:53 +02:00
|
|
|
QStringList result;
|
2012-09-04 18:04:16 +02:00
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit());
|
2012-08-29 23:17:42 +02:00
|
|
|
BaseQtVersion::QmakeBuildConfigs defaultBuildConfiguration =
|
2013-09-26 18:38:44 +02:00
|
|
|
version ? version->defaultBuildConfig() : BaseQtVersion::QmakeBuildConfigs(BaseQtVersion::DebugBuild | BaseQtVersion::BuildAll);
|
2012-08-29 23:17:42 +02:00
|
|
|
BaseQtVersion::QmakeBuildConfigs userBuildConfiguration = m_qmakeBuildConfiguration;
|
|
|
|
|
if ((defaultBuildConfiguration & BaseQtVersion::BuildAll) && !(userBuildConfiguration & BaseQtVersion::BuildAll))
|
2012-01-13 14:20:45 +01:00
|
|
|
result << QLatin1String("CONFIG-=debug_and_release");
|
2010-09-01 12:33:53 +02:00
|
|
|
|
2012-08-29 23:17:42 +02:00
|
|
|
if (!(defaultBuildConfiguration & BaseQtVersion::BuildAll) && (userBuildConfiguration & BaseQtVersion::BuildAll))
|
2012-01-13 14:20:45 +01:00
|
|
|
result << QLatin1String("CONFIG+=debug_and_release");
|
2012-08-29 23:17:42 +02:00
|
|
|
if ((defaultBuildConfiguration & BaseQtVersion::DebugBuild) && !(userBuildConfiguration & BaseQtVersion::DebugBuild))
|
2012-01-13 14:20:45 +01:00
|
|
|
result << QLatin1String("CONFIG+=release");
|
2012-08-29 23:17:42 +02:00
|
|
|
if (!(defaultBuildConfiguration & BaseQtVersion::DebugBuild) && (userBuildConfiguration & BaseQtVersion::DebugBuild))
|
2012-01-13 14:20:45 +01:00
|
|
|
result << QLatin1String("CONFIG+=debug");
|
2010-09-01 12:33:53 +02:00
|
|
|
return result;
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QMakeStep *QmakeBuildConfiguration::qmakeStep() const
|
2009-11-25 18:50:20 +01:00
|
|
|
{
|
|
|
|
|
QMakeStep *qs = 0;
|
2012-03-15 17:17:40 +01:00
|
|
|
BuildStepList *bsl = stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD));
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(bsl);
|
|
|
|
|
for (int i = 0; i < bsl->count(); ++i)
|
|
|
|
|
if ((qs = qobject_cast<QMakeStep *>(bsl->at(i))) != 0)
|
2009-11-25 18:50:20 +01:00
|
|
|
return qs;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
MakeStep *QmakeBuildConfiguration::makeStep() const
|
2009-11-25 18:50:20 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
MakeStep *ms = 0;
|
2012-03-15 17:17:40 +01:00
|
|
|
BuildStepList *bsl = stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD));
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(bsl);
|
|
|
|
|
for (int i = 0; i < bsl->count(); ++i)
|
|
|
|
|
if ((ms = qobject_cast<MakeStep *>(bsl->at(i))) != 0)
|
|
|
|
|
return ms;
|
2009-11-25 18:50:20 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-29 23:17:42 +02:00
|
|
|
// Returns true if both are equal.
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportFrom(const QString &makefile)
|
2009-11-25 18:50:20 +01:00
|
|
|
{
|
|
|
|
|
QMakeStep *qs = qmakeStep();
|
2010-10-05 17:38:45 +02:00
|
|
|
if (QFileInfo(makefile).exists() && qs) {
|
2012-08-29 23:17:42 +02:00
|
|
|
FileName qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
|
2012-09-04 18:04:16 +02:00
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit());
|
2011-05-04 13:14:46 +02:00
|
|
|
if (!version)
|
2012-04-24 15:49:09 +02:00
|
|
|
return MakefileForWrongProject;
|
2014-05-02 12:22:58 +02:00
|
|
|
if (QtSupport::QtVersionManager::makefileIsFor(makefile, qs->project()->projectFilePath().toString())
|
2014-01-23 12:09:11 +01:00
|
|
|
!= QtSupport::QtVersionManager::SameProject) {
|
|
|
|
|
if (debug) {
|
|
|
|
|
qDebug() << "different profile used to generate the Makefile:"
|
|
|
|
|
<< makefile << " expected profile:" << qs->project()->projectFilePath();
|
|
|
|
|
}
|
|
|
|
|
return MakefileIncompatible;
|
|
|
|
|
}
|
2009-11-25 18:50:20 +01:00
|
|
|
if (version->qmakeCommand() == qmakePath) {
|
|
|
|
|
// same qtversion
|
2012-08-29 23:17:42 +02:00
|
|
|
QPair<BaseQtVersion::QmakeBuildConfigs, QString> result =
|
|
|
|
|
QtVersionManager::scanMakeFile(makefile, version->defaultBuildConfig());
|
2009-12-02 17:43:43 +01:00
|
|
|
if (qmakeBuildConfiguration() == result.first) {
|
2010-02-16 13:53:29 +01:00
|
|
|
// The qmake Build Configuration are the same,
|
2009-11-25 18:50:20 +01:00
|
|
|
// now compare arguments lists
|
|
|
|
|
// we have to compare without the spec/platform cmd argument
|
|
|
|
|
// and compare that on its own
|
2010-10-05 17:38:45 +02:00
|
|
|
QString workingDirectory = QFileInfo(makefile).absolutePath();
|
2011-06-07 17:09:32 +02:00
|
|
|
QStringList actualArgs;
|
|
|
|
|
QString userArgs = qs->userArguments();
|
|
|
|
|
// This copies the settings from userArgs to actualArgs (minus some we
|
|
|
|
|
// are not interested in), splitting them up into individual strings:
|
2012-04-24 15:49:09 +02:00
|
|
|
extractSpecFromArguments(&userArgs, workingDirectory, version, &actualArgs);
|
2012-05-03 16:15:38 +02:00
|
|
|
actualArgs = qs->deducedArguments() + actualArgs + qs->deducedArgumentsAfter();
|
2012-08-29 23:17:42 +02:00
|
|
|
FileName actualSpec = qs->mkspec();
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
QString qmakeArgs = result.second;
|
|
|
|
|
QStringList parsedArgs;
|
2012-08-29 23:17:42 +02:00
|
|
|
FileName parsedSpec = extractSpecFromArguments(&qmakeArgs, workingDirectory, version, &parsedArgs);
|
2009-11-25 18:50:20 +01:00
|
|
|
|
|
|
|
|
if (debug) {
|
2012-08-29 23:17:42 +02:00
|
|
|
qDebug() << "Actual args:" << actualArgs;
|
|
|
|
|
qDebug() << "Parsed args:" << parsedArgs;
|
|
|
|
|
qDebug() << "Actual spec:" << actualSpec.toString();
|
|
|
|
|
qDebug() << "Parsed spec:" << parsedSpec.toString();
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-30 16:41:59 +02:00
|
|
|
// Comparing the sorted list is obviously wrong
|
|
|
|
|
// Though haven written a more complete version
|
|
|
|
|
// that managed had around 200 lines and yet faild
|
|
|
|
|
// to be actually foolproof at all, I think it's
|
|
|
|
|
// not feasible without actually taking the qmake
|
|
|
|
|
// command line parsing code
|
|
|
|
|
|
|
|
|
|
// Things, sorting gets wrong:
|
|
|
|
|
// parameters to positional parameters matter
|
|
|
|
|
// e.g. -o -spec is different from -spec -o
|
|
|
|
|
// -o 1 -spec 2 is diffrent from -spec 1 -o 2
|
|
|
|
|
// variable assignment order matters
|
|
|
|
|
// variable assignment vs -after
|
|
|
|
|
// -norecursive vs. recursive
|
|
|
|
|
actualArgs.sort();
|
|
|
|
|
parsedArgs.sort();
|
2009-11-25 18:50:20 +01:00
|
|
|
if (actualArgs == parsedArgs) {
|
|
|
|
|
// Specs match exactly
|
|
|
|
|
if (actualSpec == parsedSpec)
|
2012-04-24 15:49:09 +02:00
|
|
|
return MakefileMatches;
|
2009-11-25 18:50:20 +01:00
|
|
|
// Actual spec is the default one
|
2012-08-29 23:17:42 +02:00
|
|
|
// qDebug() << "AS vs VS" << actualSpec << version->mkspec();
|
2014-02-07 15:46:36 +01:00
|
|
|
if ((actualSpec == version->mkspec() || actualSpec == FileName::fromLatin1("default"))
|
|
|
|
|
&& (parsedSpec == version->mkspec() || parsedSpec == FileName::fromLatin1("default") || parsedSpec.isEmpty()))
|
2012-04-24 15:49:09 +02:00
|
|
|
return MakefileMatches;
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
return MakefileIncompatible;
|
|
|
|
|
} else {
|
|
|
|
|
if (debug)
|
2012-08-29 23:17:42 +02:00
|
|
|
qDebug() << "different qmake buildconfigurations buildconfiguration:"
|
|
|
|
|
<< qmakeBuildConfiguration() << " Makefile:" << result.first;
|
2012-04-24 15:49:09 +02:00
|
|
|
return MakefileIncompatible;
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
} else {
|
|
|
|
|
if (debug)
|
2012-08-29 23:17:42 +02:00
|
|
|
qDebug() << "different Qt versions, buildconfiguration:" << version->qmakeCommand().toString()
|
|
|
|
|
<< " Makefile:"<< qmakePath.toString();
|
2012-04-24 15:49:09 +02:00
|
|
|
return MakefileForWrongProject;
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
return MakefileMissing;
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
2009-11-26 16:49:45 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfiguration::removeQMLInspectorFromArguments(QString *args)
|
2010-08-30 13:24:34 +02:00
|
|
|
{
|
2011-09-01 16:16:59 +02:00
|
|
|
bool removedArgument = false;
|
2012-08-29 23:17:42 +02:00
|
|
|
for (QtcProcess::ArgIterator ait(args); ait.next(); ) {
|
2011-09-01 09:43:08 +02:00
|
|
|
const QString arg = ait.value();
|
|
|
|
|
if (arg.contains(QLatin1String(Constants::QMAKEVAR_QMLJSDEBUGGER_PATH))
|
2012-11-21 17:46:58 +01:00
|
|
|
|| arg.contains(QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG))
|
|
|
|
|
|| arg.contains(QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG))) {
|
2011-10-13 14:01:28 +02:00
|
|
|
ait.deleteArg();
|
2011-09-01 16:16:59 +02:00
|
|
|
removedArgument = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return removedArgument;
|
2010-08-30 13:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
FileName QmakeBuildConfiguration::extractSpecFromArguments(QString *args,
|
2012-08-29 23:17:42 +02:00
|
|
|
const QString &directory, const BaseQtVersion *version,
|
|
|
|
|
QStringList *outArgs)
|
2009-11-26 16:49:45 +01:00
|
|
|
{
|
2012-08-29 23:17:42 +02:00
|
|
|
FileName parsedSpec;
|
2010-10-19 11:14:03 +02:00
|
|
|
|
2009-11-26 16:49:45 +01:00
|
|
|
bool ignoreNext = false;
|
2010-10-19 11:14:03 +02:00
|
|
|
bool nextIsSpec = false;
|
2012-08-29 23:17:42 +02:00
|
|
|
for (QtcProcess::ArgIterator ait(args); ait.next(); ) {
|
2009-11-26 16:49:45 +01:00
|
|
|
if (ignoreNext) {
|
|
|
|
|
ignoreNext = false;
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
|
|
|
|
} else if (nextIsSpec) {
|
|
|
|
|
nextIsSpec = false;
|
2012-08-29 23:17:42 +02:00
|
|
|
parsedSpec = FileName::fromUserInput(ait.value());
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
|
|
|
|
} else if (ait.value() == QLatin1String("-spec") || ait.value() == QLatin1String("-platform")) {
|
|
|
|
|
nextIsSpec = true;
|
|
|
|
|
ait.deleteArg();
|
|
|
|
|
} else if (ait.value() == QLatin1String("-cache")) {
|
|
|
|
|
// We ignore -cache, because qmake contained a bug that it didn't
|
|
|
|
|
// mention the -cache in the Makefile.
|
|
|
|
|
// That means changing the -cache option in the additional arguments
|
|
|
|
|
// does not automatically rerun qmake. Alas, we could try more
|
|
|
|
|
// intelligent matching for -cache, but i guess people rarely
|
|
|
|
|
// do use that.
|
2009-11-26 16:49:45 +01:00
|
|
|
ignoreNext = true;
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
|
|
|
|
} else if (outArgs && ait.isSimple()) {
|
|
|
|
|
outArgs->append(ait.value());
|
2009-11-26 16:49:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
if (parsedSpec.isEmpty())
|
2012-08-29 23:17:42 +02:00
|
|
|
return FileName();
|
2009-11-26 16:49:45 +01:00
|
|
|
|
2012-08-29 23:17:42 +02:00
|
|
|
FileName baseMkspecDir = FileName::fromUserInput(
|
2012-07-06 13:29:45 +02:00
|
|
|
version->qmakeProperty("QT_HOST_DATA") + QLatin1String("/mkspecs"));
|
2012-10-04 16:40:33 +02:00
|
|
|
baseMkspecDir = Utils::FileName::fromString(baseMkspecDir.toFileInfo().canonicalFilePath());
|
2009-11-26 16:49:45 +01:00
|
|
|
|
|
|
|
|
// if the path is relative it can be
|
|
|
|
|
// relative to the working directory (as found in the Makefiles)
|
|
|
|
|
// or relatively to the mkspec directory
|
|
|
|
|
// if it is the former we need to get the canonical form
|
|
|
|
|
// for the other one we don't need to do anything
|
2011-11-25 13:19:58 +01:00
|
|
|
if (parsedSpec.toFileInfo().isRelative()) {
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (QFileInfo(directory + QLatin1Char('/') + parsedSpec.toString()).exists())
|
2012-08-29 23:17:42 +02:00
|
|
|
parsedSpec = FileName::fromUserInput(directory + QLatin1Char('/') + parsedSpec.toString());
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2012-08-29 23:17:42 +02:00
|
|
|
parsedSpec = FileName::fromUserInput(baseMkspecDir.toString() + QLatin1Char('/') + parsedSpec.toString());
|
2009-11-26 16:49:45 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
QFileInfo f2 = parsedSpec.toFileInfo();
|
2009-11-26 16:49:45 +01:00
|
|
|
while (f2.isSymLink()) {
|
2012-08-29 23:17:42 +02:00
|
|
|
parsedSpec = FileName::fromString(f2.symLinkTarget());
|
2011-11-25 13:19:58 +01:00
|
|
|
f2.setFile(parsedSpec.toString());
|
2009-11-26 16:49:45 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
if (parsedSpec.isChildOf(baseMkspecDir)) {
|
|
|
|
|
parsedSpec = parsedSpec.relativeChildPath(baseMkspecDir);
|
2009-11-26 16:49:45 +01:00
|
|
|
} else {
|
2012-08-29 23:17:42 +02:00
|
|
|
FileName sourceMkSpecPath = FileName::fromString(version->sourcePath().toString()
|
|
|
|
|
+ QLatin1String("/mkspecs"));
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (parsedSpec.isChildOf(sourceMkSpecPath))
|
2011-11-25 13:19:58 +01:00
|
|
|
parsedSpec = parsedSpec.relativeChildPath(sourceMkSpecPath);
|
2009-11-26 16:49:45 +01:00
|
|
|
}
|
|
|
|
|
return parsedSpec;
|
2009-12-02 17:43:43 +01:00
|
|
|
}
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfiguration::isEnabled() const
|
2011-01-19 15:46:01 +01:00
|
|
|
{
|
|
|
|
|
return m_isEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QString QmakeBuildConfiguration::disabledReason() const
|
2011-05-26 15:56:36 +02:00
|
|
|
{
|
|
|
|
|
if (!m_isEnabled)
|
|
|
|
|
return tr("Parsing the .pro file");
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfiguration::setEnabled(bool enabled)
|
2011-01-19 15:46:01 +01:00
|
|
|
{
|
|
|
|
|
if (m_isEnabled == enabled)
|
|
|
|
|
return;
|
|
|
|
|
m_isEnabled = enabled;
|
|
|
|
|
emit enabledChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
/*!
|
2013-10-16 14:00:45 +02:00
|
|
|
\class QmakeBuildConfigurationFactory
|
2010-01-07 18:17:24 +01:00
|
|
|
*/
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfigurationFactory::QmakeBuildConfigurationFactory(QObject *parent) :
|
2012-08-29 23:17:42 +02:00
|
|
|
IBuildConfigurationFactory(parent)
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
|
|
|
|
update();
|
|
|
|
|
|
2013-08-29 14:11:29 +02:00
|
|
|
connect(QtVersionManager::instance(),
|
|
|
|
|
SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
|
2010-01-07 18:17:24 +01:00
|
|
|
this, SLOT(update()));
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfigurationFactory::~QmakeBuildConfigurationFactory()
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
void QmakeBuildConfigurationFactory::update()
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
|
|
|
|
emit availableCreationIdsChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfigurationFactory::canHandle(const Target *t) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!t->project()->supportsKit(t->kit()))
|
2012-04-24 15:49:09 +02:00
|
|
|
return false;
|
2013-10-29 14:22:31 +01:00
|
|
|
return qobject_cast<QmakeProject *>(t->project());
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildInfo *QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
|
2013-07-22 15:53:57 +02:00
|
|
|
const QString &projectPath,
|
|
|
|
|
BuildConfiguration::BuildType type) const
|
2012-04-04 16:06:35 +02:00
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
|
QmakeBuildInfo *info = new QmakeBuildInfo(this);
|
2013-12-16 12:16:35 +04:00
|
|
|
QString suffix;
|
|
|
|
|
if (type == BuildConfiguration::Release) {
|
2013-07-22 15:53:57 +02:00
|
|
|
//: The name of the release build configuration created by default for a qmake project.
|
|
|
|
|
info->displayName = tr("Release");
|
2013-12-16 12:16:35 +04:00
|
|
|
//: Non-ASCII characters in directory suffix may cause build issues.
|
|
|
|
|
suffix = tr("Release", "Shadow build directory suffix");
|
|
|
|
|
} else {
|
2013-07-22 15:53:57 +02:00
|
|
|
//: The name of the debug build configuration created by default for a qmake project.
|
|
|
|
|
info->displayName = tr("Debug");
|
2013-12-16 12:16:35 +04:00
|
|
|
//: Non-ASCII characters in directory suffix may cause build issues.
|
|
|
|
|
suffix = tr("Debug", "Shadow build directory suffix");
|
|
|
|
|
}
|
2013-07-22 15:53:57 +02:00
|
|
|
info->typeName = tr("Build");
|
|
|
|
|
// Leave info->buildDirectory unset;
|
|
|
|
|
info->kitId = k->id();
|
|
|
|
|
info->supportsShadowBuild = (version && version->supportsShadowBuilds());
|
2013-08-13 10:52:57 +02:00
|
|
|
info->buildDirectory
|
2013-12-16 12:16:35 +04:00
|
|
|
= defaultBuildDirectory(info->supportsShadowBuild, projectPath, k, suffix);
|
2013-07-22 15:53:57 +02:00
|
|
|
info->type = type;
|
|
|
|
|
return info;
|
2012-04-04 16:06:35 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
int QmakeBuildConfigurationFactory::priority(const Target *parent) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2013-07-24 12:42:24 +02:00
|
|
|
return canHandle(parent) ? 0 : -1;
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QList<BuildInfo *> QmakeBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
QList<ProjectExplorer::BuildInfo *> result;
|
2014-05-02 12:22:58 +02:00
|
|
|
QmakeBuildInfo *info = createBuildInfo(parent->kit(), parent->project()->projectFilePath().toString(),
|
2013-07-22 15:53:57 +02:00
|
|
|
BuildConfiguration::Debug);
|
|
|
|
|
info->displayName.clear(); // ask for a name
|
2013-08-13 10:52:57 +02:00
|
|
|
info->buildDirectory.clear(); // This depends on the displayName
|
2013-07-22 15:53:57 +02:00
|
|
|
result << info;
|
|
|
|
|
|
|
|
|
|
return result;
|
2010-01-18 12:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
int QmakeBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
2013-07-24 12:42:24 +02:00
|
|
|
return (k && Core::MimeDatabase::findByFile(QFileInfo(projectPath))
|
|
|
|
|
.matchesType(QLatin1String(Constants::PROFILE_MIMETYPE))) ? 0 : -1;
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QList<BuildInfo *> QmakeBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
|
|
|
|
QList<ProjectExplorer::BuildInfo *> result;
|
|
|
|
|
result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Debug);
|
|
|
|
|
result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Release);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
BuildConfiguration *QmakeBuildConfigurationFactory::create(Target *parent, const BuildInfo *info) const
|
2010-01-18 12:11:04 +01:00
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
QTC_ASSERT(info->factory() == this, return 0);
|
|
|
|
|
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
|
|
|
|
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
const QmakeBuildInfo *qmakeInfo = static_cast<const QmakeBuildInfo *>(info);
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(parent->kit());
|
|
|
|
|
QTC_ASSERT(version, return 0);
|
2011-05-04 13:14:46 +02:00
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
BaseQtVersion::QmakeBuildConfigs config = version->defaultBuildConfig();
|
|
|
|
|
if (qmakeInfo->type == BuildConfiguration::Release)
|
|
|
|
|
config &= ~QtSupport::BaseQtVersion::DebugBuild;
|
|
|
|
|
else
|
|
|
|
|
config |= QtSupport::BaseQtVersion::DebugBuild;
|
2012-04-17 17:10:56 +02:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration *bc = new QmakeBuildConfiguration(parent);
|
2013-08-13 10:52:57 +02:00
|
|
|
bc->setDefaultDisplayName(info->displayName);
|
|
|
|
|
bc->setDisplayName(info->displayName);
|
|
|
|
|
|
|
|
|
|
BuildStepList *buildSteps = bc->stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD));
|
|
|
|
|
BuildStepList *cleanSteps = bc->stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN));
|
|
|
|
|
Q_ASSERT(buildSteps);
|
|
|
|
|
Q_ASSERT(cleanSteps);
|
|
|
|
|
|
|
|
|
|
QMakeStep *qmakeStep = new QMakeStep(buildSteps);
|
|
|
|
|
buildSteps->insertStep(0, qmakeStep);
|
|
|
|
|
|
|
|
|
|
MakeStep *makeStep = new MakeStep(buildSteps);
|
|
|
|
|
buildSteps->insertStep(1, makeStep);
|
|
|
|
|
|
|
|
|
|
MakeStep *cleanStep = new MakeStep(cleanSteps);
|
|
|
|
|
cleanStep->setClean(true);
|
|
|
|
|
cleanStep->setUserArguments(QLatin1String("clean"));
|
|
|
|
|
cleanSteps->insertStep(0, cleanStep);
|
|
|
|
|
|
|
|
|
|
QString additionalArguments = qmakeInfo->additionalArguments;
|
|
|
|
|
|
|
|
|
|
bool enableQmlDebugger
|
2013-10-16 14:00:45 +02:00
|
|
|
= QmakeBuildConfiguration::removeQMLInspectorFromArguments(&additionalArguments);
|
2013-08-13 10:52:57 +02:00
|
|
|
if (!additionalArguments.isEmpty())
|
|
|
|
|
qmakeStep->setUserArguments(additionalArguments);
|
2013-10-31 10:45:26 +01:00
|
|
|
if (!qmakeInfo->makefile.isEmpty())
|
|
|
|
|
qmakeStep->setLinkQmlDebuggingLibrary(enableQmlDebugger);
|
2013-08-13 10:52:57 +02:00
|
|
|
|
|
|
|
|
bc->setQMakeBuildConfiguration(config);
|
|
|
|
|
|
|
|
|
|
Utils::FileName directory = qmakeInfo->buildDirectory;
|
|
|
|
|
if (directory.isEmpty()) {
|
|
|
|
|
directory = defaultBuildDirectory(qmakeInfo->supportsShadowBuild,
|
2014-05-02 12:22:58 +02:00
|
|
|
parent->project()->projectFilePath().toString(),
|
2013-08-13 10:52:57 +02:00
|
|
|
parent->kit(), info->displayName);
|
|
|
|
|
}
|
2013-07-22 15:53:57 +02:00
|
|
|
|
2013-08-13 10:52:57 +02:00
|
|
|
bc->setBuildDirectory(directory);
|
2010-01-07 18:17:24 +01:00
|
|
|
return bc;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfigurationFactory::canClone(const Target *parent, BuildConfiguration *source) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2013-10-16 14:00:45 +02:00
|
|
|
return canHandle(parent) && qobject_cast<QmakeBuildConfiguration *>(source);
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
BuildConfiguration *QmakeBuildConfigurationFactory::clone(Target *parent, BuildConfiguration *source)
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration *oldbc(static_cast<QmakeBuildConfiguration *>(source));
|
|
|
|
|
return new QmakeBuildConfiguration(parent, oldbc);
|
2010-01-18 12:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfigurationFactory::canRestore(const Target *parent, const QVariantMap &map) const
|
2010-01-18 12:11:04 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2010-01-18 12:11:04 +01:00
|
|
|
return false;
|
2013-10-29 16:08:37 +01:00
|
|
|
return ProjectExplorer::idFromMap(map) == QMAKE_BC_ID;
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
BuildConfiguration *QmakeBuildConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
2010-01-18 12:11:04 +01:00
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration *bc = new QmakeBuildConfiguration(parent);
|
2010-01-18 12:11:04 +01:00
|
|
|
if (bc->fromMap(map))
|
|
|
|
|
return bc;
|
|
|
|
|
delete bc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2011-01-13 13:38:43 +01:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const
|
2011-03-03 16:12:00 +01:00
|
|
|
{
|
2012-08-29 23:17:42 +02:00
|
|
|
if (qmakeBuildConfiguration() & BaseQtVersion::DebugBuild)
|
2011-03-03 16:12:00 +01:00
|
|
|
return Debug;
|
|
|
|
|
else
|
|
|
|
|
return Release;
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::LastKitState::LastKitState()
|
2012-10-18 15:35:10 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration::LastKitState::LastKitState(Kit *k)
|
2012-10-18 15:35:10 +02:00
|
|
|
: m_qtVersion(QtKitInformation::qtVersionId(k)),
|
|
|
|
|
m_sysroot(SysRootKitInformation::sysRoot(k).toString()),
|
|
|
|
|
m_mkspec(QmakeKitInformation::mkspec(k).toString())
|
|
|
|
|
{
|
|
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(k);
|
|
|
|
|
m_toolchain = tc ? tc->id() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfiguration::LastKitState::operator ==(const LastKitState &other) const
|
2012-10-18 15:35:10 +02:00
|
|
|
{
|
|
|
|
|
return m_qtVersion == other.m_qtVersion
|
|
|
|
|
&& m_toolchain == other.m_toolchain
|
|
|
|
|
&& m_sysroot == other.m_sysroot
|
|
|
|
|
&& m_mkspec == other.m_mkspec;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 14:00:45 +02:00
|
|
|
bool QmakeBuildConfiguration::LastKitState::operator !=(const LastKitState &other) const
|
2012-10-18 15:35:10 +02:00
|
|
|
{
|
|
|
|
|
return !operator ==(other);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
} // namespace QmakeProjectManager
|