Commit aface7b1 authored by Tobias Hunger's avatar Tobias Hunger

Expand CurrentBuild:Type in the wizards

This was just unset before.

Task-number: QTCREATORBUG-15178
Change-Id: Ice66273e2ce9bc60bd8a96516f774201a7a95331
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@theqtcompany.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 63468357
......@@ -61,13 +61,14 @@ namespace Internal {
const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNinja";
const char INITIAL_ARGUMENTS[] = "CMakeProjectManager.CMakeBuildConfiguration.InitialArgument";
static FileName shadowBuildDirectory(const FileName &projectFilePath, const Kit *k, const QString &bcName)
static FileName shadowBuildDirectory(const FileName &projectFilePath, const Kit *k,
const QString &bcName, BuildConfiguration::BuildType buildType)
{
if (projectFilePath.isEmpty())
return FileName();
const QString projectName = projectFilePath.parentDir().fileName();
ProjectMacroExpander expander(projectName, k, bcName);
ProjectMacroExpander expander(projectName, k, bcName, buildType);
QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString());
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return FileName::fromUserInput(projectDir.absoluteFilePath(buildPath));
......@@ -79,7 +80,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
setBuildDirectory(shadowBuildDirectory(project->projectFilePath(),
parent->kit(),
displayName()));
displayName(), BuildConfiguration::Unknown));
}
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent,
......@@ -202,7 +203,8 @@ QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableSet
} else {
info->displayName = info->typeName;
}
info->buildDirectory = shadowBuildDirectory(projectPathName, k, info->displayName);
info->buildDirectory
= shadowBuildDirectory(projectPathName, k, info->displayName, info->buildType);
result << info;
}
return result;
......@@ -220,7 +222,7 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
if (copy.buildDirectory.isEmpty()) {
copy.buildDirectory = shadowBuildDirectory(project->projectFilePath(), parent->kit(),
copy.displayName);
copy.displayName, info->buildType);
}
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(parent);
......@@ -306,18 +308,22 @@ CMakeBuildInfo *CMakeBuildConfigurationFactory::createBuildInfo(const ProjectExp
case BuildTypeDebug:
info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=Debug");
info->typeName = tr("Debug");
info->buildType = BuildConfiguration::Debug;
break;
case BuildTypeRelease:
info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=Release");
info->typeName = tr("Release");
info->buildType = BuildConfiguration::Release;
break;
case BuildTypeMinSizeRel:
info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=MinSizeRel");
info->typeName = tr("Minimum Size Release");
info->buildType = BuildConfiguration::Release;
break;
case BuildTypeRelWithDebInfo:
info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=RelWithDebInfo");
info->typeName = tr("Release with Debug Information");
info->buildType = BuildConfiguration::Profile;
break;
default:
QTC_CHECK(false);
......
......@@ -35,7 +35,8 @@
namespace ProjectExplorer {
ProjectMacroExpander::ProjectMacroExpander(const QString &projectName,
const Kit *kit, const QString &bcName)
const Kit *kit, const QString &bcName,
BuildConfiguration::BuildType buildType)
{
registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
QCoreApplication::translate("ProjectExplorer", "Name of current project"),
......@@ -45,6 +46,10 @@ ProjectMacroExpander::ProjectMacroExpander(const QString &projectName,
QCoreApplication::translate("ProjectExplorer", "Name of current build"),
[bcName] { return bcName; });
registerVariable(Constants::VAR_CURRENTBUILD_TYPE,
QCoreApplication::translate("ProjectExplorer", "Type of current build"),
[buildType] { return BuildConfiguration::buildTypeName(buildType); });
registerSubProvider([kit] { return kit->macroExpander(); });
}
......
......@@ -32,6 +32,9 @@
#define PROJECTMACROEXPANDER_H
#include "projectexplorer_export.h"
#include "buildconfiguration.h"
#include <utils/macroexpander.h>
namespace ProjectExplorer {
......@@ -40,7 +43,8 @@ class Kit;
class PROJECTEXPLORER_EXPORT ProjectMacroExpander : public Utils::MacroExpander
{
public:
ProjectMacroExpander(const QString &projectName, const Kit *kit, const QString &bcName);
ProjectMacroExpander(const QString &projectName, const Kit *kit, const QString &bcName,
BuildConfiguration::BuildType buildType);
};
} // namespace ProjectExplorer
......
......@@ -405,10 +405,11 @@ int QbsBuildConfigurationFactory::priority(const Kit *k, const QString &projectP
}
static Utils::FileName defaultBuildDirectory(const QString &projectFilePath, const Kit *k,
const QString &bcName)
const QString &bcName,
BuildConfiguration::BuildType buildType)
{
const QString projectName = QFileInfo(projectFilePath).completeBaseName();
ProjectMacroExpander expander(projectName, k, bcName);
ProjectMacroExpander expander(projectName, k, bcName, buildType);
QString projectDir = Project::projectDirectory(Utils::FileName::fromString(projectFilePath)).toString();
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return Utils::FileName::fromString(Utils::FileUtils::resolvePath(projectDir, buildPath));
......@@ -422,14 +423,18 @@ QList<BuildInfo *> QbsBuildConfigurationFactory::availableSetups(const Kit *k, c
//: The name of the debug build configuration created by default for a qbs project.
info->displayName = tr("Debug");
//: Non-ASCII characters in directory suffix may cause build issues.
info->buildDirectory = defaultBuildDirectory(projectPath, k, tr("Debug", "Shadow build directory suffix"));
info->buildDirectory
= defaultBuildDirectory(projectPath, k, tr("Debug", "Shadow build directory suffix"),
info->buildType);
result << info;
info = createBuildInfo(k, BuildConfiguration::Release);
//: The name of the release build configuration created by default for a qbs project.
info->displayName = tr("Release");
//: Non-ASCII characters in directory suffix may cause build issues.
info->buildDirectory = defaultBuildDirectory(projectPath, k, tr("Release", "Shadow build directory suffix"));
info->buildDirectory
= defaultBuildDirectory(projectPath, k, tr("Release", "Shadow build directory suffix"),
info->buildType);
result << info;
return result;
......@@ -450,7 +455,7 @@ BuildConfiguration *QbsBuildConfigurationFactory::create(Target *parent, const B
Utils::FileName buildDir = info->buildDirectory;
if (buildDir.isEmpty())
buildDir = defaultBuildDirectory(parent->project()->projectDirectory().toString(),
parent->kit(), info->displayName);
parent->kit(), info->displayName, info->buildType);
BuildConfiguration *bc
= QbsBuildConfiguration::setup(parent, info->displayName, info->displayName,
......
......@@ -75,13 +75,15 @@ namespace QmakeProjectManager {
// Helpers:
// --------------------------------------------------------------------
QString QmakeBuildConfiguration::shadowBuildDirectory(const QString &proFilePath, const Kit *k, const QString &suffix)
QString QmakeBuildConfiguration::shadowBuildDirectory(const QString &proFilePath, const Kit *k,
const QString &suffix,
BuildConfiguration::BuildType buildType)
{
if (proFilePath.isEmpty())
return QString();
const QString projectName = QFileInfo(proFilePath).completeBaseName();
ProjectMacroExpander expander(projectName, k, suffix);
ProjectMacroExpander expander(projectName, k, suffix, buildType);
QString projectDir = Project::projectDirectory(FileName::fromString(proFilePath)).toString();
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return FileUtils::resolvePath(projectDir, buildPath);
......@@ -89,9 +91,11 @@ QString QmakeBuildConfiguration::shadowBuildDirectory(const QString &proFilePath
static Utils::FileName defaultBuildDirectory(const QString &projectPath,
const ProjectExplorer::Kit *k,
const QString &suffix)
const QString &suffix,
BuildConfiguration::BuildType type)
{
return Utils::FileName::fromString(QmakeBuildConfiguration::shadowBuildDirectory(projectPath, k, suffix));
return Utils::FileName::fromString(QmakeBuildConfiguration::shadowBuildDirectory(projectPath, k,
suffix, type));
}
const char QMAKE_BC_ID[] = "Qt4ProjectManager.Qt4BuildConfiguration";
......@@ -597,7 +601,7 @@ QmakeBuildInfo *QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
info->buildDirectory = Utils::FileName::fromString(absoluteBuildPath);
} else {
info->buildDirectory = defaultBuildDirectory(projectPath, k, suffix);
info->buildDirectory = defaultBuildDirectory(projectPath, k, suffix, type);
}
info->buildType = type;
return info;
......@@ -690,7 +694,7 @@ void QmakeBuildConfigurationFactory::configureBuildConfiguration(Target *parent,
Utils::FileName directory = qmakeInfo->buildDirectory;
if (directory.isEmpty()) {
directory = defaultBuildDirectory(parent->project()->projectFilePath().toString(),
parent->kit(), qmakeInfo->displayName);
parent->kit(), qmakeInfo->displayName, bc->buildType());
}
bc->setBuildDirectory(directory);
......
......@@ -70,7 +70,7 @@ public:
/// suffix should be unique
static QString shadowBuildDirectory(const QString &profilePath, const ProjectExplorer::Kit *k,
const QString &suffix);
const QString &suffix, BuildConfiguration::BuildType type);
/// \internal for qmakestep
// used by qmake step to notify that the qmake args have changed
......
......@@ -50,7 +50,8 @@ public:
QString makefile;
QMakeStepConfig config;
bool operator==(const QmakeBuildInfo &o) {
bool operator==(const QmakeBuildInfo &o)
{
return ProjectExplorer::BuildInfo::operator==(o)
&& additionalArguments == o.additionalArguments
&& config == o.config;
......
......@@ -52,7 +52,8 @@ QmakeProjectConfigWidget::QmakeProjectConfigWidget(QmakeBuildConfiguration *bc)
m_defaultShadowBuildDir
= QmakeBuildConfiguration::shadowBuildDirectory(bc->target()->project()->projectFilePath().toString(),
bc->target()->kit(),
Utils::FileUtils::qmakeFriendlyName(bc->displayName()));
Utils::FileUtils::qmakeFriendlyName(bc->displayName()),
bc->buildType());
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
......
......@@ -264,7 +264,8 @@ QStringList QmakeProjectImporter::importCandidates(const FileName &projectPath)
candidates << pfi.absolutePath();
foreach (Kit *k, KitManager::kits()) {
QFileInfo fi(QmakeBuildConfiguration::shadowBuildDirectory(projectPath.toString(), k, QString()));
QFileInfo fi(QmakeBuildConfiguration::shadowBuildDirectory(projectPath.toString(), k,
QString(), BuildConfiguration::Unknown));
const QString baseDir = fi.absolutePath();
foreach (const QString &dir, QDir(baseDir).entryList()) {
......
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