2011-11-29 14:19:28 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010-2011 Openismus GmbH.
|
|
|
|
|
** Authors: Peter Penz (ppenz@openismus.com)
|
|
|
|
|
** Patricia Santana Cruz (patriciasantanacruz@gmail.com)
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at info@qt.nokia.com.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "autotoolsbuildconfiguration.h"
|
2012-07-25 09:48:48 +02:00
|
|
|
#include "autotoolsbuildsettingswidget.h"
|
2011-11-29 14:19:28 +01:00
|
|
|
#include "makestep.h"
|
|
|
|
|
#include "autotoolsproject.h"
|
|
|
|
|
#include "autotoolsprojectconstants.h"
|
|
|
|
|
#include "autogenstep.h"
|
|
|
|
|
#include "autoreconfstep.h"
|
|
|
|
|
#include "configurestep.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2011-11-29 14:19:28 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
2012-05-16 16:24:16 +02:00
|
|
|
#include <qtsupport/customexecutablerunconfiguration.h>
|
2011-11-29 14:19:28 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QInputDialog>
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
using namespace AutotoolsProjectManager;
|
2012-01-13 13:36:45 +01:00
|
|
|
using namespace AutotoolsProjectManager::Constants;
|
2011-11-29 14:19:28 +01:00
|
|
|
using namespace Internal;
|
2012-01-13 13:36:45 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Constants;
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
// AutotoolsBuildConfiguration class
|
|
|
|
|
//////////////////////////////////////
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(ProjectExplorer::Target *parent)
|
2012-03-15 17:17:40 +01:00
|
|
|
: BuildConfiguration(parent, Core::Id(AUTOTOOLS_BC_ID))
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsProject *project = qobject_cast<AutotoolsProject *>(parent->project());
|
|
|
|
|
if (project)
|
|
|
|
|
m_buildDirectory = project->defaultBuildDirectory();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfigWidget *AutotoolsBuildConfiguration::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
return new AutotoolsBuildSettingsWidget;
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(ProjectExplorer::Target *parent, const Core::Id id)
|
2011-11-29 14:19:28 +01:00
|
|
|
: BuildConfiguration(parent, id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(ProjectExplorer::Target *parent,
|
|
|
|
|
AutotoolsBuildConfiguration *source)
|
2011-11-29 14:19:28 +01:00
|
|
|
: BuildConfiguration(parent, source),
|
|
|
|
|
m_buildDirectory(source->m_buildDirectory)
|
|
|
|
|
{
|
|
|
|
|
cloneSteps(source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AutotoolsBuildConfiguration::toMap() const
|
|
|
|
|
{
|
2012-01-13 13:36:45 +01:00
|
|
|
QVariantMap map = BuildConfiguration::toMap();
|
|
|
|
|
map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory);
|
2011-11-29 14:19:28 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AutotoolsBuildConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!BuildConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString();
|
2011-11-29 14:19:28 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AutotoolsBuildConfiguration::buildDirectory() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AutotoolsBuildConfiguration::setBuildDirectory(const QString &buildDirectory)
|
|
|
|
|
{
|
|
|
|
|
if (m_buildDirectory == buildDirectory)
|
|
|
|
|
return;
|
|
|
|
|
m_buildDirectory = buildDirectory;
|
|
|
|
|
emit buildDirectoryChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
IOutputParser *AutotoolsBuildConfiguration::createOutputParser() const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
|
2011-11-29 14:19:28 +01:00
|
|
|
if (tc)
|
|
|
|
|
return tc->outputParser();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
// AutotoolsBuildConfiguration class
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
AutotoolsBuildConfigurationFactory::AutotoolsBuildConfigurationFactory(QObject *parent) :
|
2012-01-13 13:36:45 +01:00
|
|
|
IBuildConfigurationFactory(parent)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<Core::Id> AutotoolsBuildConfigurationFactory::availableCreationIds(const Target *parent) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2012-03-15 17:17:40 +01:00
|
|
|
return QList<Core::Id>();
|
|
|
|
|
return QList<Core::Id>() << Core::Id(AUTOTOOLS_BC_ID);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QString AutotoolsBuildConfigurationFactory::displayNameForId(const Core::Id id) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (id == AUTOTOOLS_BC_ID)
|
2011-11-29 14:19:28 +01:00
|
|
|
return tr("Build");
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool AutotoolsBuildConfigurationFactory::canCreate(const Target *parent, const Core::Id id) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2011-11-29 14:19:28 +01:00
|
|
|
return false;
|
2012-08-03 15:24:33 +02:00
|
|
|
if (id == AUTOTOOLS_BC_ID)
|
2011-11-29 14:19:28 +01:00
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::create(Target *parent, const Core::Id id, const QString &name)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool ok = true;
|
|
|
|
|
QString buildConfigurationName = name;
|
|
|
|
|
if (buildConfigurationName.isEmpty())
|
|
|
|
|
buildConfigurationName = QInputDialog::getText(0,
|
|
|
|
|
tr("New Configuration"),
|
|
|
|
|
tr("New configuration name:"),
|
|
|
|
|
QLineEdit::Normal,
|
|
|
|
|
QString(), &ok);
|
|
|
|
|
buildConfigurationName = buildConfigurationName.trimmed();
|
2011-11-29 14:19:28 +01:00
|
|
|
if (!ok || buildConfigurationName.isEmpty())
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration *bc = createDefaultConfiguration(parent);
|
|
|
|
|
bc->setDisplayName(buildConfigurationName);
|
2011-11-29 14:19:28 +01:00
|
|
|
return bc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::createDefaultConfiguration(ProjectExplorer::Target *target)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
AutotoolsBuildConfiguration *bc = new AutotoolsBuildConfiguration(target);
|
2012-03-15 17:17:40 +01:00
|
|
|
BuildStepList *buildSteps = bc->stepList(Core::Id(BUILDSTEPS_BUILD));
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
// ### Build Steps Build ###
|
|
|
|
|
// autogen.sh or autoreconf
|
2012-04-24 15:49:09 +02:00
|
|
|
QFile autogenFile(target->project()->projectDirectory() + QLatin1String("/autogen.sh"));
|
2011-11-29 14:19:28 +01:00
|
|
|
if (autogenFile.exists()) {
|
|
|
|
|
AutogenStep *autogenStep = new AutogenStep(buildSteps);
|
|
|
|
|
buildSteps->insertStep(0, autogenStep);
|
|
|
|
|
} else {
|
|
|
|
|
AutoreconfStep *autoreconfStep = new AutoreconfStep(buildSteps);
|
|
|
|
|
autoreconfStep->setAdditionalArguments(QLatin1String("--force --install"));
|
|
|
|
|
buildSteps->insertStep(0, autoreconfStep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ./configure.
|
|
|
|
|
ConfigureStep *configureStep = new ConfigureStep(buildSteps);
|
|
|
|
|
buildSteps->insertStep(1, configureStep);
|
|
|
|
|
|
|
|
|
|
// make
|
|
|
|
|
MakeStep *makeStep = new MakeStep(buildSteps);
|
|
|
|
|
buildSteps->insertStep(2, makeStep);
|
|
|
|
|
makeStep->setBuildTarget(QLatin1String("all"), /*on =*/ true);
|
|
|
|
|
|
|
|
|
|
// ### Build Steps Clean ###
|
2012-03-15 17:17:40 +01:00
|
|
|
BuildStepList *cleanSteps = bc->stepList(Core::Id(BUILDSTEPS_CLEAN));
|
2011-11-29 14:19:28 +01:00
|
|
|
MakeStep *cleanMakeStep = new MakeStep(cleanSteps);
|
|
|
|
|
cleanMakeStep->setAdditionalArguments(QLatin1String("clean"));
|
|
|
|
|
cleanMakeStep->setClean(true);
|
|
|
|
|
cleanSteps->insertStep(0, cleanMakeStep);
|
|
|
|
|
|
|
|
|
|
return bc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool AutotoolsBuildConfigurationFactory::canHandle(const Target *t) const
|
|
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!t->project()->supportsKit(t->kit()))
|
2012-04-24 15:49:09 +02:00
|
|
|
return false;
|
2012-08-03 15:24:33 +02:00
|
|
|
return t->project()->id() == Constants::AUTOTOOLS_PROJECT_ID;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AutotoolsBuildConfigurationFactory::canClone(const Target *parent, BuildConfiguration *source) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
return canCreate(parent, source->id());
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::clone(Target *parent, BuildConfiguration *source)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
AutotoolsBuildConfiguration *origin = static_cast<AutotoolsBuildConfiguration *>(source);
|
2012-04-24 15:49:09 +02:00
|
|
|
return new AutotoolsBuildConfiguration(parent, origin);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool AutotoolsBuildConfigurationFactory::canRestore(const Target *parent, const QVariantMap &map) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
return canCreate(parent, idFromMap(map));
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
AutotoolsBuildConfiguration *AutotoolsBuildConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration *bc = new AutotoolsBuildConfiguration(parent);
|
2011-11-29 14:19:28 +01:00
|
|
|
if (bc->fromMap(map))
|
|
|
|
|
return bc;
|
|
|
|
|
delete bc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
BuildConfiguration::BuildType AutotoolsBuildConfiguration::buildType() const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
// TODO: Should I return something different from Unknown?
|
|
|
|
|
return Unknown;
|
|
|
|
|
}
|