QmlProjectManager: fix importPaths on device

We have converted all import paths to absolute paths, which works on the host but causes issues on the target. To resolve this, we introduce targetImportPaths()

Task-number: QDS-12948
Change-Id: I02e32badeaf386e66a6d0806979692439d685450
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tim Jenßen
2024-09-19 18:21:13 +02:00
committed by Tim Jenssen
parent 61487090ed
commit dfc3ce723b
3 changed files with 17 additions and 4 deletions

View File

@@ -527,6 +527,7 @@ Utils::FilePath QmlBuildSystem::targetFile(const Utils::FilePath &sourceFile) co
const Utils::FilePath relative = sourceFile.relativePathFrom(sourceDir);
return targetDirectory().resolvePath(relative);
}
void QmlBuildSystem::setSupportedLanguages(QStringList languages)
{
m_projectItem->setSupportedLanguages(languages);
@@ -725,9 +726,20 @@ QStringList QmlBuildSystem::absoluteImportPaths() const
{
return Utils::transform<QStringList>(m_projectItem->importPaths(), [&](const QString &importPath) {
Utils::FilePath filePath = Utils::FilePath::fromString(importPath);
if (!filePath.isAbsolutePath())
return (projectDirectory() / importPath).toString();
return projectDirectory().resolvePath(importPath).toString();
if (filePath.isAbsolutePath())
return projectDirectory().resolvePath(importPath).path();
return (projectDirectory() / importPath).path();
});
}
QStringList QmlBuildSystem::targetImportPaths() const
{
return Utils::transform<QStringList>(allImports(), [&](const QString &importPath) {
const Utils::FilePath filePath = Utils::FilePath::fromString(importPath);
if (filePath.isAbsolutePath()) {
return importPath;
}
return (targetDirectory() / importPath).path();
});
}

View File

@@ -75,6 +75,7 @@ public:
QStringList importPaths() const;
QStringList absoluteImportPaths() const;
QStringList targetImportPaths() const;
QStringList fileSelectors() const;
bool multilanguageSupport() const;

View File

@@ -97,7 +97,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
// arguments from .qmlproject file
const QmlBuildSystem *bs = qobject_cast<QmlBuildSystem *>(target->buildSystem());
for (const QString &importPath : bs->absoluteImportPaths()) {
for (const QString &importPath : bs->targetImportPaths()) {
cmd.addArg("-I");
cmd.addArg(importPath);
}