diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index b9767fdedcb..fd95c807994 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -1570,7 +1570,6 @@ void ProjectExplorerPlugin::testSourceToBinaryMapping() return theProject.project()->binariesForSourceFile(projectDir.pathAppended(fileName)); }; QEXPECT_FAIL("cmake", "QTCREATORBUG-28815", Abort); - QEXPECT_FAIL("qmake", "QTCREATORBUG-28815", Abort); QCOMPARE(binariesForSource("multi-target-project-main.cpp").size(), 1); QCOMPARE(binariesForSource("multi-target-project-lib.cpp").size(), 1); QCOMPARE(binariesForSource("multi-target-project-shared.h").size(), 2); diff --git a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp index f261594e59e..752cb7c3192 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp @@ -202,7 +202,23 @@ static void createTree(QmakeBuildSystem *buildSystem, } } - if (!generatedFiles.empty()) { + FileType targetFileType = FileType::Unknown; + FilePath targetBinary; + if (proFile && proFile->targetInformation().valid) { + if (proFile->projectType() == ProjectType::ApplicationTemplate) { + targetFileType = FileType::App; + targetBinary = buildSystem->executableFor(proFile); + } else if (proFile->projectType() == ProjectType::SharedLibraryTemplate + || proFile->projectType() == ProjectType::StaticLibraryTemplate) { + targetFileType = FileType::Lib; + const FilePaths libs = Utils::sorted(buildSystem->allLibraryTargetFiles(proFile), + [](const FilePath &fp1, const FilePath &fp2) { + return fp1.fileName().length() < fp2.fileName().length(); }); + if (!libs.isEmpty()) + targetBinary = libs.last(); // Longest file name is the one that's not a symlink. + } + } + if (!generatedFiles.empty() || !targetBinary.isEmpty()) { QTC_CHECK(proFile); const FilePath baseDir = generatedFiles.size() == 1 ? generatedFiles.first().parentDir() : buildSystem->buildDir(proFile->filePath()); @@ -214,6 +230,11 @@ static void createTree(QmakeBuildSystem *buildSystem, fileNode->setIsGenerated(true); genFolder->addNestedNode(std::move(fileNode)); } + if (!targetBinary.isEmpty()) { + auto targetFileNode = std::make_unique(targetBinary, targetFileType); + targetFileNode->setIsGenerated(true); + genFolder->addNestedNode(std::move(targetFileNode)); + } node->addNode(std::move(genFolder)); } diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 3c78099b0f9..c12827b6b43 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -1311,15 +1311,13 @@ static FilePath destDirFor(const TargetInformation &ti) return ti.destDir; } -void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentData &deploymentData) +FilePaths QmakeBuildSystem::allLibraryTargetFiles(const QmakeProFile *file) const { - const QString targetPath = file->installsList().targetPath; - if (targetPath.isEmpty()) - return; const ToolChain *const toolchain = ToolChainKitAspect::cxxToolChain(kit()); if (!toolchain) - return; + return {}; + FilePaths libs; TargetInformation ti = file->targetInformation(); QString targetFileName = ti.target; const QStringList config = file->variableValue(Variable::Config); @@ -1339,7 +1337,7 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa } targetFileName += targetVersionExt + QLatin1Char('.'); targetFileName += QLatin1String(isStatic ? "lib" : "dll"); - deploymentData.addFile(destDirFor(ti) / targetFileName, targetPath); + libs << FilePath::fromString(targetFileName); break; } case Abi::DarwinOS: { @@ -1359,10 +1357,10 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa targetFileName += majorVersion; } targetFileName += QLatin1Char('.'); - targetFileName += file->singleVariableValue(isStatic - ? Variable::StaticLibExtension : Variable::ShLibExtension); + targetFileName += file->singleVariableValue(isStatic ? Variable::StaticLibExtension + : Variable::ShLibExtension); } - deploymentData.addFile(destDir / targetFileName, targetPath); + libs << destDir / targetFileName; break; } case Abi::LinuxOS: @@ -1374,10 +1372,10 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa targetFileName += QLatin1Char('.'); if (isStatic) { - targetFileName += QLatin1Char('a'); + libs << destDirFor(ti) / (targetFileName + QLatin1Char('a')); } else { targetFileName += QLatin1String("so"); - deploymentData.addFile(destDirFor(ti) / targetFileName, targetPath); + libs << destDirFor(ti) / targetFileName; if (nameIsVersioned) { QString version = file->singleVariableValue(Variable::Version); if (version.isEmpty()) @@ -1388,9 +1386,7 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa targetFileName += QLatin1Char('.'); while (!versionComponents.isEmpty()) { const QString versionString = versionComponents.join(QLatin1Char('.')); - deploymentData.addFile(destDirFor(ti).pathAppended(targetFileName - + versionString), - targetPath); + libs << destDirFor(ti).pathAppended(targetFileName + versionString); versionComponents.removeLast(); } } @@ -1399,6 +1395,18 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa default: break; } + + return libs; +} + +void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentData &deploymentData) +{ + const QString targetPath = file->installsList().targetPath; + if (!targetPath.isEmpty()) { + const FilePaths libs = allLibraryTargetFiles(file); + for (const FilePath &lib : libs) + deploymentData.addFile(lib, targetPath); + } } static FilePath getFullPathOf(const QmakeProFile *pro, Variable variable, diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.h b/src/plugins/qmakeprojectmanager/qmakeproject.h index 6615baaaca5..3097ae7b579 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.h +++ b/src/plugins/qmakeprojectmanager/qmakeproject.h @@ -106,6 +106,7 @@ public: void collectData(const QmakeProFile *file, ProjectExplorer::DeploymentData &deploymentData); void collectApplicationData(const QmakeProFile *file, ProjectExplorer::DeploymentData &deploymentData); + Utils::FilePaths allLibraryTargetFiles(const QmakeProFile *file) const; void collectLibraryData(const QmakeProFile *file, ProjectExplorer::DeploymentData &deploymentData); void startAsyncTimer(QmakeProFile::AsyncUpdateDelay delay);