QmlDesigner: Add configuration for qsb shader generator tool

Added default ShaderTool configuration block to new project template
and use information specified there to generate qsb shaders.

The args property specifies command line argument for qsb tool.
The files property specifies files for which qsb tool is run for.

E.g.:

ShaderTool {
    args: "-s --glsl \"100 es,120,150\" --hlsl 50 --msl 12"
    files: [ "content/shaders/*" ]
}

Fixes: QDS-6590
Change-Id: I3bab0db21d20f486f9f25c1437a27ddb7fb47396
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
This commit is contained in:
Miikka Heikkinen
2022-04-01 14:32:20 +03:00
parent 1fd9b13101
commit be284f24c0
7 changed files with 213 additions and 59 deletions

View File

@@ -161,6 +161,26 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi
projectItem->addToEnviroment(i.key(), i.value().value.toString());
++i;
}
} else if (childNode->name() == "ShaderTool") {
QmlJS::SimpleReaderNode::Property commandLine = childNode->property("args");
if (commandLine.isValid()) {
const QStringList quotedArgs = commandLine.value.toString().split('\"');
QStringList args;
for (int i = 0; i < quotedArgs.size(); ++i) {
// Each odd arg in this list is a single quoted argument, which we should
// not be split further
if (i % 2 == 0)
args.append(quotedArgs[i].trimmed().split(' '));
else
args.append(quotedArgs[i]);
}
args.removeAll({});
args.append("-o"); // Prepare for adding output file as next arg
projectItem->setShaderToolArgs(args);
}
QmlJS::SimpleReaderNode::Property files = childNode->property("files");
if (files.isValid())
projectItem->setShaderToolFiles(files.value.toStringList());
} else {
qWarning() << "Unknown type:" << childNode->name();
}

View File

@@ -84,6 +84,12 @@ public:
bool widgetApp() const { return m_widgetApp; }
void setWidgetApp(bool widgetApp) { m_widgetApp = widgetApp; }
QStringList shaderToolArgs() const { return m_shaderToolArgs; }
void setShaderToolArgs(const QStringList &args) {m_shaderToolArgs = args; }
QStringList shaderToolFiles() const { return m_shaderToolFiles; }
void setShaderToolFiles(const QStringList &files) {m_shaderToolFiles = files; }
void appendContent(QmlProjectContentItem *item) { m_content.append(item); }
Utils::EnvironmentItems environment() const;
@@ -107,6 +113,8 @@ protected:
bool m_qtForMCUs = false;
bool m_qt6Project = false;
bool m_widgetApp = false;
QStringList m_shaderToolArgs;
QStringList m_shaderToolFiles;
};
} // namespace QmlProjectManager

View File

@@ -625,6 +625,20 @@ bool QmlBuildSystem::widgetApp() const
return false;
}
QStringList QmlBuildSystem::shaderToolArgs() const
{
if (m_projectItem)
return m_projectItem->shaderToolArgs();
return {};
}
QStringList QmlBuildSystem::shaderToolFiles() const
{
if (m_projectItem)
return m_projectItem->shaderToolFiles();
return {};
}
bool QmlBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FilePaths *)
{
if (!dynamic_cast<QmlProjectNode *>(context))

View File

@@ -95,6 +95,8 @@ public:
void setPrimaryLanguage(QString language);
bool forceFreeType() const;
bool widgetApp() const;
QStringList shaderToolArgs() const;
QStringList shaderToolFiles() const;
bool addFiles(const QStringList &filePaths);