forked from qt-creator/qt-creator
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:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -75,6 +75,7 @@ public:
|
||||
|
||||
QStringList importPaths() const;
|
||||
QStringList absoluteImportPaths() const;
|
||||
QStringList targetImportPaths() const;
|
||||
QStringList fileSelectors() const;
|
||||
|
||||
bool multilanguageSupport() const;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user