forked from qt-creator/qt-creator
QmlProjectManager: Disable Cmake Generation for Qt4MCU
Task-number: QDS-7442 Change-Id: Ifc2239d5be7489e0fd7c5a778e5653d4266c0393 Reviewed-by: Aleksei German <aleksei.german@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -59,6 +59,16 @@ enum ProjectDirectoryError {
|
|||||||
const QString MENU_ITEM_GENERATE = QCoreApplication::translate("QmlDesigner::GenerateCmake",
|
const QString MENU_ITEM_GENERATE = QCoreApplication::translate("QmlDesigner::GenerateCmake",
|
||||||
"Generate CMake Build Files...");
|
"Generate CMake Build Files...");
|
||||||
|
|
||||||
|
const QmlBuildSystem *getBuildSystem()
|
||||||
|
{
|
||||||
|
auto project = ProjectExplorer::SessionManager::startupProject();
|
||||||
|
if (project && project->activeTarget() && project->activeTarget()->buildSystem()) {
|
||||||
|
return qobject_cast<QmlProjectManager::QmlBuildSystem *>(
|
||||||
|
project->activeTarget()->buildSystem());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void generateMenuEntry(QObject *parent)
|
void generateMenuEntry(QObject *parent)
|
||||||
{
|
{
|
||||||
Core::ActionContainer *menu = Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
Core::ActionContainer *menu = Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
||||||
@@ -83,9 +93,8 @@ void generateMenuEntry(QObject *parent)
|
|||||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||||
&ProjectExplorer::SessionManager::startupProjectChanged,
|
&ProjectExplorer::SessionManager::startupProjectChanged,
|
||||||
[action]() {
|
[action]() {
|
||||||
auto qmlProject = qobject_cast<QmlProject *>(
|
if (auto buildSystem = getBuildSystem())
|
||||||
ProjectExplorer::SessionManager::startupProject());
|
action->setEnabled(!buildSystem->qtForMCUs());
|
||||||
action->setEnabled(qmlProject != nullptr);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,17 +260,15 @@ const QString projectEnvironmentVariable(const QString &key)
|
|||||||
{
|
{
|
||||||
QString value = {};
|
QString value = {};
|
||||||
|
|
||||||
auto *target = ProjectExplorer::SessionManager::startupProject()->activeTarget();
|
if (auto buildSystem = getBuildSystem()) {
|
||||||
if (target && target->buildSystem()) {
|
auto envItems = buildSystem->environment();
|
||||||
auto buildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(target->buildSystem());
|
auto confEnv = std::find_if(envItems.begin(), envItems.end(), [key](NameValueItem &item) {
|
||||||
if (buildSystem) {
|
return item.name == key;
|
||||||
auto envItems = buildSystem->environment();
|
});
|
||||||
auto confEnv = std::find_if(envItems.begin(), envItems.end(),
|
if (confEnv != envItems.end())
|
||||||
[key](NameValueItem &item){return item.name == key;});
|
value = confEnv->value;
|
||||||
if (confEnv != envItems.end())
|
|
||||||
value = confEnv->value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,7 +543,6 @@ bool CmakeFileGenerator::includeFile(const FilePath &filePath)
|
|||||||
return !isFileBlacklisted(filePath.fileName());
|
return !isFileBlacklisted(filePath.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CmakeFileGenerator::generateEntryPointFiles(const FilePath &dir)
|
bool CmakeFileGenerator::generateEntryPointFiles(const FilePath &dir)
|
||||||
{
|
{
|
||||||
const QString qtcontrolsConf = GenerateCmake::projectEnvironmentVariable(ENV_VARIABLE_CONTROLCONF);
|
const QString qtcontrolsConf = GenerateCmake::projectEnvironmentVariable(ENV_VARIABLE_CONTROLCONF);
|
||||||
@@ -575,22 +581,19 @@ bool CmakeFileGenerator::generateMainCpp(const FilePath &dir)
|
|||||||
|
|
||||||
bool envHeaderOk = true;
|
bool envHeaderOk = true;
|
||||||
QString environment;
|
QString environment;
|
||||||
auto *target = ProjectExplorer::SessionManager::startupProject()->activeTarget();
|
|
||||||
if (target && target->buildSystem()) {
|
if (auto buildSystem = getBuildSystem()) {
|
||||||
auto buildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(target->buildSystem());
|
for (EnvironmentItem &envItem : buildSystem->environment()) {
|
||||||
if (buildSystem) {
|
QString key = envItem.name;
|
||||||
for (EnvironmentItem &envItem : buildSystem->environment()) {
|
QString value = envItem.value;
|
||||||
QString key = envItem.name;
|
if (isFileResource(value))
|
||||||
QString value = envItem.value;
|
value.prepend(":/");
|
||||||
if (isFileResource(value))
|
environment.append(QString(ENV_HEADER_VARIABLE_LINE).arg(key).arg(value));
|
||||||
value.prepend(":/");
|
|
||||||
environment.append(QString(ENV_HEADER_VARIABLE_LINE).arg(key).arg(value));
|
|
||||||
}
|
|
||||||
QString envHeaderContent = GenerateCmake::readTemplate(ENV_HEADER_TEMPLATE_PATH)
|
|
||||||
.arg(environment);
|
|
||||||
FilePath envHeaderPath = srcDir.pathAppended(FILENAME_ENV_HEADER);
|
|
||||||
envHeaderOk = m_fileQueue.queueFile(envHeaderPath, envHeaderContent);
|
|
||||||
}
|
}
|
||||||
|
QString envHeaderContent = GenerateCmake::readTemplate(ENV_HEADER_TEMPLATE_PATH)
|
||||||
|
.arg(environment);
|
||||||
|
FilePath envHeaderPath = srcDir.pathAppended(FILENAME_ENV_HEADER);
|
||||||
|
envHeaderOk = m_fileQueue.queueFile(envHeaderPath, envHeaderContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cppOk && pluginHeaderOk && envHeaderOk;
|
return cppOk && pluginHeaderOk && envHeaderOk;
|
||||||
@@ -613,6 +616,8 @@ bool CmakeFileGenerator::isFileResource(const QString &relativeFilePath)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} //GenerateCmake
|
} //GenerateCmake
|
||||||
} //QmlProjectManager
|
} //QmlProjectManager
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user