Created
March 31, 2016 05:29
-
-
Save orgads/00cc12650211eed9c2fdf86ddddcd16a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import qbs | |
| import qbs.File | |
| import qbs.FileInfo | |
| import qbs.TextFile | |
| Product { | |
| name: "UnitTests" | |
| type: "hpp" | |
| readonly property string targetFile: FileInfo.joinPaths(buildDirectory, ".current-unit-test-flag") | |
| property string content: { | |
| var res = "// GTEST"; | |
| if (project.gtest) | |
| res += "1"; | |
| res += "\n"; | |
| return res; | |
| } | |
| Rule { | |
| id: unitTestEnabled | |
| inputs: ["qbs"] | |
| Artifact { | |
| filePath: product.targetFile | |
| fileTags: ["hpp"] | |
| } | |
| condition: { | |
| if (File.exists(product.targetFile)) { | |
| var file = new TextFile(product.targetFile); | |
| return file.readAll() != product.content; | |
| } | |
| return true; | |
| } | |
| prepare: { | |
| var cmd = new JavaScriptCommand(); | |
| cmd.description = 'generating ' + product.targetFile; | |
| cmd.highlight = 'codegen'; | |
| cmd.content = product.content | |
| cmd.sourceCode = function() { | |
| var outfile = new TextFile(product.targetFile, TextFile.WriteOnly); | |
| outfile.truncate(); | |
| outfile.write(content); | |
| outfile.close(); | |
| } | |
| return cmd; | |
| } | |
| } | |
| Export { | |
| Depends { name: "cpp" } | |
| cpp.includePaths: product.buildDirectory | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment