forked from qt-creator/qt-creator
ProjectExplorer: Move BuildSystem owership to BuildConfiguration
... or Target. This patch moves build system from conceptually "one per project" to "one per target (i.e. per project-and-kit)" or "per BuildConfigurations" for targets where the builds differ significantly. Building requires usually items from the kit (Qt version, compiler, ...) so a target-agnostic build is practically almost always wrong. Moving the build system to the target also has the potential to solve issues caused by switching targets while parsing, that used Project::activeTarget() regularly, with potentially different results before and after the switch. This patch might create performance/size regressions when several targets are set up per project as the build system implementation's internal data are duplicated in this case. The idea is to fix that by sharing per-project pieces again in the project implementation once these problems occur. Change-Id: I87f640ce418b93175b5029124eaa55f3b8721dca Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -68,11 +68,6 @@ namespace CMakeProjectManager {
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
static CMakeBuildConfiguration *activeBc(const CMakeProject *p)
|
||||
{
|
||||
return qobject_cast<CMakeBuildConfiguration *>(p->activeTarget() ? p->activeTarget()->activeBuildConfiguration() : nullptr);
|
||||
}
|
||||
|
||||
// QtCreator CMake Generator wishlist:
|
||||
// Which make targets we need to build to get all executables
|
||||
// What is the actual compiler executable
|
||||
@@ -90,8 +85,6 @@ CMakeProject::CMakeProject(const FilePath &fileName)
|
||||
setCanBuildProducts();
|
||||
setKnowsAllBuildExecutables(false);
|
||||
setHasMakeInstallEquivalent(true);
|
||||
|
||||
setBuildSystemCreator([](Project *p) { return new CMakeBuildSystem(p); });
|
||||
}
|
||||
|
||||
CMakeProject::~CMakeProject() = default;
|
||||
@@ -108,38 +101,6 @@ Tasks CMakeProject::projectIssues(const Kit *k) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void CMakeProject::runCMake()
|
||||
{
|
||||
CMakeBuildConfiguration *bc = activeBc(this);
|
||||
if (isParsing() || !bc)
|
||||
return;
|
||||
|
||||
BuildDirParameters parameters(bc);
|
||||
bc->m_buildDirManager.setParametersAndRequestParse(parameters,
|
||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
||||
| BuildDirManager::REPARSE_FORCE_CMAKE_RUN
|
||||
| BuildDirManager::REPARSE_URGENT);
|
||||
}
|
||||
|
||||
void CMakeProject::runCMakeAndScanProjectTree()
|
||||
{
|
||||
CMakeBuildConfiguration *bc = activeBc(this);
|
||||
if (isParsing() || !bc)
|
||||
return;
|
||||
|
||||
BuildDirParameters parameters(bc);
|
||||
bc->m_buildDirManager.setParametersAndRequestParse(parameters,
|
||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
||||
| BuildDirManager::REPARSE_SCAN);
|
||||
}
|
||||
|
||||
void CMakeProject::buildCMakeTarget(const QString &buildTarget)
|
||||
{
|
||||
QTC_ASSERT(!buildTarget.isEmpty(), return);
|
||||
CMakeBuildConfiguration *bc = activeBc(this);
|
||||
if (bc)
|
||||
bc->buildTarget(buildTarget);
|
||||
}
|
||||
|
||||
ProjectImporter *CMakeProject::projectImporter() const
|
||||
{
|
||||
@@ -148,19 +109,6 @@ ProjectImporter *CMakeProject::projectImporter() const
|
||||
return m_projectImporter.get();
|
||||
}
|
||||
|
||||
bool CMakeProject::persistCMakeState()
|
||||
{
|
||||
CMakeBuildConfiguration *bc = activeBc(this);
|
||||
return bc ? bc->m_buildDirManager.persistCMakeState() : false;
|
||||
}
|
||||
|
||||
void CMakeProject::clearCMakeCache()
|
||||
{
|
||||
CMakeBuildConfiguration *bc = activeBc(this);
|
||||
if (bc)
|
||||
bc->m_buildDirManager.clearCache();
|
||||
}
|
||||
|
||||
bool CMakeProject::setupTarget(Target *t)
|
||||
{
|
||||
t->updateDefaultBuildConfigurations();
|
||||
@@ -170,42 +118,6 @@ bool CMakeProject::setupTarget(Target *t)
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList CMakeProject::filesGeneratedFrom(const QString &sourceFile) const
|
||||
{
|
||||
if (!activeTarget())
|
||||
return QStringList();
|
||||
QFileInfo fi(sourceFile);
|
||||
FilePath project = projectDirectory();
|
||||
FilePath baseDirectory = FilePath::fromString(fi.absolutePath());
|
||||
|
||||
while (baseDirectory.isChildOf(project)) {
|
||||
const FilePath cmakeListsTxt = baseDirectory.pathAppended("CMakeLists.txt");
|
||||
if (cmakeListsTxt.exists())
|
||||
break;
|
||||
baseDirectory = baseDirectory.parentDir();
|
||||
}
|
||||
|
||||
QDir srcDirRoot = QDir(project.toString());
|
||||
QString relativePath = srcDirRoot.relativeFilePath(baseDirectory.toString());
|
||||
QDir buildDir = QDir(activeTarget()->activeBuildConfiguration()->buildDirectory().toString());
|
||||
QString generatedFilePath = buildDir.absoluteFilePath(relativePath);
|
||||
|
||||
if (fi.suffix() == "ui") {
|
||||
generatedFilePath += "/ui_";
|
||||
generatedFilePath += fi.completeBaseName();
|
||||
generatedFilePath += ".h";
|
||||
return QStringList(QDir::cleanPath(generatedFilePath));
|
||||
} else if (fi.suffix() == "scxml") {
|
||||
generatedFilePath += "/";
|
||||
generatedFilePath += QDir::cleanPath(fi.completeBaseName());
|
||||
return QStringList({generatedFilePath + ".h",
|
||||
generatedFilePath + ".cpp"});
|
||||
} else {
|
||||
// TODO: Other types will be added when adapters for their compilers become available.
|
||||
return QStringList();
|
||||
}
|
||||
}
|
||||
|
||||
ProjectExplorer::DeploymentKnowledge CMakeProject::deploymentKnowledge() const
|
||||
{
|
||||
return !files([](const ProjectExplorer::Node *n) {
|
||||
@@ -232,9 +144,4 @@ MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
|
||||
return cmd;
|
||||
}
|
||||
|
||||
bool CMakeProject::mustUpdateCMakeStateBeforeBuild() const
|
||||
{
|
||||
return buildSystem()->isWaitingForParse();
|
||||
}
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
Reference in New Issue
Block a user