2011-11-29 14:19:28 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Openismus GmbH.
|
2012-10-02 09:12:39 +02:00
|
|
|
** Authors: Peter Penz (ppenz@openismus.com)
|
|
|
|
|
** Patricia Santana Cruz (patriciasantanacruz@gmail.com)
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-11-29 14:19:28 +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.
|
2011-11-29 14:19:28 +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
|
2011-11-29 14:19:28 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/mimedatabase.h>
|
|
|
|
|
#include <projectexplorer/buildinfo.h>
|
2011-11-29 14:19:28 +01:00
|
|
|
#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>
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
#include <QFileInfo>
|
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))
|
2013-08-16 17:45:16 +02:00
|
|
|
{ }
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-11-08 18:02:50 +01:00
|
|
|
NamedWidget *AutotoolsBuildConfiguration::createConfigWidget()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-11-08 17:35:59 +01:00
|
|
|
return new AutotoolsBuildSettingsWidget(this);
|
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)
|
2013-08-16 17:45:16 +02:00
|
|
|
{ }
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(ProjectExplorer::Target *parent,
|
|
|
|
|
AutotoolsBuildConfiguration *source)
|
2013-08-16 17:45:16 +02:00
|
|
|
: BuildConfiguration(parent, source)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
cloneSteps(source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
// AutotoolsBuildConfiguration class
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
AutotoolsBuildConfigurationFactory::AutotoolsBuildConfigurationFactory(QObject *parent) :
|
2012-01-13 13:36:45 +01:00
|
|
|
IBuildConfigurationFactory(parent)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
bool AutotoolsBuildConfigurationFactory::canCreate(const Target *parent) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
return canHandle(parent);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
QList<BuildInfo *> AutotoolsBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
QList<BuildInfo *> result;
|
|
|
|
|
QTC_ASSERT(canCreate(parent), return result);
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
result << createBuildInfo(parent->kit(),
|
|
|
|
|
Utils::FileName::fromString(parent->project()->projectDirectory()));
|
|
|
|
|
return result;
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-13 10:52:57 +02:00
|
|
|
bool AutotoolsBuildConfigurationFactory::canSetup(const Kit *k, const QString &projectPath) const
|
|
|
|
|
{
|
|
|
|
|
return k && Core::MimeDatabase::findByFile(QFileInfo(projectPath))
|
|
|
|
|
.matchesType(QLatin1String(Constants::MAKEFILE_MIMETYPE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BuildInfo *> AutotoolsBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
|
|
|
|
|
{
|
|
|
|
|
QList<BuildInfo *> result;
|
|
|
|
|
QTC_ASSERT(canSetup(k, projectPath), return result);
|
|
|
|
|
BuildInfo *info = createBuildInfo(k,
|
|
|
|
|
Utils::FileName::fromString(AutotoolsProject::defaultBuildDirectory(projectPath)));
|
|
|
|
|
//: The name of the build configuration created by default for a autotools project.
|
|
|
|
|
info->displayName = tr("Default");
|
|
|
|
|
result << info;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
BuildConfiguration *AutotoolsBuildConfigurationFactory::create(Target *parent, const BuildInfo *info) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
QTC_ASSERT(parent, return 0);
|
|
|
|
|
QTC_ASSERT(info->factory() == this, return 0);
|
|
|
|
|
QTC_ASSERT(info->kitId == parent->kit()->id(), return 0);
|
|
|
|
|
QTC_ASSERT(!info->displayName.isEmpty(), return 0);
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
AutotoolsBuildConfiguration *bc = new AutotoolsBuildConfiguration(parent);
|
|
|
|
|
bc->setDisplayName(info->displayName);
|
|
|
|
|
bc->setDefaultDisplayName(info->displayName);
|
|
|
|
|
bc->setBuildDirectory(info->buildDirectory);
|
2011-11-29 14:19:28 +01:00
|
|
|
|
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
|
2013-07-22 15:53:57 +02:00
|
|
|
QFile autogenFile(parent->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
|
|
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
QTC_ASSERT(t, return false);
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
BuildInfo *AutotoolsBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k,
|
|
|
|
|
const Utils::FileName &buildDir) const
|
|
|
|
|
{
|
|
|
|
|
BuildInfo *info = new BuildInfo(this);
|
|
|
|
|
info->typeName = tr("Build");
|
|
|
|
|
info->buildDirectory = buildDir;
|
|
|
|
|
info->kitId = k->id();
|
2013-08-13 10:52:57 +02:00
|
|
|
info->supportsShadowBuild = true; // Works sometimes...
|
2013-07-22 15:53:57 +02:00
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return false;
|
|
|
|
|
return source->id() == AUTOTOOLS_BC_ID;
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2013-07-22 15:53:57 +02:00
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return false;
|
|
|
|
|
return idFromMap(map) == AUTOTOOLS_BC_ID;
|
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;
|
|
|
|
|
}
|