forked from qt-creator/qt-creator
add API to query build type (unknown, release, debug) to BuildConfiguration
Merge-request: 261 Reviewed-by: dt <qtc-committer@nokia.com>
This commit is contained in:
@@ -273,3 +273,36 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer
|
|||||||
delete bc;
|
delete bc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const
|
||||||
|
{
|
||||||
|
QString cmakeBuildType;
|
||||||
|
QFile cmakeCache(buildDirectory() + "/CMakeCache.txt");
|
||||||
|
if (cmakeCache.open(QIODevice::ReadOnly)) {
|
||||||
|
while (!cmakeCache.atEnd()) {
|
||||||
|
QString line = cmakeCache.readLine();
|
||||||
|
if (line.startsWith("CMAKE_BUILD_TYPE")) {
|
||||||
|
if (int pos = line.indexOf('=')) {
|
||||||
|
cmakeBuildType = line.mid(pos + 1).trimmed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmakeCache.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cover all common CMake build types
|
||||||
|
if (cmakeBuildType.compare("Release", Qt::CaseInsensitive) == 0
|
||||||
|
|| cmakeBuildType.compare("MinSizeRel", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
return Release;
|
||||||
|
} else if (cmakeBuildType.compare("Debug", Qt::CaseInsensitive) == 0
|
||||||
|
|| cmakeBuildType.compare("debugfull", Qt::CaseInsensitive) == 0
|
||||||
|
|| cmakeBuildType.compare("RelWithDebInfo", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
return Debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -68,6 +68,8 @@ public:
|
|||||||
|
|
||||||
Utils::Environment baseEnvironment() const;
|
Utils::Environment baseEnvironment() const;
|
||||||
|
|
||||||
|
BuildType buildType() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CMakeBuildConfiguration(CMakeTarget *parent, CMakeBuildConfiguration *source);
|
CMakeBuildConfiguration(CMakeTarget *parent, CMakeBuildConfiguration *source);
|
||||||
virtual bool fromMap(const QVariantMap &map);
|
virtual bool fromMap(const QVariantMap &map);
|
||||||
|
@@ -223,3 +223,9 @@ BuildConfiguration *GenericBuildConfigurationFactory::restore(ProjectExplorer::T
|
|||||||
delete bc;
|
delete bc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BuildConfiguration::BuildType GenericBuildConfiguration::buildType() const
|
||||||
|
{
|
||||||
|
return Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -62,6 +62,8 @@ public:
|
|||||||
|
|
||||||
ProjectExplorer::IOutputParser *createOutputParser() const;
|
ProjectExplorer::IOutputParser *createOutputParser() const;
|
||||||
|
|
||||||
|
BuildType buildType() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GenericBuildConfiguration(GenericTarget *parent, GenericBuildConfiguration *source);
|
GenericBuildConfiguration(GenericTarget *parent, GenericBuildConfiguration *source);
|
||||||
GenericBuildConfiguration(GenericTarget *parent, const QString &id);
|
GenericBuildConfiguration(GenericTarget *parent, const QString &id);
|
||||||
|
@@ -99,6 +99,13 @@ public:
|
|||||||
virtual ProjectExplorer::ToolChain *toolChain() const;
|
virtual ProjectExplorer::ToolChain *toolChain() const;
|
||||||
virtual void setToolChain(ProjectExplorer::ToolChain *tc);
|
virtual void setToolChain(ProjectExplorer::ToolChain *tc);
|
||||||
|
|
||||||
|
enum BuildType {
|
||||||
|
Unknown,
|
||||||
|
Debug,
|
||||||
|
Release
|
||||||
|
};
|
||||||
|
virtual BuildType buildType() const = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void environmentChanged();
|
void environmentChanged();
|
||||||
void buildDirectoryChanged();
|
void buildDirectoryChanged();
|
||||||
|
@@ -868,3 +868,12 @@ void Qt4BuildConfiguration::importFromBuildDirectory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BuildConfiguration::BuildType Qt4BuildConfiguration::buildType() const
|
||||||
|
{
|
||||||
|
if (qmakeBuildConfiguration() & QtVersion::DebugBuild)
|
||||||
|
return Debug;
|
||||||
|
else
|
||||||
|
return Release;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -124,6 +124,8 @@ public:
|
|||||||
/// \internal For Qt4Project, since that manages the parsing information
|
/// \internal For Qt4Project, since that manages the parsing information
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
|
BuildType buildType() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void importFromBuildDirectory();
|
void importFromBuildDirectory();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user