2013-04-25 16:02:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-04-25 16:02:17 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
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.
|
2013-04-25 16:02:17 +02: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.
|
2013-04-25 16:02:17 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "iosbuildstep.h"
|
|
|
|
|
#include "iosconstants.h"
|
|
|
|
|
#include "ui_iosbuildstep.h"
|
|
|
|
|
#include "iosmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/gnumakeparser.h>
|
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
|
|
|
|
#include <projectexplorer/gcctoolchain.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
#include <qtsupport/qtparser.h>
|
|
|
|
|
#include <utils/stringutils.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace Ios {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
const char IOS_BUILD_STEP_ID[] = "Ios.IosBuildStep";
|
|
|
|
|
const char IOS_BUILD_STEP_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("Ios::Internal::IosBuildStep",
|
|
|
|
|
"xcodebuild");
|
|
|
|
|
|
|
|
|
|
const char BUILD_USE_DEFAULT_ARGS_KEY[] = "Ios.IosBuildStep.XcodeArgumentsUseDefault";
|
|
|
|
|
const char BUILD_ARGUMENTS_KEY[] = "Ios.IosBuildStep.XcodeArguments";
|
|
|
|
|
const char CLEAN_KEY[] = "Ios.IosBuildStep.Clean";
|
|
|
|
|
|
|
|
|
|
IosBuildStep::IosBuildStep(BuildStepList *parent) :
|
|
|
|
|
AbstractProcessStep(parent, Id(IOS_BUILD_STEP_ID)),
|
|
|
|
|
m_useDefaultArguments(true),
|
|
|
|
|
m_clean(false)
|
|
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IosBuildStep::IosBuildStep(BuildStepList *parent, const Id id) :
|
|
|
|
|
AbstractProcessStep(parent, id),
|
|
|
|
|
m_useDefaultArguments(true),
|
|
|
|
|
m_clean(false)
|
|
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IosBuildStep::IosBuildStep(BuildStepList *parent, IosBuildStep *bs) :
|
|
|
|
|
AbstractProcessStep(parent, bs),
|
|
|
|
|
m_baseBuildArguments(bs->m_baseBuildArguments),
|
|
|
|
|
m_useDefaultArguments(bs->m_useDefaultArguments),
|
|
|
|
|
m_clean(bs->m_clean)
|
|
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStep::ctor()
|
|
|
|
|
{
|
|
|
|
|
setDefaultDisplayName(QCoreApplication::translate("GenericProjectManager::Internal::IosBuildStep",
|
|
|
|
|
IOS_BUILD_STEP_DISPLAY_NAME));
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
bool IosBuildStep::init(QList<const BuildStep *> &earlierSteps)
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = buildConfiguration();
|
|
|
|
|
if (!bc)
|
|
|
|
|
bc = target()->activeBuildConfiguration();
|
2014-06-20 14:32:40 +02:00
|
|
|
if (!bc)
|
|
|
|
|
emit addTask(Task::buildConfigurationMissingTask());
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2014-06-20 14:32:40 +02:00
|
|
|
if (!tc)
|
|
|
|
|
emit addTask(Task::compilerMissingTask());
|
|
|
|
|
|
|
|
|
|
if (!bc || !tc) {
|
|
|
|
|
emitFaultyConfigurationMessage();
|
2013-04-25 16:02:17 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2014-06-20 14:32:40 +02:00
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
ProcessParameters *pp = processParameters();
|
|
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
|
|
|
|
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
|
|
|
|
Utils::Environment env = bc->environment();
|
2016-04-07 13:06:01 +02:00
|
|
|
Utils::Environment::setupEnglishOutput(&env);
|
2013-04-25 16:02:17 +02:00
|
|
|
pp->setEnvironment(env);
|
|
|
|
|
pp->setCommand(buildCommand());
|
|
|
|
|
pp->setArguments(Utils::QtcProcess::joinArgs(allArguments()));
|
|
|
|
|
pp->resolveAll();
|
|
|
|
|
|
|
|
|
|
// If we are cleaning, then build can fail with an error code, but that doesn't mean
|
|
|
|
|
// we should stop the clean queue
|
|
|
|
|
// That is mostly so that rebuild works on an already clean project
|
|
|
|
|
setIgnoreReturnValue(m_clean);
|
|
|
|
|
|
|
|
|
|
setOutputParser(new GnuMakeParser());
|
|
|
|
|
IOutputParser *parser = target()->kit()->createOutputParser();
|
|
|
|
|
if (parser)
|
|
|
|
|
appendOutputParser(parser);
|
|
|
|
|
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
|
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
return AbstractProcessStep::init(earlierSteps);
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStep::setClean(bool clean)
|
|
|
|
|
{
|
|
|
|
|
m_clean = clean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IosBuildStep::isClean() const
|
|
|
|
|
{
|
|
|
|
|
return m_clean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap IosBuildStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map(AbstractProcessStep::toMap());
|
|
|
|
|
|
2017-06-12 14:23:06 +02:00
|
|
|
map.insert(BUILD_ARGUMENTS_KEY, m_baseBuildArguments);
|
|
|
|
|
map.insert(BUILD_USE_DEFAULT_ARGS_KEY, m_useDefaultArguments);
|
|
|
|
|
map.insert(CLEAN_KEY, m_clean);
|
2013-04-25 16:02:17 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IosBuildStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2017-06-12 14:23:06 +02:00
|
|
|
QVariant bArgs = map.value(BUILD_ARGUMENTS_KEY);
|
2013-04-25 16:02:17 +02:00
|
|
|
m_baseBuildArguments = bArgs.toStringList();
|
2017-06-12 14:23:06 +02:00
|
|
|
m_useDefaultArguments = map.value(BUILD_USE_DEFAULT_ARGS_KEY).toBool();
|
|
|
|
|
m_clean = map.value(CLEAN_KEY).toBool();
|
2013-04-25 16:02:17 +02:00
|
|
|
|
|
|
|
|
return BuildStep::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList IosBuildStep::allArguments() const
|
|
|
|
|
{
|
|
|
|
|
return baseArguments() + m_extraArguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList IosBuildStep::defaultArguments() const
|
|
|
|
|
{
|
|
|
|
|
QStringList res;
|
|
|
|
|
Kit *kit = target()->kit();
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2013-04-25 16:02:17 +02:00
|
|
|
switch (target()->activeBuildConfiguration()->buildType()) {
|
|
|
|
|
case BuildConfiguration::Debug :
|
2017-06-12 14:23:06 +02:00
|
|
|
res << "-configuration" << "Debug";
|
2013-04-25 16:02:17 +02:00
|
|
|
break;
|
|
|
|
|
case BuildConfiguration::Release :
|
2015-02-20 15:10:56 +01:00
|
|
|
case BuildConfiguration::Profile :
|
2017-06-12 14:23:06 +02:00
|
|
|
res << "-configuration" << "Release";
|
2013-04-25 16:02:17 +02:00
|
|
|
break;
|
|
|
|
|
case BuildConfiguration::Unknown :
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2014-07-07 09:24:17 +02:00
|
|
|
qCWarning(iosLog) << "IosBuildStep had an unknown buildType "
|
|
|
|
|
<< target()->activeBuildConfiguration()->buildType();
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
2015-07-07 15:37:50 +02:00
|
|
|
if (tc->typeId() == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID
|
|
|
|
|
|| tc->typeId() == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID) {
|
2013-04-25 16:02:17 +02:00
|
|
|
GccToolChain *gtc = static_cast<GccToolChain *>(tc);
|
|
|
|
|
res << gtc->platformCodeGenFlags();
|
|
|
|
|
}
|
|
|
|
|
if (!SysRootKitInformation::sysRoot(kit).isEmpty())
|
2017-06-12 14:23:06 +02:00
|
|
|
res << "-sdk" << SysRootKitInformation::sysRoot(kit).toString();
|
|
|
|
|
res << "SYMROOT=" + IosManager::resDirForTarget(target());
|
2013-04-25 16:02:17 +02:00
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IosBuildStep::buildCommand() const
|
|
|
|
|
{
|
2017-06-12 14:23:06 +02:00
|
|
|
return "xcodebuild"; // add path?
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStep::run(QFutureInterface<bool> &fi)
|
|
|
|
|
{
|
|
|
|
|
AbstractProcessStep::run(fi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepConfigWidget *IosBuildStep::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
return new IosBuildStepConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IosBuildStep::immutable() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStep::setBaseArguments(const QStringList &args)
|
|
|
|
|
{
|
|
|
|
|
m_baseBuildArguments = args;
|
|
|
|
|
m_useDefaultArguments = (args == defaultArguments());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStep::setExtraArguments(const QStringList &extraArgs)
|
|
|
|
|
{
|
|
|
|
|
m_extraArguments = extraArgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList IosBuildStep::baseArguments() const
|
|
|
|
|
{
|
|
|
|
|
if (m_useDefaultArguments)
|
|
|
|
|
return defaultArguments();
|
|
|
|
|
return m_baseBuildArguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// IosBuildStepConfigWidget
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
IosBuildStepConfigWidget::IosBuildStepConfigWidget(IosBuildStep *buildStep)
|
|
|
|
|
: m_buildStep(buildStep)
|
|
|
|
|
{
|
|
|
|
|
m_ui = new Ui::IosBuildStep;
|
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
Project *pro = m_buildStep->target()->project();
|
|
|
|
|
|
|
|
|
|
m_ui->buildArgumentsTextEdit->setPlainText(Utils::QtcProcess::joinArgs(
|
|
|
|
|
m_buildStep->baseArguments()));
|
|
|
|
|
m_ui->extraArgumentsLineEdit->setText(Utils::QtcProcess::joinArgs(
|
|
|
|
|
m_buildStep->m_extraArguments));
|
|
|
|
|
m_ui->resetDefaultsButton->setEnabled(!m_buildStep->m_useDefaultArguments);
|
|
|
|
|
updateDetails();
|
|
|
|
|
|
2016-05-24 16:10:47 +02:00
|
|
|
connect(m_ui->buildArgumentsTextEdit, &QPlainTextEdit::textChanged,
|
|
|
|
|
this, &IosBuildStepConfigWidget::buildArgumentsChanged);
|
|
|
|
|
connect(m_ui->resetDefaultsButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &IosBuildStepConfigWidget::resetDefaultArguments);
|
|
|
|
|
connect(m_ui->extraArgumentsLineEdit, &QLineEdit::editingFinished,
|
|
|
|
|
this, &IosBuildStepConfigWidget::extraArgumentsChanged);
|
|
|
|
|
|
|
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
|
|
|
|
this, &IosBuildStepConfigWidget::updateDetails);
|
|
|
|
|
connect(m_buildStep->target(), &Target::kitChanged,
|
|
|
|
|
this, &IosBuildStepConfigWidget::updateDetails);
|
|
|
|
|
connect(pro, &Project::environmentChanged, this, &IosBuildStepConfigWidget::updateDetails);
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IosBuildStepConfigWidget::~IosBuildStepConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IosBuildStepConfigWidget::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("iOS build", "iOS BuildStep display name.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStepConfigWidget::updateDetails()
|
|
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = m_buildStep->buildConfiguration();
|
|
|
|
|
if (!bc)
|
|
|
|
|
bc = m_buildStep->target()->activeBuildConfiguration();
|
|
|
|
|
|
|
|
|
|
ProcessParameters param;
|
|
|
|
|
param.setMacroExpander(bc->macroExpander());
|
|
|
|
|
param.setWorkingDirectory(bc->buildDirectory().toString());
|
|
|
|
|
param.setEnvironment(bc->environment());
|
|
|
|
|
param.setCommand(m_buildStep->buildCommand());
|
|
|
|
|
param.setArguments(Utils::QtcProcess::joinArgs(m_buildStep->allArguments()));
|
|
|
|
|
m_summaryText = param.summary(displayName());
|
|
|
|
|
emit updateSummary();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IosBuildStepConfigWidget::summaryText() const
|
|
|
|
|
{
|
|
|
|
|
return m_summaryText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStepConfigWidget::buildArgumentsChanged()
|
|
|
|
|
{
|
|
|
|
|
m_buildStep->setBaseArguments(Utils::QtcProcess::splitArgs(
|
|
|
|
|
m_ui->buildArgumentsTextEdit->toPlainText()));
|
|
|
|
|
m_ui->resetDefaultsButton->setEnabled(!m_buildStep->m_useDefaultArguments);
|
|
|
|
|
updateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStepConfigWidget::resetDefaultArguments()
|
|
|
|
|
{
|
|
|
|
|
m_buildStep->setBaseArguments(m_buildStep->defaultArguments());
|
|
|
|
|
m_ui->buildArgumentsTextEdit->setPlainText(Utils::QtcProcess::joinArgs(
|
|
|
|
|
m_buildStep->baseArguments()));
|
|
|
|
|
m_ui->resetDefaultsButton->setEnabled(!m_buildStep->m_useDefaultArguments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosBuildStepConfigWidget::extraArgumentsChanged()
|
|
|
|
|
{
|
|
|
|
|
m_buildStep->setExtraArguments(Utils::QtcProcess::splitArgs(
|
|
|
|
|
m_ui->extraArgumentsLineEdit->text()));
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// IosBuildStepFactory
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
IosBuildStepFactory::IosBuildStepFactory(QObject *parent) :
|
|
|
|
|
IBuildStepFactory(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStep *IosBuildStepFactory::create(BuildStepList *parent, const Id id)
|
|
|
|
|
{
|
2016-05-18 12:37:29 +02:00
|
|
|
Q_UNUSED(id);
|
2013-04-25 16:02:17 +02:00
|
|
|
IosBuildStep *step = new IosBuildStep(parent);
|
|
|
|
|
if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) {
|
|
|
|
|
step->setClean(true);
|
2017-06-12 14:23:06 +02:00
|
|
|
step->setExtraArguments(QStringList("clean"));
|
2013-04-25 16:02:17 +02:00
|
|
|
} else if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_BUILD) {
|
|
|
|
|
// nomal setup
|
|
|
|
|
}
|
|
|
|
|
return step;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStep *IosBuildStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
|
|
|
|
{
|
2016-05-18 12:37:29 +02:00
|
|
|
IosBuildStep *old = qobject_cast<IosBuildStep *>(source);
|
2013-04-25 16:02:17 +02:00
|
|
|
Q_ASSERT(old);
|
|
|
|
|
return new IosBuildStep(parent, old);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-18 12:37:29 +02:00
|
|
|
QList<BuildStepInfo> IosBuildStepFactory::availableSteps(BuildStepList *parent) const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2016-05-18 12:37:29 +02:00
|
|
|
Id deviceType = DeviceTypeKitInformation::deviceTypeId(parent->target()->kit());
|
|
|
|
|
if (deviceType != Constants::IOS_DEVICE_TYPE
|
|
|
|
|
&& deviceType != Constants::IOS_SIMULATOR_TYPE)
|
|
|
|
|
return {};
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2016-05-18 12:37:29 +02:00
|
|
|
if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_CLEAN
|
|
|
|
|
&& parent->id() != ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
|
|
|
|
return {};
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2017-02-22 15:09:35 +01:00
|
|
|
return {{IOS_BUILD_STEP_ID,
|
|
|
|
|
QCoreApplication::translate("GenericProjectManager::Internal::IosBuildStep",
|
|
|
|
|
IOS_BUILD_STEP_DISPLAY_NAME)}};
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Ios
|