2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
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.
|
2009-11-23 12:11:48 +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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-11-23 12:11:48 +01:00
|
|
|
|
|
|
|
|
#include "cmakebuildconfiguration.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2016-02-24 18:00:24 +01:00
|
|
|
#include "builddirmanager.h"
|
2016-01-07 12:33:52 +01:00
|
|
|
#include "cmakebuildstep.h"
|
2019-01-29 16:51:17 +01:00
|
|
|
#include "cmakeconfigitem.h"
|
2016-02-03 13:52:50 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2012-10-02 17:46:19 +02:00
|
|
|
#include "cmakeprojectconstants.h"
|
2015-03-10 10:22:38 +01:00
|
|
|
#include "cmakebuildsettingswidget.h"
|
2015-03-10 14:24:14 +01:00
|
|
|
#include "cmakeprojectmanager.h"
|
2017-01-26 11:58:57 +01:00
|
|
|
#include "cmakeprojectnodes.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
#include <android/androidconstants.h>
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2014-10-22 09:16:55 +02:00
|
|
|
|
2019-01-29 16:51:17 +01:00
|
|
|
#include <projectexplorer/buildinfo.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2013-04-10 12:02:06 +02:00
|
|
|
#include <projectexplorer/kit.h>
|
2019-01-07 12:15:40 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2014-10-22 09:16:55 +02:00
|
|
|
#include <projectexplorer/projectmacroexpander.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2016-02-03 13:52:50 +01:00
|
|
|
#include <utils/algorithm.h>
|
2015-02-04 09:32:46 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.h>
|
2013-07-22 15:53:57 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2016-02-03 13:52:50 +01:00
|
|
|
#include <utils/qtcprocess.h>
|
2013-07-22 15:53:57 +02:00
|
|
|
|
2014-10-22 09:16:55 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2019-01-29 16:51:17 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
|
|
|
|
|
class CMakeExtraBuildInfo
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QString sourceDirectory;
|
|
|
|
|
CMakeConfig configuration;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace CMakeProjectManager
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(CMakeProjectManager::CMakeExtraBuildInfo)
|
|
|
|
|
|
|
|
|
|
|
2014-10-22 09:16:55 +02:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-11-23 13:29:45 +01:00
|
|
|
|
2016-02-03 13:52:50 +01:00
|
|
|
const char INITIAL_ARGUMENTS[] = "CMakeProjectManager.CMakeBuildConfiguration.InitialArgument"; // Obsolete since QtC 3.7
|
|
|
|
|
const char CONFIGURATION_KEY[] = "CMake.Configuration";
|
2014-10-22 09:16:55 +02:00
|
|
|
|
2018-05-04 16:52:21 +02:00
|
|
|
CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
|
|
|
|
|
: BuildConfiguration(parent, id)
|
2019-08-05 15:56:03 +02:00
|
|
|
, m_buildDirManager(qobject_cast<CMakeProject *>(parent->project()))
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
2019-08-05 15:56:03 +02:00
|
|
|
setBuildDirectory(shadowBuildDirectory(project()->projectFilePath(),
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
target()->kit(),
|
2019-08-05 15:56:03 +02:00
|
|
|
displayName(),
|
|
|
|
|
BuildConfiguration::Unknown));
|
|
|
|
|
connect(project(), &Project::parsingFinished, this, &BuildConfiguration::enabledChanged);
|
|
|
|
|
|
|
|
|
|
// BuildDirManager:
|
|
|
|
|
connect(&m_buildDirManager, &BuildDirManager::requestReparse, this, [this](int options) {
|
|
|
|
|
if (isActive())
|
|
|
|
|
project()->requestReparse(options);
|
|
|
|
|
});
|
|
|
|
|
connect(&m_buildDirManager, &BuildDirManager::dataAvailable, this, [this]() {
|
|
|
|
|
clearError();
|
|
|
|
|
if (isActive())
|
|
|
|
|
project()->handleParsingSuccess(this);
|
|
|
|
|
});
|
|
|
|
|
connect(&m_buildDirManager, &BuildDirManager::errorOccured, this, [this](const QString &msg) {
|
|
|
|
|
setError(msg);
|
|
|
|
|
QString errorMessage;
|
|
|
|
|
setConfigurationFromCMake(m_buildDirManager.takeCMakeConfiguration(errorMessage));
|
|
|
|
|
// ignore errorMessage here, we already got one.
|
|
|
|
|
project()->handleParsingError(this);
|
|
|
|
|
});
|
|
|
|
|
connect(&m_buildDirManager, &BuildDirManager::parsingStarted, this, [this]() {
|
|
|
|
|
clearError(CMakeBuildConfiguration::ForceEnabledChanged::True);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Kit changed:
|
|
|
|
|
connect(KitManager::instance(), &KitManager::kitUpdated, this, [this](Kit *k) {
|
|
|
|
|
if (k != target()->kit())
|
|
|
|
|
return; // not for us...
|
|
|
|
|
|
|
|
|
|
// Build configuration has not changed, but Kit settings might have:
|
|
|
|
|
// reparse and check the configuration, independent of whether the reader has changed
|
|
|
|
|
m_buildDirManager.setParametersAndRequestParse(BuildDirParameters(this),
|
|
|
|
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION,
|
|
|
|
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Became active/inactive:
|
|
|
|
|
connect(project(), &Project::activeBuildConfigurationChanged, this, [this]() {
|
|
|
|
|
if (isActive()) {
|
|
|
|
|
// Build configuration has switched:
|
|
|
|
|
// * Check configuration if reader changes due to it not existing yet:-)
|
|
|
|
|
// * run cmake without configuration arguments if the reader stays
|
|
|
|
|
m_buildDirManager
|
|
|
|
|
.setParametersAndRequestParse(BuildDirParameters(this),
|
|
|
|
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION,
|
|
|
|
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
|
|
|
|
} else {
|
|
|
|
|
m_buildDirManager.stopParsingAndClearState();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// BuildConfiguration changed:
|
|
|
|
|
connect(this, &CMakeBuildConfiguration::environmentChanged, this, [this]() {
|
|
|
|
|
if (isActive()) {
|
|
|
|
|
// The environment on our BC has changed:
|
|
|
|
|
// * Error out if the reader updates, cannot happen since all BCs share a target/kit.
|
|
|
|
|
// * run cmake without configuration arguments if the reader stays
|
|
|
|
|
m_buildDirManager.setParametersAndRequestParse(
|
|
|
|
|
BuildDirParameters(this),
|
|
|
|
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION, // server-mode might need a restart...
|
|
|
|
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
connect(this, &CMakeBuildConfiguration::buildDirectoryChanged, this, [this]() {
|
|
|
|
|
if (isActive()) {
|
|
|
|
|
// The build directory of our BC has changed:
|
|
|
|
|
// * Error out if the reader updates, cannot happen since all BCs share a target/kit.
|
|
|
|
|
// * run cmake without configuration arguments if the reader stays
|
|
|
|
|
// If no configuration exists, then the arguments will get added automatically by
|
|
|
|
|
// the reader.
|
|
|
|
|
m_buildDirManager
|
|
|
|
|
.setParametersAndRequestParse(BuildDirParameters(this),
|
|
|
|
|
BuildDirManager::REPARSE_FAIL,
|
|
|
|
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
connect(this, &CMakeBuildConfiguration::configurationForCMakeChanged, this, [this]() {
|
|
|
|
|
if (isActive()) {
|
|
|
|
|
// The CMake configuration has changed on our BC:
|
|
|
|
|
// * Error out if the reader updates, cannot happen since all BCs share a target/kit.
|
|
|
|
|
// * run cmake with configuration arguments if the reader stays
|
|
|
|
|
m_buildDirManager
|
|
|
|
|
.setParametersAndRequestParse(BuildDirParameters(this),
|
|
|
|
|
BuildDirManager::REPARSE_FAIL,
|
|
|
|
|
BuildDirManager::REPARSE_FORCE_CONFIGURATION);
|
|
|
|
|
}
|
|
|
|
|
});
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-29 16:51:17 +01:00
|
|
|
void CMakeBuildConfiguration::initialize(const BuildInfo &info)
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
{
|
|
|
|
|
BuildConfiguration::initialize(info);
|
|
|
|
|
|
|
|
|
|
BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
2019-06-26 13:23:44 +02:00
|
|
|
buildSteps->appendStep(Constants::CMAKE_BUILD_STEP_ID);
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
if (DeviceTypeKitAspect::deviceTypeId(target()->kit())
|
|
|
|
|
== Android::Constants::ANDROID_DEVICE_TYPE) {
|
|
|
|
|
buildSteps->appendStep(Android::Constants::ANDROID_BUILD_APK_ID);
|
|
|
|
|
const auto &bs = buildSteps->steps().constLast();
|
|
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"ANDROID_NATIVE_API_LEVEL",
|
|
|
|
|
CMakeProjectManager::CMakeConfigItem::Type::STRING,
|
|
|
|
|
"Android native API level",
|
|
|
|
|
bs->data(Android::Constants::AndroidNdkPlatform).toString().toUtf8()});
|
2019-05-28 13:49:26 +02:00
|
|
|
auto ndkLocation = bs->data(Android::Constants::NdkLocation).value<FilePath>();
|
2019-03-06 14:17:17 +02:00
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"ANDROID_NDK",
|
|
|
|
|
CMakeProjectManager::CMakeConfigItem::Type::PATH,
|
|
|
|
|
"Android NDK PATH",
|
|
|
|
|
ndkLocation.toUserOutput().toUtf8()});
|
|
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_TOOLCHAIN_FILE",
|
|
|
|
|
CMakeProjectManager::CMakeConfigItem::Type::PATH,
|
|
|
|
|
"Android CMake toolchain file",
|
2019-05-15 14:54:25 +02:00
|
|
|
ndkLocation.pathAppended("build/cmake/android.toolchain.cmake").toUserOutput().toUtf8()});
|
2019-03-06 14:17:17 +02:00
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"ANDROID_ABI",
|
|
|
|
|
CMakeProjectManager::CMakeConfigItem::Type::STRING,
|
|
|
|
|
"Android ABI",
|
|
|
|
|
bs->data(Android::Constants::AndroidABI).toString().toUtf8()});
|
|
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"ANDROID_STL",
|
|
|
|
|
CMakeProjectManager::CMakeConfigItem::Type::STRING,
|
|
|
|
|
"Android STL",
|
|
|
|
|
"c++_shared"});
|
|
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "BOTH"});
|
|
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "BOTH"});
|
|
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_INCLUDE", "BOTH"});
|
|
|
|
|
m_initialConfiguration.prepend(CMakeProjectManager::CMakeConfigItem{"CMAKE_FIND_ROOT_PATH_MODE_PACKAGE", "BOTH"});
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
BuildStepList *cleanSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
|
2019-06-26 13:23:44 +02:00
|
|
|
cleanSteps->appendStep(Constants::CMAKE_BUILD_STEP_ID);
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
|
2019-01-29 16:51:17 +01:00
|
|
|
if (info.buildDirectory.isEmpty()) {
|
2019-01-31 14:26:06 +01:00
|
|
|
auto project = target()->project();
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
setBuildDirectory(CMakeBuildConfiguration::shadowBuildDirectory(project->projectFilePath(),
|
|
|
|
|
target()->kit(),
|
2019-01-29 16:51:17 +01:00
|
|
|
info.displayName, info.buildType));
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
}
|
2019-01-29 16:51:17 +01:00
|
|
|
auto extraInfo = info.extraInfo.value<CMakeExtraBuildInfo>();
|
|
|
|
|
setConfigurationForCMake(extraInfo.configuration);
|
2016-02-24 18:00:24 +01:00
|
|
|
}
|
|
|
|
|
|
2016-02-11 16:33:15 +01:00
|
|
|
bool CMakeBuildConfiguration::isEnabled() const
|
|
|
|
|
{
|
2017-03-01 12:52:24 +01:00
|
|
|
return m_error.isEmpty() && !isParsing();
|
2016-02-11 16:33:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeBuildConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
return error();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
QVariantMap CMakeBuildConfiguration::toMap() const
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
QVariantMap map(ProjectExplorer::BuildConfiguration::toMap());
|
2016-02-03 13:52:50 +01:00
|
|
|
const QStringList config
|
2017-09-28 11:32:39 +02:00
|
|
|
= Utils::transform(m_configurationForCMake, [](const CMakeConfigItem &i) { return i.toString(); });
|
2016-02-03 13:52:50 +01:00
|
|
|
map.insert(QLatin1String(CONFIGURATION_KEY), config);
|
2010-01-18 12:11:04 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2010-09-22 15:14:07 +02:00
|
|
|
if (!BuildConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-02-03 13:52:50 +01:00
|
|
|
const CMakeConfig conf
|
2016-04-08 14:11:57 +02:00
|
|
|
= Utils::filtered(Utils::transform(map.value(QLatin1String(CONFIGURATION_KEY)).toStringList(),
|
|
|
|
|
[](const QString &v) { return CMakeConfigItem::fromString(v); }),
|
|
|
|
|
[](const CMakeConfigItem &c) { return !c.isNull(); });
|
2016-02-03 13:52:50 +01:00
|
|
|
|
|
|
|
|
// Legacy (pre QtC 3.7):
|
|
|
|
|
const QStringList args = QtcProcess::splitArgs(map.value(QLatin1String(INITIAL_ARGUMENTS)).toString());
|
|
|
|
|
CMakeConfig legacyConf;
|
|
|
|
|
bool nextIsConfig = false;
|
|
|
|
|
foreach (const QString &a, args) {
|
|
|
|
|
if (a == QLatin1String("-D")) {
|
|
|
|
|
nextIsConfig = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!a.startsWith(QLatin1String("-D")))
|
|
|
|
|
continue;
|
|
|
|
|
legacyConf << CMakeConfigItem::fromString(nextIsConfig ? a : a.mid(2));
|
|
|
|
|
nextIsConfig = false;
|
|
|
|
|
}
|
|
|
|
|
// End Legacy
|
|
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
setConfigurationForCMake(legacyConf + conf);
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2010-09-22 15:14:07 +02:00
|
|
|
return true;
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
2009-11-23 13:29:45 +01:00
|
|
|
|
2016-02-24 18:00:24 +01:00
|
|
|
bool CMakeBuildConfiguration::isParsing() const
|
|
|
|
|
{
|
2017-09-28 11:32:39 +02:00
|
|
|
return project()->isParsing() && isActive();
|
2016-10-06 11:31:27 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-03 17:26:49 +02:00
|
|
|
const QList<BuildTargetInfo> CMakeBuildConfiguration::appTargets() const
|
2016-10-06 11:31:27 +02:00
|
|
|
{
|
2019-05-03 17:26:49 +02:00
|
|
|
QList<BuildTargetInfo> appTargetList;
|
2019-03-06 14:17:17 +02:00
|
|
|
bool forAndroid = DeviceTypeKitAspect::deviceTypeId(target()->kit()) == Android::Constants::ANDROID_DEVICE_TYPE;
|
2018-12-20 18:51:12 +01:00
|
|
|
for (const CMakeBuildTarget &ct : m_buildTargets) {
|
|
|
|
|
if (ct.targetType == UtilityType)
|
|
|
|
|
continue;
|
|
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
if (ct.targetType == ExecutableType || (forAndroid && ct.targetType == DynamicLibraryType)) {
|
2018-12-20 18:51:12 +01:00
|
|
|
BuildTargetInfo bti;
|
|
|
|
|
bti.displayName = ct.title;
|
|
|
|
|
bti.targetFilePath = ct.executable;
|
2019-05-15 08:01:06 +02:00
|
|
|
bti.projectFilePath = ct.sourceDirectory.stringAppended("/");
|
2018-12-20 18:51:12 +01:00
|
|
|
bti.workingDirectory = ct.workingDirectory;
|
2019-06-20 14:03:40 +02:00
|
|
|
bti.buildKey = ct.title;
|
2019-05-03 17:26:49 +02:00
|
|
|
appTargetList.append(bti);
|
2018-12-20 18:51:12 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return appTargetList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeploymentData CMakeBuildConfiguration::deploymentData() const
|
|
|
|
|
{
|
|
|
|
|
DeploymentData result;
|
|
|
|
|
|
|
|
|
|
QDir sourceDir = target()->project()->projectDirectory().toString();
|
|
|
|
|
QDir buildDir = buildDirectory().toString();
|
|
|
|
|
|
|
|
|
|
QString deploymentPrefix;
|
|
|
|
|
QString deploymentFilePath = sourceDir.filePath("QtCreatorDeployment.txt");
|
|
|
|
|
|
|
|
|
|
bool hasDeploymentFile = QFileInfo::exists(deploymentFilePath);
|
|
|
|
|
if (!hasDeploymentFile) {
|
|
|
|
|
deploymentFilePath = buildDir.filePath("QtCreatorDeployment.txt");
|
|
|
|
|
hasDeploymentFile = QFileInfo::exists(deploymentFilePath);
|
|
|
|
|
}
|
2019-04-12 14:49:59 +02:00
|
|
|
if (!hasDeploymentFile)
|
|
|
|
|
return result;
|
2018-12-20 18:51:12 +01:00
|
|
|
|
2019-04-12 14:49:59 +02:00
|
|
|
deploymentPrefix = result.addFilesFromDeploymentFile(deploymentFilePath,
|
|
|
|
|
sourceDir.absolutePath());
|
2018-12-20 18:51:12 +01:00
|
|
|
for (const CMakeBuildTarget &ct : m_buildTargets) {
|
|
|
|
|
if (ct.targetType == ExecutableType || ct.targetType == DynamicLibraryType) {
|
2019-04-23 17:49:42 +02:00
|
|
|
if (!ct.executable.isEmpty()
|
|
|
|
|
&& !result.deployableForLocalFile(ct.executable.toString()).isValid()) {
|
2018-12-20 18:51:12 +01:00
|
|
|
result.addFile(ct.executable.toString(),
|
|
|
|
|
deploymentPrefix + buildDir.relativeFilePath(ct.executable.toFileInfo().dir().path()),
|
|
|
|
|
DeployableFile::TypeExecutable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList CMakeBuildConfiguration::buildTargetTitles() const
|
|
|
|
|
{
|
|
|
|
|
return transform(m_buildTargets, &CMakeBuildTarget::title);
|
2016-10-10 10:22:06 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
const QList<CMakeBuildTarget> &CMakeBuildConfiguration::buildTargets() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildTargets;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath CMakeBuildConfiguration::shadowBuildDirectory(const FilePath &projectFilePath,
|
2016-03-01 14:12:35 +01:00
|
|
|
const Kit *k,
|
|
|
|
|
const QString &bcName,
|
|
|
|
|
BuildConfiguration::BuildType buildType)
|
|
|
|
|
{
|
|
|
|
|
if (projectFilePath.isEmpty())
|
2019-05-28 13:49:26 +02:00
|
|
|
return FilePath();
|
2016-03-01 14:12:35 +01:00
|
|
|
|
|
|
|
|
const QString projectName = projectFilePath.parentDir().fileName();
|
2019-06-26 17:09:35 +02:00
|
|
|
ProjectMacroExpander expander(projectFilePath, projectName, k, bcName, buildType);
|
2016-03-01 14:12:35 +01:00
|
|
|
QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString());
|
2018-10-05 15:04:25 +02:00
|
|
|
QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
|
2018-10-23 16:44:34 +02:00
|
|
|
buildPath.replace(" ", "-");
|
2019-05-28 13:49:26 +02:00
|
|
|
return FilePath::fromUserInput(projectDir.absoluteFilePath(buildPath));
|
2016-03-01 14:12:35 +01:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
void CMakeBuildConfiguration::buildTarget(const QString &buildTarget)
|
|
|
|
|
{
|
|
|
|
|
const Core::Id buildStep = ProjectExplorer::Constants::BUILDSTEPS_BUILD;
|
2018-11-04 23:09:41 +01:00
|
|
|
auto cmBs = qobject_cast<CMakeBuildStep *>(Utils::findOrDefault(
|
|
|
|
|
stepList(buildStep)->steps(),
|
|
|
|
|
[](const ProjectExplorer::BuildStep *bs) {
|
2016-11-14 15:18:25 +01:00
|
|
|
return bs->id() == Constants::CMAKE_BUILD_STEP_ID;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
QString originalBuildTarget;
|
|
|
|
|
if (cmBs) {
|
|
|
|
|
originalBuildTarget = cmBs->buildTarget();
|
|
|
|
|
cmBs->setBuildTarget(buildTarget);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-05 15:47:41 +01:00
|
|
|
BuildManager::buildList(stepList(buildStep));
|
2016-11-14 15:18:25 +01:00
|
|
|
|
|
|
|
|
if (cmBs)
|
|
|
|
|
cmBs->setBuildTarget(originalBuildTarget);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
CMakeConfig CMakeBuildConfiguration::configurationFromCMake() const
|
2016-02-24 18:00:24 +01:00
|
|
|
{
|
2017-09-28 11:32:39 +02:00
|
|
|
return m_configurationFromCMake;
|
|
|
|
|
}
|
2016-02-24 18:00:24 +01:00
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
void CMakeBuildConfiguration::setConfigurationFromCMake(const CMakeConfig &config)
|
|
|
|
|
{
|
|
|
|
|
m_configurationFromCMake = config;
|
2016-02-24 18:00:24 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
void CMakeBuildConfiguration::setBuildTargets(const QList<CMakeBuildTarget> &targets)
|
2016-02-24 18:00:24 +01:00
|
|
|
{
|
2017-09-28 11:32:39 +02:00
|
|
|
m_buildTargets = targets;
|
|
|
|
|
}
|
2016-02-24 18:00:24 +01:00
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
void CMakeBuildConfiguration::setConfigurationForCMake(const QList<ConfigModel::DataItem> &items)
|
|
|
|
|
{
|
2016-02-24 18:00:24 +01:00
|
|
|
const CMakeConfig newConfig = Utils::transform(items, [](const ConfigModel::DataItem &i) {
|
|
|
|
|
CMakeConfigItem ni;
|
|
|
|
|
ni.key = i.key.toUtf8();
|
|
|
|
|
ni.value = i.value.toUtf8();
|
|
|
|
|
ni.documentation = i.description.toUtf8();
|
|
|
|
|
ni.isAdvanced = i.isAdvanced;
|
2017-09-27 12:28:11 +02:00
|
|
|
ni.isUnset = i.isUnset;
|
2017-01-18 16:53:01 +01:00
|
|
|
ni.inCMakeCache = i.inCMakeCache;
|
2016-10-10 09:49:46 +10:00
|
|
|
ni.values = i.values;
|
2016-02-24 18:00:24 +01:00
|
|
|
switch (i.type) {
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::BOOLEAN:
|
|
|
|
|
ni.type = CMakeConfigItem::BOOL;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::FILE:
|
|
|
|
|
ni.type = CMakeConfigItem::FILEPATH;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::DIRECTORY:
|
|
|
|
|
ni.type = CMakeConfigItem::PATH;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::STRING:
|
|
|
|
|
ni.type = CMakeConfigItem::STRING;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::UNKNOWN:
|
|
|
|
|
default:
|
|
|
|
|
ni.type = CMakeConfigItem::INTERNAL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ni;
|
|
|
|
|
});
|
|
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
const CMakeConfig config = configurationForCMake() + newConfig;
|
|
|
|
|
setConfigurationForCMake(config);
|
2016-02-24 18:00:24 +01:00
|
|
|
}
|
|
|
|
|
|
2017-04-07 11:15:26 +02:00
|
|
|
void CMakeBuildConfiguration::clearError(ForceEnabledChanged fec)
|
2017-03-01 12:52:24 +01:00
|
|
|
{
|
|
|
|
|
if (!m_error.isEmpty()) {
|
|
|
|
|
m_error.clear();
|
2017-04-07 11:15:26 +02:00
|
|
|
fec = ForceEnabledChanged::True;
|
2017-03-01 12:52:24 +01:00
|
|
|
}
|
2017-04-07 11:15:26 +02:00
|
|
|
if (fec == ForceEnabledChanged::True)
|
|
|
|
|
emit enabledChanged();
|
2017-03-01 12:52:24 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-19 15:29:11 +02:00
|
|
|
void CMakeBuildConfiguration::emitBuildTypeChanged()
|
|
|
|
|
{
|
|
|
|
|
emit buildTypeChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-03 13:52:50 +01:00
|
|
|
static CMakeConfig removeDuplicates(const CMakeConfig &config)
|
|
|
|
|
{
|
|
|
|
|
CMakeConfig result;
|
|
|
|
|
// Remove duplicates (last value wins):
|
|
|
|
|
QSet<QByteArray> knownKeys;
|
|
|
|
|
for (int i = config.count() - 1; i >= 0; --i) {
|
|
|
|
|
const CMakeConfigItem &item = config.at(i);
|
|
|
|
|
if (knownKeys.contains(item.key))
|
|
|
|
|
continue;
|
|
|
|
|
result.append(item);
|
|
|
|
|
knownKeys.insert(item.key);
|
|
|
|
|
}
|
|
|
|
|
Utils::sort(result, CMakeConfigItem::sortOperator());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
void CMakeBuildConfiguration::setConfigurationForCMake(const CMakeConfig &config)
|
2015-09-10 16:17:38 +02:00
|
|
|
{
|
2019-03-06 14:17:17 +02:00
|
|
|
auto configs = removeDuplicates(config);
|
|
|
|
|
if (m_configurationForCMake.isEmpty())
|
|
|
|
|
m_configurationForCMake = removeDuplicates(configs + m_initialConfiguration);
|
|
|
|
|
else
|
|
|
|
|
m_configurationForCMake = configs;
|
2016-05-12 17:23:03 +02:00
|
|
|
|
|
|
|
|
const Kit *k = target()->kit();
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeConfig kitConfig = CMakeConfigurationKitAspect::configuration(k);
|
2016-05-12 17:23:03 +02:00
|
|
|
bool hasKitOverride = false;
|
2017-09-28 11:32:39 +02:00
|
|
|
foreach (const CMakeConfigItem &i, m_configurationForCMake) {
|
2016-05-12 17:23:03 +02:00
|
|
|
const QString b = CMakeConfigItem::expandedValueOf(k, i.key, kitConfig);
|
2017-09-27 12:28:11 +02:00
|
|
|
if (!b.isNull() && (i.expandedValue(k) != b || i.isUnset)) {
|
2016-05-12 17:23:03 +02:00
|
|
|
hasKitOverride = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasKitOverride)
|
2016-06-21 16:28:04 +02:00
|
|
|
setWarning(tr("CMake configuration set by the kit was overridden in the project."));
|
2016-05-12 17:23:03 +02:00
|
|
|
else
|
|
|
|
|
setWarning(QString());
|
2017-09-28 11:32:39 +02:00
|
|
|
|
|
|
|
|
emit configurationForCMakeChanged();
|
2015-09-10 16:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
CMakeConfig CMakeBuildConfiguration::configurationForCMake() const
|
2015-09-10 16:17:38 +02:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
return removeDuplicates(CMakeConfigurationKitAspect::configuration(target()->kit()) + m_configurationForCMake);
|
2015-09-10 16:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-11 16:33:15 +01:00
|
|
|
void CMakeBuildConfiguration::setError(const QString &message)
|
|
|
|
|
{
|
2017-07-18 16:48:02 +02:00
|
|
|
const QString oldMessage = m_error;
|
2017-03-01 12:52:24 +01:00
|
|
|
if (m_error != message)
|
2016-12-02 17:32:31 +01:00
|
|
|
m_error = message;
|
2017-03-01 12:52:24 +01:00
|
|
|
if (oldMessage.isEmpty() && !message.isEmpty())
|
|
|
|
|
emit enabledChanged();
|
2016-02-11 16:33:15 +01:00
|
|
|
emit errorOccured(m_error);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:23:03 +02:00
|
|
|
void CMakeBuildConfiguration::setWarning(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
if (m_warning == message)
|
|
|
|
|
return;
|
|
|
|
|
m_warning = message;
|
|
|
|
|
emit warningOccured(m_warning);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-11 16:33:15 +01:00
|
|
|
QString CMakeBuildConfiguration::error() const
|
|
|
|
|
{
|
|
|
|
|
return m_error;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:23:03 +02:00
|
|
|
QString CMakeBuildConfiguration::warning() const
|
|
|
|
|
{
|
|
|
|
|
return m_warning;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-08 18:02:50 +01:00
|
|
|
ProjectExplorer::NamedWidget *CMakeBuildConfiguration::createConfigWidget()
|
2009-11-26 14:43:27 +01:00
|
|
|
{
|
2012-11-08 17:35:59 +01:00
|
|
|
return new CMakeBuildSettingsWidget(this);
|
2009-11-26 14:43:27 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
/*!
|
|
|
|
|
\class CMakeBuildConfigurationFactory
|
|
|
|
|
*/
|
|
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory()
|
|
|
|
|
{
|
2018-05-04 16:52:21 +02:00
|
|
|
registerBuildConfiguration<CMakeBuildConfiguration>("CMakeProjectManager.CMakeBuildConfiguration");
|
|
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
setSupportedProjectType(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
|
|
|
|
setSupportedProjectMimeTypeName(Constants::CMAKEPROJECTMIMETYPE);
|
|
|
|
|
}
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2017-02-07 16:23:36 +01:00
|
|
|
CMakeBuildConfigurationFactory::BuildType CMakeBuildConfigurationFactory::buildTypeFromByteArray(const QByteArray &in)
|
|
|
|
|
{
|
|
|
|
|
const QByteArray bt = in.toLower();
|
|
|
|
|
if (bt == "debug")
|
|
|
|
|
return BuildTypeDebug;
|
|
|
|
|
if (bt == "release")
|
|
|
|
|
return BuildTypeRelease;
|
|
|
|
|
if (bt == "relwithdebinfo")
|
|
|
|
|
return BuildTypeRelWithDebInfo;
|
|
|
|
|
if (bt == "minsizerel")
|
|
|
|
|
return BuildTypeMinSizeRel;
|
|
|
|
|
return BuildTypeNone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfiguration::BuildType CMakeBuildConfigurationFactory::cmakeBuildTypeToBuildType(const CMakeBuildConfigurationFactory::BuildType &in)
|
|
|
|
|
{
|
|
|
|
|
// Cover all common CMake build types
|
|
|
|
|
if (in == BuildTypeRelease || in == BuildTypeMinSizeRel)
|
|
|
|
|
return BuildConfiguration::Release;
|
|
|
|
|
else if (in == BuildTypeDebug)
|
|
|
|
|
return BuildConfiguration::Debug;
|
|
|
|
|
else if (in == BuildTypeRelWithDebInfo)
|
|
|
|
|
return BuildConfiguration::Profile;
|
|
|
|
|
else
|
|
|
|
|
return BuildConfiguration::Unknown;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 10:22:13 +02:00
|
|
|
QList<BuildInfo> CMakeBuildConfigurationFactory::availableBuilds
|
|
|
|
|
(const Kit *k, const FilePath &projectPath, bool forSetup) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2019-01-29 16:51:17 +01:00
|
|
|
QList<BuildInfo> result;
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2019-06-27 10:22:13 +02:00
|
|
|
FilePath path = forSetup ? Project::projectDirectory(projectPath) : projectPath;
|
2013-08-13 10:52:57 +02:00
|
|
|
|
2019-06-27 10:22:13 +02:00
|
|
|
for (int type = BuildTypeNone; type != BuildTypeLast; ++type) {
|
|
|
|
|
BuildInfo info = createBuildInfo(k, path.toString(), BuildType(type));
|
|
|
|
|
if (forSetup) {
|
|
|
|
|
info.displayName = info.typeName;
|
|
|
|
|
info.buildDirectory
|
|
|
|
|
= CMakeBuildConfiguration::shadowBuildDirectory(projectPath, k,
|
|
|
|
|
info.displayName, info.buildType);
|
|
|
|
|
}
|
2015-09-10 16:17:38 +02:00
|
|
|
result << info;
|
|
|
|
|
}
|
2013-07-22 15:53:57 +02:00
|
|
|
return result;
|
2010-01-18 12:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-29 16:51:17 +01:00
|
|
|
BuildInfo CMakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
|
|
|
|
|
const QString &sourceDir,
|
|
|
|
|
BuildType buildType) const
|
2013-07-22 15:53:57 +02:00
|
|
|
{
|
2019-01-29 16:51:17 +01:00
|
|
|
BuildInfo info(this);
|
|
|
|
|
info.kitId = k->id();
|
|
|
|
|
|
|
|
|
|
CMakeExtraBuildInfo extra;
|
|
|
|
|
extra.sourceDirectory = sourceDir;
|
2016-02-03 13:52:50 +01:00
|
|
|
|
|
|
|
|
CMakeConfigItem buildTypeItem;
|
2015-09-10 16:17:38 +02:00
|
|
|
switch (buildType) {
|
|
|
|
|
case BuildTypeNone:
|
2019-01-29 16:51:17 +01:00
|
|
|
info.typeName = tr("Build");
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeDebug:
|
2017-02-22 15:09:35 +01:00
|
|
|
buildTypeItem = {CMakeConfigItem("CMAKE_BUILD_TYPE", "Debug")};
|
2019-01-29 16:51:17 +01:00
|
|
|
info.typeName = tr("Debug");
|
|
|
|
|
info.buildType = BuildConfiguration::Debug;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeRelease:
|
2017-02-22 15:09:35 +01:00
|
|
|
buildTypeItem = {CMakeConfigItem("CMAKE_BUILD_TYPE", "Release")};
|
2019-01-29 16:51:17 +01:00
|
|
|
info.typeName = tr("Release");
|
|
|
|
|
info.buildType = BuildConfiguration::Release;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeMinSizeRel:
|
2017-02-22 15:09:35 +01:00
|
|
|
buildTypeItem = {CMakeConfigItem("CMAKE_BUILD_TYPE", "MinSizeRel")};
|
2019-01-29 16:51:17 +01:00
|
|
|
info.typeName = tr("Minimum Size Release");
|
|
|
|
|
info.buildType = BuildConfiguration::Release;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeRelWithDebInfo:
|
2017-02-22 15:09:35 +01:00
|
|
|
buildTypeItem = {CMakeConfigItem("CMAKE_BUILD_TYPE", "RelWithDebInfo")};
|
2019-01-29 16:51:17 +01:00
|
|
|
info.typeName = tr("Release with Debug Information");
|
|
|
|
|
info.buildType = BuildConfiguration::Profile;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
QTC_CHECK(false);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-07-22 15:53:57 +02:00
|
|
|
|
2016-02-03 13:52:50 +01:00
|
|
|
if (!buildTypeItem.isNull())
|
2019-01-29 16:51:17 +01:00
|
|
|
extra.configuration.append(buildTypeItem);
|
2016-02-03 13:52:50 +01:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
const QString sysRoot = SysRootKitAspect::sysRoot(k).toString();
|
2019-01-07 12:15:40 +01:00
|
|
|
if (!sysRoot.isEmpty()) {
|
2019-01-29 16:51:17 +01:00
|
|
|
extra.configuration.append(CMakeConfigItem("CMAKE_SYSROOT", sysRoot.toUtf8()));
|
2019-02-06 12:50:51 +01:00
|
|
|
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitAspect::toolChain(
|
2019-01-07 12:15:40 +01:00
|
|
|
k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
|
|
|
if (tc) {
|
|
|
|
|
const QByteArray targetTriple = tc->originalTargetTriple().toUtf8();
|
2019-01-29 16:51:17 +01:00
|
|
|
extra.configuration.append(CMakeConfigItem("CMAKE_C_COMPILER_TARGET", targetTriple));
|
|
|
|
|
extra.configuration.append(CMakeConfigItem("CMAKE_CXX_COMPILER_TARGET ", targetTriple));
|
2019-01-07 12:15:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-01-29 16:51:17 +01:00
|
|
|
info.extraInfo = QVariant::fromValue(extra);
|
2019-01-07 12:15:40 +01:00
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-03 16:12:00 +01:00
|
|
|
ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const
|
|
|
|
|
{
|
2017-02-07 16:23:36 +01:00
|
|
|
QByteArray cmakeBuildTypeName;
|
2013-08-16 17:45:16 +02:00
|
|
|
QFile cmakeCache(buildDirectory().toString() + QLatin1String("/CMakeCache.txt"));
|
2011-03-03 16:12:00 +01:00
|
|
|
if (cmakeCache.open(QIODevice::ReadOnly)) {
|
|
|
|
|
while (!cmakeCache.atEnd()) {
|
2012-11-21 23:54:06 +02:00
|
|
|
QByteArray line = cmakeCache.readLine();
|
2011-03-03 16:12:00 +01:00
|
|
|
if (line.startsWith("CMAKE_BUILD_TYPE")) {
|
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 (int pos = line.indexOf('='))
|
2017-02-07 16:23:36 +01:00
|
|
|
cmakeBuildTypeName = line.mid(pos + 1).trimmed();
|
2011-03-03 16:12:00 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cmakeCache.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cover all common CMake build types
|
2017-02-07 16:23:36 +01:00
|
|
|
const CMakeBuildConfigurationFactory::BuildType cmakeBuildType
|
2019-08-05 16:39:00 +02:00
|
|
|
= CMakeBuildConfigurationFactory::buildTypeFromByteArray(cmakeBuildTypeName);
|
2017-02-07 16:23:36 +01:00
|
|
|
return CMakeBuildConfigurationFactory::cmakeBuildTypeToBuildType(cmakeBuildType);
|
2011-03-03 16:12:00 +01:00
|
|
|
}
|
2012-10-02 17:46:12 +02:00
|
|
|
|
2019-08-05 15:56:03 +02:00
|
|
|
CMakeProject *CMakeBuildConfiguration::project() const
|
|
|
|
|
{
|
|
|
|
|
return qobject_cast<CMakeProject *>(BuildConfiguration::project());
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 09:16:55 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CMakeProjectManager
|