forked from qt-creator/qt-creator
QmakeProjectManager: Add lib and app binaries to project tree
Task-number: QTCREATORBUG-28815 Change-Id: I4a3bbab54ce4f5cf6553d61f50b047f63b88cfa3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -1570,7 +1570,6 @@ void ProjectExplorerPlugin::testSourceToBinaryMapping()
|
|||||||
return theProject.project()->binariesForSourceFile(projectDir.pathAppended(fileName));
|
return theProject.project()->binariesForSourceFile(projectDir.pathAppended(fileName));
|
||||||
};
|
};
|
||||||
QEXPECT_FAIL("cmake", "QTCREATORBUG-28815", Abort);
|
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-main.cpp").size(), 1);
|
||||||
QCOMPARE(binariesForSource("multi-target-project-lib.cpp").size(), 1);
|
QCOMPARE(binariesForSource("multi-target-project-lib.cpp").size(), 1);
|
||||||
QCOMPARE(binariesForSource("multi-target-project-shared.h").size(), 2);
|
QCOMPARE(binariesForSource("multi-target-project-shared.h").size(), 2);
|
||||||
|
|||||||
@@ -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);
|
QTC_CHECK(proFile);
|
||||||
const FilePath baseDir = generatedFiles.size() == 1 ? generatedFiles.first().parentDir()
|
const FilePath baseDir = generatedFiles.size() == 1 ? generatedFiles.first().parentDir()
|
||||||
: buildSystem->buildDir(proFile->filePath());
|
: buildSystem->buildDir(proFile->filePath());
|
||||||
@@ -214,6 +230,11 @@ static void createTree(QmakeBuildSystem *buildSystem,
|
|||||||
fileNode->setIsGenerated(true);
|
fileNode->setIsGenerated(true);
|
||||||
genFolder->addNestedNode(std::move(fileNode));
|
genFolder->addNestedNode(std::move(fileNode));
|
||||||
}
|
}
|
||||||
|
if (!targetBinary.isEmpty()) {
|
||||||
|
auto targetFileNode = std::make_unique<FileNode>(targetBinary, targetFileType);
|
||||||
|
targetFileNode->setIsGenerated(true);
|
||||||
|
genFolder->addNestedNode(std::move(targetFileNode));
|
||||||
|
}
|
||||||
node->addNode(std::move(genFolder));
|
node->addNode(std::move(genFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1311,15 +1311,13 @@ static FilePath destDirFor(const TargetInformation &ti)
|
|||||||
return ti.destDir;
|
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());
|
const ToolChain *const toolchain = ToolChainKitAspect::cxxToolChain(kit());
|
||||||
if (!toolchain)
|
if (!toolchain)
|
||||||
return;
|
return {};
|
||||||
|
|
||||||
|
FilePaths libs;
|
||||||
TargetInformation ti = file->targetInformation();
|
TargetInformation ti = file->targetInformation();
|
||||||
QString targetFileName = ti.target;
|
QString targetFileName = ti.target;
|
||||||
const QStringList config = file->variableValue(Variable::Config);
|
const QStringList config = file->variableValue(Variable::Config);
|
||||||
@@ -1339,7 +1337,7 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa
|
|||||||
}
|
}
|
||||||
targetFileName += targetVersionExt + QLatin1Char('.');
|
targetFileName += targetVersionExt + QLatin1Char('.');
|
||||||
targetFileName += QLatin1String(isStatic ? "lib" : "dll");
|
targetFileName += QLatin1String(isStatic ? "lib" : "dll");
|
||||||
deploymentData.addFile(destDirFor(ti) / targetFileName, targetPath);
|
libs << FilePath::fromString(targetFileName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Abi::DarwinOS: {
|
case Abi::DarwinOS: {
|
||||||
@@ -1359,10 +1357,10 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa
|
|||||||
targetFileName += majorVersion;
|
targetFileName += majorVersion;
|
||||||
}
|
}
|
||||||
targetFileName += QLatin1Char('.');
|
targetFileName += QLatin1Char('.');
|
||||||
targetFileName += file->singleVariableValue(isStatic
|
targetFileName += file->singleVariableValue(isStatic ? Variable::StaticLibExtension
|
||||||
? Variable::StaticLibExtension : Variable::ShLibExtension);
|
: Variable::ShLibExtension);
|
||||||
}
|
}
|
||||||
deploymentData.addFile(destDir / targetFileName, targetPath);
|
libs << destDir / targetFileName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Abi::LinuxOS:
|
case Abi::LinuxOS:
|
||||||
@@ -1374,10 +1372,10 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa
|
|||||||
|
|
||||||
targetFileName += QLatin1Char('.');
|
targetFileName += QLatin1Char('.');
|
||||||
if (isStatic) {
|
if (isStatic) {
|
||||||
targetFileName += QLatin1Char('a');
|
libs << destDirFor(ti) / (targetFileName + QLatin1Char('a'));
|
||||||
} else {
|
} else {
|
||||||
targetFileName += QLatin1String("so");
|
targetFileName += QLatin1String("so");
|
||||||
deploymentData.addFile(destDirFor(ti) / targetFileName, targetPath);
|
libs << destDirFor(ti) / targetFileName;
|
||||||
if (nameIsVersioned) {
|
if (nameIsVersioned) {
|
||||||
QString version = file->singleVariableValue(Variable::Version);
|
QString version = file->singleVariableValue(Variable::Version);
|
||||||
if (version.isEmpty())
|
if (version.isEmpty())
|
||||||
@@ -1388,9 +1386,7 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa
|
|||||||
targetFileName += QLatin1Char('.');
|
targetFileName += QLatin1Char('.');
|
||||||
while (!versionComponents.isEmpty()) {
|
while (!versionComponents.isEmpty()) {
|
||||||
const QString versionString = versionComponents.join(QLatin1Char('.'));
|
const QString versionString = versionComponents.join(QLatin1Char('.'));
|
||||||
deploymentData.addFile(destDirFor(ti).pathAppended(targetFileName
|
libs << destDirFor(ti).pathAppended(targetFileName + versionString);
|
||||||
+ versionString),
|
|
||||||
targetPath);
|
|
||||||
versionComponents.removeLast();
|
versionComponents.removeLast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1399,6 +1395,18 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa
|
|||||||
default:
|
default:
|
||||||
break;
|
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,
|
static FilePath getFullPathOf(const QmakeProFile *pro, Variable variable,
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ public:
|
|||||||
void collectData(const QmakeProFile *file, ProjectExplorer::DeploymentData &deploymentData);
|
void collectData(const QmakeProFile *file, ProjectExplorer::DeploymentData &deploymentData);
|
||||||
void collectApplicationData(const QmakeProFile *file,
|
void collectApplicationData(const QmakeProFile *file,
|
||||||
ProjectExplorer::DeploymentData &deploymentData);
|
ProjectExplorer::DeploymentData &deploymentData);
|
||||||
|
Utils::FilePaths allLibraryTargetFiles(const QmakeProFile *file) const;
|
||||||
void collectLibraryData(const QmakeProFile *file,
|
void collectLibraryData(const QmakeProFile *file,
|
||||||
ProjectExplorer::DeploymentData &deploymentData);
|
ProjectExplorer::DeploymentData &deploymentData);
|
||||||
void startAsyncTimer(QmakeProFile::AsyncUpdateDelay delay);
|
void startAsyncTimer(QmakeProFile::AsyncUpdateDelay delay);
|
||||||
|
|||||||
Reference in New Issue
Block a user