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: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Tim Jenßen
2024-09-19 18:21:13 +02:00
committed by Tim Jenssen
parent a65ac94f67
commit 4ca84d844c
3 changed files with 18 additions and 5 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);
@@ -733,11 +734,22 @@ QStringList QmlBuildSystem::mockImports() const
QStringList QmlBuildSystem::absoluteImportPaths() const
{
return Utils::transform<QStringList>(allImports(), [&](const QString &importPath) {
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

@@ -77,6 +77,7 @@ public:
QStringList importPaths() const;
QStringList mockImports() 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);
}