diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-08 13:18:38 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-08 14:53:10 +0000 |
commit | b08f15a36b2478c85e38f6f9e876cc058d54ba8b (patch) | |
tree | ba663f7bf1f7b310b34a1cfc5f10360e9d87aa33 /src/libs/glsl | |
parent | da1453a13d529e7d63e26f92e7f8cecfc5c2a077 (diff) |
GLSL: Auto run qlalr generator when explicitly requested
...because we support building Qt Creator with multiple Qt versions
(different qlalr versions), thus the generated source files might/will
differ.
Done-By: Christian Kandeler
Change-Id: Ib38d2a73704a030627b716f6f5b4a1e5c6a8ad14
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/libs/glsl')
-rw-r--r-- | src/libs/glsl/glsl.qbs | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/src/libs/glsl/glsl.qbs b/src/libs/glsl/glsl.qbs index b526001953..09ccb8bffe 100644 --- a/src/libs/glsl/glsl.qbs +++ b/src/libs/glsl/glsl.qbs @@ -1,12 +1,17 @@ import qbs 1.0 +import qbs.Environment +import qbs.File import qbs.FileInfo QtcLibrary { name: "GLSL" + property bool autoGenerateParser: Environment.getEnv("QTC_GLSL_AUTOGENERATE") + cpp.defines: base.concat([ "GLSL_LIBRARY" ]) + cpp.includePaths: base.concat([sourceDirectory]) Depends { name: "Qt.gui" } @@ -38,37 +43,63 @@ QtcLibrary { ] Group { + name: "generated parser files" + condition: !autoGenerateParser + files: [ + "glslparser.cpp", + "glslparser.h", + "glslparsertable.cpp", + "glslparsertable_p.h", + ] + } + + Group { fileTags: ["qlalrInput"] files: [ "glsl.g" ] } + // Necessary because qlalr generates its outputs in the working directory, + // and we want the input file to appear as a relative path in the generated files. Rule { inputs: ["qlalrInput"] - Artifact { - filePath: FileInfo.joinPaths(product.sourceDirectory, "glslparsertable_p.h") - fileTags: ["hpp"] - } - Artifact { - filePath: FileInfo.joinPaths(product.sourceDirectory, "glslparsertable.cpp") - fileTags: ["cpp"] - } - Artifact { - filePath: FileInfo.joinPaths(product.sourceDirectory, "glslparser.h") - fileTags: ["hpp"] - } - Artifact { - filePath: FileInfo.joinPaths(product.sourceDirectory, "glslparser.cpp") - fileTags: ["cpp"] + condition: product.autoGenerateParser + Artifact { filePath: input.fileName; fileTags: ["qlalrInput.real"] } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); } + cmd.silent = true; + return [cmd]; } + } + + Rule { + inputs: ["qlalrInput.real"] + condition: product.autoGenerateParser + Artifact { filePath: "glslparsertable_p.h"; fileTags: ["hpp"] } + Artifact { filePath: "glslparsertable.cpp"; fileTags: ["cpp"] } + Artifact { filePath: "glslparser.h"; fileTags: ["hpp"] } + Artifact { filePath: "glslparser.cpp"; fileTags: ["cpp"]} prepare: { - // Keep the input file path relative, so it's consistent with - // make-parser.sh and no absolute paths end up in e.g. glslparser.cpp. - var inputFile = "./" + inputs["qlalrInput"][0].fileName + var inputFile = "./" + input.fileName; var qlalr = FileInfo.joinPaths(product.Qt.core.binPath, "qlalr") var generateCmd = new Command(qlalr, ["--qt", "--no-debug", inputFile]); - generateCmd.workingDirectory = product.sourceDirectory; + generateCmd.workingDirectory = product.buildDirectory; generateCmd.description = "generating glsl parser"; - return generateCmd; + + var copyCmd = new JavaScriptCommand(); + copyCmd.sourceCode = function() { + var tags = ["hpp", "cpp"]; + for (var i = 0; i < tags.length; ++i) { + var artifacts = outputs[tags[i]]; + for (var j = 0; j < artifacts.length; ++j) { + var artifact = artifacts[j]; + File.copy(artifact.filePath, FileInfo.joinPaths(product.sourceDirectory, + artifact.fileName)); + } + } + }; + copyCmd.silent = true; + return [generateCmd, copyCmd]; } } } |