forked from qt-creator/qt-creator
Fix CMake file generation to include module subdirectories properly
Task-number: QDS-5273 Change-Id: Id32ef746851a51a54941359548d0e35608f282a5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -149,9 +149,7 @@ const char MODULEFILE_CREATE_MODULE[] = "qt6_add_qml_module(%1\n\tURI \"%1\"\n\t
|
|||||||
QString generateModuleCmake(const FilePath &dir)
|
QString generateModuleCmake(const FilePath &dir)
|
||||||
{
|
{
|
||||||
QString fileContent;
|
QString fileContent;
|
||||||
const QStringList qmlFilesOnly("*.qml");
|
|
||||||
const QStringList qmldirFilesOnly(QMLDIRFILENAME);
|
const QStringList qmldirFilesOnly(QMLDIRFILENAME);
|
||||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
|
||||||
|
|
||||||
FilePaths qmldirFileList = dir.dirEntries(qmldirFilesOnly, FILES_ONLY);
|
FilePaths qmldirFileList = dir.dirEntries(qmldirFilesOnly, FILES_ONLY);
|
||||||
if (!qmldirFileList.isEmpty()) {
|
if (!qmldirFileList.isEmpty()) {
|
||||||
@@ -161,18 +159,15 @@ QString generateModuleCmake(const FilePath &dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePaths qmlFileList = dir.dirEntries(qmlFilesOnly, FILES_ONLY);
|
QStringList qmlFileList = getDirectoryTreeQmls(dir);
|
||||||
QString qmlFiles;
|
QString qmlFiles;
|
||||||
for (FilePath &qmlFile : qmlFileList) {
|
for (QString &qmlFile : qmlFileList)
|
||||||
if (project->isKnownFile(qmlFile))
|
qmlFiles.append(QString("\t\t%1\n").arg(qmlFile));
|
||||||
qmlFiles.append(QString("\t\t%1\n").arg(qmlFile.fileName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList resourceFileList = getDirectoryTreeResources(dir);
|
QStringList resourceFileList = getDirectoryTreeResources(dir);
|
||||||
QString resourceFiles;
|
QString resourceFiles;
|
||||||
for (QString &resourceFile : resourceFileList) {
|
for (QString &resourceFile : resourceFileList)
|
||||||
resourceFiles.append(QString("\t\t%1\n").arg(resourceFile));
|
resourceFiles.append(QString("\t\t%1\n").arg(resourceFile));
|
||||||
}
|
|
||||||
|
|
||||||
QString moduleContent;
|
QString moduleContent;
|
||||||
if (!qmlFiles.isEmpty()) {
|
if (!qmlFiles.isEmpty()) {
|
||||||
@@ -226,6 +221,31 @@ QStringList getSingletonsFromQmldirFile(const FilePath &filePath)
|
|||||||
return singletons;
|
return singletons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList getDirectoryTreeQmls(const FilePath &dir)
|
||||||
|
{
|
||||||
|
const QStringList qmlFilesOnly("*.qml");
|
||||||
|
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
||||||
|
QStringList qmlFileList;
|
||||||
|
|
||||||
|
FilePaths thisDirFiles = dir.dirEntries(qmlFilesOnly, FILES_ONLY);
|
||||||
|
for (FilePath &file : thisDirFiles) {
|
||||||
|
if (!isFileBlacklisted(file.fileName()) &&
|
||||||
|
project->isKnownFile(file)) {
|
||||||
|
qmlFileList.append(file.fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePaths subDirsList = dir.dirEntries(DIRS_ONLY);
|
||||||
|
for (FilePath &subDir : subDirsList) {
|
||||||
|
QStringList subDirQmlFiles = getDirectoryTreeQmls(subDir);
|
||||||
|
for (QString &qmlFile : subDirQmlFiles) {
|
||||||
|
qmlFileList.append(subDir.fileName().append('/').append(qmlFile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return qmlFileList;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList getDirectoryTreeResources(const FilePath &dir)
|
QStringList getDirectoryTreeResources(const FilePath &dir)
|
||||||
{
|
{
|
||||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ void generateSubdirCmake(const Utils::FilePath &dir);
|
|||||||
QString generateModuleCmake(const Utils::FilePath &dir);
|
QString generateModuleCmake(const Utils::FilePath &dir);
|
||||||
QStringList processDirectory(const Utils::FilePath &dir);
|
QStringList processDirectory(const Utils::FilePath &dir);
|
||||||
QStringList getSingletonsFromQmldirFile(const Utils::FilePath &filePath);
|
QStringList getSingletonsFromQmldirFile(const Utils::FilePath &filePath);
|
||||||
|
QStringList getDirectoryTreeQmls(const Utils::FilePath &dir);
|
||||||
QStringList getDirectoryTreeResources(const Utils::FilePath &dir);
|
QStringList getDirectoryTreeResources(const Utils::FilePath &dir);
|
||||||
void createCmakeFile(const Utils::FilePath &filePath, const QString &content);
|
void createCmakeFile(const Utils::FilePath &filePath, const QString &content);
|
||||||
bool isFileBlacklisted(const QString &fileName);
|
bool isFileBlacklisted(const QString &fileName);
|
||||||
|
|||||||
Reference in New Issue
Block a user