Commit d6ea2945 authored by Milian Wolff's avatar Milian Wolff Committed by dt
Browse files

add API to query build type (unknown, release, debug) to BuildConfiguration



Merge-request: 261
Reviewed-by: default avatardt <qtc-committer@nokia.com>
parent 0ecd80c6
......@@ -273,3 +273,36 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer
delete bc;
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;
BuildType buildType() const;
protected:
CMakeBuildConfiguration(CMakeTarget *parent, CMakeBuildConfiguration *source);
virtual bool fromMap(const QVariantMap &map);
......
......@@ -223,3 +223,9 @@ BuildConfiguration *GenericBuildConfigurationFactory::restore(ProjectExplorer::T
delete bc;
return 0;
}
BuildConfiguration::BuildType GenericBuildConfiguration::buildType() const
{
return Unknown;
}
......@@ -62,6 +62,8 @@ public:
ProjectExplorer::IOutputParser *createOutputParser() const;
BuildType buildType() const;
protected:
GenericBuildConfiguration(GenericTarget *parent, GenericBuildConfiguration *source);
GenericBuildConfiguration(GenericTarget *parent, const QString &id);
......
......@@ -99,6 +99,13 @@ public:
virtual ProjectExplorer::ToolChain *toolChain() const;
virtual void setToolChain(ProjectExplorer::ToolChain *tc);
enum BuildType {
Unknown,
Debug,
Release
};
virtual BuildType buildType() const = 0;
signals:
void environmentChanged();
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
void setEnabled(bool enabled);
BuildType buildType() const;
public slots:
void importFromBuildDirectory();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment