forked from qt-creator/qt-creator
Qmake: Move buildDir() from ProFileNode to QmakeBuildSystem
More a buildsystem than a node thing in general and removes one use of activeBuildSystem and one use of the ProFileNode -> ProFile back pointers. Change-Id: Ie007fcd0db9e9294a08b3a1cd68f825c7d3dc9b8 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -84,7 +84,7 @@ bool QmakeMakeStep::init()
|
||||
|
||||
Utils::FilePath workingDirectory;
|
||||
if (bc->subNodeBuild())
|
||||
workingDirectory = bc->subNodeBuild()->buildDir(bc);
|
||||
workingDirectory = bc->qmakeBuildSystem()->buildDir(bc->subNodeBuild()->filePath());
|
||||
else
|
||||
workingDirectory = bc->buildDirectory();
|
||||
pp->setWorkingDirectory(workingDirectory);
|
||||
@@ -130,7 +130,7 @@ bool QmakeMakeStep::init()
|
||||
if (bc->fileNodeBuild() && subProFile) {
|
||||
QString objectsDir = subProFile->objectsDirectory();
|
||||
if (objectsDir.isEmpty()) {
|
||||
objectsDir = subProFile->buildDir(bc).toString();
|
||||
objectsDir = bc->qmakeBuildSystem()->buildDir(subProFile->filePath()).toString();
|
||||
if (subProFile->isDebugAndRelease()) {
|
||||
if (bc->buildType() == QmakeBuildConfiguration::Debug)
|
||||
objectsDir += "/debug";
|
||||
|
||||
@@ -505,12 +505,6 @@ QString QmakeProFileNode::singleVariableValue(const Variable var) const
|
||||
return values.isEmpty() ? QString() : values.first();
|
||||
}
|
||||
|
||||
FilePath QmakeProFileNode::buildDir(BuildConfiguration *bc) const
|
||||
{
|
||||
const QmakeProFile *pro = proFile();
|
||||
return pro ? pro->buildDir(bc) : FilePath();
|
||||
}
|
||||
|
||||
QString QmakeProFileNode::objectExtension() const
|
||||
{
|
||||
QStringList exts = variableValue(Variable::ObjectExt);
|
||||
|
||||
@@ -98,7 +98,6 @@ public:
|
||||
bool setData(Core::Id role, const QVariant &value) const override;
|
||||
|
||||
QmakeProjectManager::ProjectType projectType() const;
|
||||
Utils::FilePath buildDir(ProjectExplorer::BuildConfiguration *bc) const;
|
||||
|
||||
QStringList variableValue(const Variable var) const;
|
||||
QString singleVariableValue(const Variable var) const;
|
||||
|
||||
@@ -211,7 +211,7 @@ static void createTree(QmakeBuildSystem *buildSystem,
|
||||
if (!generatedFiles.empty()) {
|
||||
QTC_CHECK(proFile);
|
||||
const FilePath baseDir = generatedFiles.size() == 1 ? generatedFiles.first().parentDir()
|
||||
: proFile->buildDir();
|
||||
: buildSystem->buildDir(proFile->filePath());
|
||||
auto genFolder = std::make_unique<VirtualFolderNode>(baseDir);
|
||||
genFolder->setDisplayName(QCoreApplication::translate("QmakeProjectManager::QmakePriFile",
|
||||
"Generated Files"));
|
||||
|
||||
@@ -1336,7 +1336,7 @@ QmakeEvalInput QmakeProFile::evalInput() const
|
||||
QmakeEvalInput input;
|
||||
input.projectDir = directoryPath().toString();
|
||||
input.projectFilePath = filePath();
|
||||
input.buildDirectory = buildDir();
|
||||
input.buildDirectory = m_buildSystem->buildDir(m_filePath);
|
||||
input.sysroot = FilePath::fromString(m_buildSystem->qmakeSysroot());
|
||||
input.readerExact = m_readerExact;
|
||||
input.readerCumulative = m_readerCumulative;
|
||||
@@ -1726,7 +1726,7 @@ void QmakeProFile::applyEvaluate(QmakeEvalResult *evalResult)
|
||||
//
|
||||
// Add/Remove pri files, sub projects
|
||||
//
|
||||
FilePath buildDirectory = buildDir();
|
||||
FilePath buildDirectory = m_buildSystem->buildDir(m_filePath);
|
||||
makeEmpty();
|
||||
for (QmakePriFile * const toAdd : qAsConst(result->directChildren))
|
||||
addChild(toAdd);
|
||||
@@ -2069,20 +2069,6 @@ FilePath QmakeProFile::sourceDir() const
|
||||
return directoryPath();
|
||||
}
|
||||
|
||||
FilePath QmakeProFile::buildDir(BuildConfiguration *bc) const
|
||||
{
|
||||
if (!bc)
|
||||
bc = m_buildSystem->target()->activeBuildConfiguration();
|
||||
|
||||
const QDir srcDirRoot = QDir(m_buildSystem->projectDirectory().toString());
|
||||
const QString relativeDir = srcDirRoot.relativeFilePath(directoryPath().toString());
|
||||
const QString buildConfigBuildDir = bc ? bc->buildDirectory().toString() : QString();
|
||||
const QString buildDir = buildConfigBuildDir.isEmpty()
|
||||
? m_buildSystem->projectDirectory().toString()
|
||||
: buildConfigBuildDir;
|
||||
return FilePath::fromString(QDir::cleanPath(QDir(buildDir).absoluteFilePath(relativeDir)));
|
||||
}
|
||||
|
||||
FilePaths QmakeProFile::generatedFiles(const FilePath &buildDir,
|
||||
const FilePath &sourceFile,
|
||||
const FileType &sourceFileType) const
|
||||
|
||||
@@ -321,7 +321,6 @@ public:
|
||||
}
|
||||
|
||||
Utils::FilePath sourceDir() const;
|
||||
Utils::FilePath buildDir(ProjectExplorer::BuildConfiguration *bc = nullptr) const;
|
||||
|
||||
Utils::FilePaths generatedFiles(const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &sourceFile,
|
||||
|
||||
@@ -656,6 +656,17 @@ static FileNode *fileNodeOf(FolderNode *in, const FilePath &fileName)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FilePath QmakeBuildSystem::buildDir(const FilePath &proFilePath) const
|
||||
{
|
||||
const QDir srcDirRoot = QDir(projectDirectory().toString());
|
||||
const QString relativeDir = srcDirRoot.relativeFilePath(proFilePath.parentDir().toString());
|
||||
const QString buildConfigBuildDir = m_buildConfiguration->buildDirectory().toString();
|
||||
const QString buildDir = buildConfigBuildDir.isEmpty()
|
||||
? projectDirectory().toString()
|
||||
: buildConfigBuildDir;
|
||||
return FilePath::fromString(QDir::cleanPath(QDir(buildDir).absoluteFilePath(relativeDir)));
|
||||
}
|
||||
|
||||
void QmakeBuildSystem::proFileParseError(const QString &errorMessage)
|
||||
{
|
||||
Core::MessageManager::write(errorMessage);
|
||||
@@ -686,13 +697,13 @@ QtSupport::ProFileReader *QmakeBuildSystem::createProFileReader(const QmakeProFi
|
||||
qtVersion->applyProperties(m_qmakeGlobals.get());
|
||||
}
|
||||
m_qmakeGlobals->setDirectories(rootProFile()->sourceDir().toString(),
|
||||
rootProFile()->buildDir().toString());
|
||||
buildDir(rootProFile()->filePath()).toString());
|
||||
|
||||
Environment::const_iterator eit = env.constBegin(), eend = env.constEnd();
|
||||
for (; eit != eend; ++eit)
|
||||
m_qmakeGlobals->environment.insert(env.key(eit), env.expandedValueForKey(env.key(eit)));
|
||||
|
||||
m_qmakeGlobals->setCommandLineArguments(rootProFile()->buildDir().toString(), qmakeArgs);
|
||||
m_qmakeGlobals->setCommandLineArguments(buildDir(rootProFile()->filePath()).toString(), qmakeArgs);
|
||||
|
||||
QtSupport::ProFileCacheManager::instance()->incRefCount();
|
||||
|
||||
@@ -714,7 +725,7 @@ QtSupport::ProFileReader *QmakeBuildSystem::createProFileReader(const QmakeProFi
|
||||
|
||||
auto reader = new QtSupport::ProFileReader(m_qmakeGlobals.get(), m_qmakeVfs);
|
||||
|
||||
reader->setOutputDir(qmakeProFile->buildDir().toString());
|
||||
reader->setOutputDir(buildDir(qmakeProFile->filePath()).toString());
|
||||
|
||||
return reader;
|
||||
}
|
||||
@@ -1045,7 +1056,7 @@ void QmakeBuildSystem::updateBuildSystemData()
|
||||
if (!libDirectories.isEmpty()) {
|
||||
QmakeProFile *proFile = node->proFile();
|
||||
QTC_ASSERT(proFile, return);
|
||||
const QString proDirectory = proFile->buildDir().toString();
|
||||
const QString proDirectory = buildDir(proFile->filePath()).toString();
|
||||
foreach (QString dir, libDirectories) {
|
||||
// Fix up relative entries like "LIBS+=-L.."
|
||||
const QFileInfo fi(dir);
|
||||
@@ -1335,7 +1346,7 @@ QStringList QmakeBuildSystem::filesGeneratedFrom(const QString &input) const
|
||||
const QmakeProFileNode *pro = dynamic_cast<QmakeProFileNode *>(file->parentFolderNode());
|
||||
QTC_ASSERT(pro, return {});
|
||||
if (const QmakeProFile *proFile = pro->proFile())
|
||||
return Utils::transform(proFile->generatedFiles(pro->buildDir(nullptr),
|
||||
return Utils::transform(proFile->generatedFiles(buildDir(pro->filePath()),
|
||||
file->filePath(), file->fileType()),
|
||||
&FilePath::toString);
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ public:
|
||||
void scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay);
|
||||
void scheduleUpdateAllLater() { scheduleUpdateAll(QmakeProFile::ParseLater); }
|
||||
void scheduleUpdateAllNowOrLater();
|
||||
Utils::FilePath buildDir(const Utils::FilePath &proFilePath) const;
|
||||
|
||||
mutable QSet<const QPair<Utils::FilePath, Utils::FilePath>> m_toolChainWarnings;
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ bool QMakeStep::init()
|
||||
FilePath workingDirectory;
|
||||
|
||||
if (qmakeBc->subNodeBuild())
|
||||
workingDirectory = qmakeBc->subNodeBuild()->buildDir(qmakeBc);
|
||||
workingDirectory = qmakeBc->qmakeBuildSystem()->buildDir(qmakeBc->subNodeBuild()->filePath());
|
||||
else
|
||||
workingDirectory = qmakeBc->buildDirectory();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user