2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Openismus GmbH.
|
|
|
|
|
** Author: Peter Penz (ppenz@openismus.com)
|
|
|
|
|
** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com)
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
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 <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>
|
2015-02-04 09:32:46 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.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
|
|
|
|
|
//////////////////////////////////////
|
2016-02-03 17:21:12 +01:00
|
|
|
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent) :
|
|
|
|
|
BuildConfiguration(parent, Core::Id(AUTOTOOLS_BC_ID))
|
2014-09-10 00:17:42 +01:00
|
|
|
{
|
2016-12-05 09:53:12 +01:00
|
|
|
// /<foobar> is used so the un-changed check in setBuildDirectory() works correctly.
|
|
|
|
|
// The leading / is to avoid the relative the path expansion in BuildConfiguration::buildDirectory.
|
|
|
|
|
BuildConfiguration::setBuildDirectory(Utils::FileName::fromString(QString::fromLatin1("/<foobar>")));
|
|
|
|
|
|
|
|
|
|
connect(this, &BuildConfiguration::buildDirectoryChanged, this, [this] {
|
|
|
|
|
foreach (auto bs, stepList(BUILDSTEPS_BUILD)->allOfType<ConfigureStep>())
|
|
|
|
|
bs->notifyBuildDirectoryChanged();
|
|
|
|
|
});
|
2014-09-10 00:17:42 +01: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
|
|
|
}
|
|
|
|
|
|
2016-02-03 17:21:12 +01:00
|
|
|
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent, Core::Id id) :
|
|
|
|
|
BuildConfiguration(parent, id)
|
2013-08-16 17:45:16 +02:00
|
|
|
{ }
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent,
|
2016-02-03 17:21:12 +01:00
|
|
|
AutotoolsBuildConfiguration *source) :
|
|
|
|
|
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)
|
2016-02-03 17:21:12 +01:00
|
|
|
{ }
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2013-07-24 12:42:24 +02:00
|
|
|
int AutotoolsBuildConfigurationFactory::priority(const Target *parent) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2013-07-24 12:42:24 +02:00
|
|
|
return canHandle(parent) ? 0 : -1;
|
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;
|
2014-05-02 12:53:36 +02:00
|
|
|
result << createBuildInfo(parent->kit(), parent->project()->projectDirectory());
|
2013-07-22 15:53:57 +02:00
|
|
|
return result;
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2013-07-24 12:42:24 +02:00
|
|
|
int AutotoolsBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
2017-03-02 12:07:11 +01:00
|
|
|
if (k && Utils::mimeTypeForFile(projectPath).matchesName(QLatin1String(Constants::MAKEFILE_MIMETYPE)))
|
2015-02-04 09:32:46 +01:00
|
|
|
return 0;
|
|
|
|
|
return -1;
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BuildInfo *> AutotoolsBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
|
|
|
|
|
{
|
|
|
|
|
QList<BuildInfo *> 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
|
2014-05-02 12:53:36 +02:00
|
|
|
QFile autogenFile(parent->project()->projectDirectory().toString() + 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
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
BuildInfo *AutotoolsBuildConfigurationFactory::createBuildInfo(const Kit *k,
|
2013-07-22 15:53:57 +02:00
|
|
|
const Utils::FileName &buildDir) const
|
|
|
|
|
{
|
|
|
|
|
BuildInfo *info = new BuildInfo(this);
|
|
|
|
|
info->typeName = tr("Build");
|
|
|
|
|
info->buildDirectory = buildDir;
|
|
|
|
|
info->kitId = k->id();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|