1import qbs.Environment 2import qbs.File 3import qbs.TextFile 4 5Project { 6 property var projectDefines: ["blubb2"] 7 property string fileContentSuffix: "suffix 1" 8 property string testProperty: "default value" 9 CppApplication { 10 name: qbs.enableDebugCode ? "product 1.debug" : "product 1.release" 11 cpp.defines: ["blubb1"] 12 files: "source1.cpp" 13 } 14 CppApplication { 15 Depends { name: 'library' } 16 name: "product 2" 17 cpp.defines: project.projectDefines 18 files: "source2.cpp" 19 } 20 CppApplication { 21 name: "product 3" 22 cpp.defines: Environment.getEnv("QBS_BLACKBOX_DEFINE") 23 files: "source3.cpp" 24 } 25 DynamicLibrary { 26 Depends { name: "cpp" } 27 name: "library" 28 files: "lib.cpp" 29 Properties { 30 condition: qbs.targetOS.contains("darwin") 31 bundle.isBundle: false 32 } 33 } 34 35 Product { 36 name: "generated text file" 37 type: ["my_output"] 38 property string fileContentPrefix: "prefix 1" 39 40 Rule { 41 multiplex: true 42 Artifact { filePath: "nothing"; fileTags: ["my_output"] } 43 prepare: { 44 var cmd = new JavaScriptCommand(); 45 cmd.silent = true; 46 cmd.sourceCode = function() { console.info(product.fileContentPrefix); } 47 return cmd; 48 } 49 } 50 51 Rule { 52 multiplex: true 53 Artifact { filePath: "generated.txt"; fileTags: ["my_output"] } 54 prepare: { 55 var cmd = new JavaScriptCommand(); 56 cmd.description = "generating " + output.filePath; 57 cmd.highlight = "codegen"; 58 cmd.sourceCode = function() { 59 file = new TextFile(output.filePath, TextFile.WriteOnly); 60 file.truncate(); 61 file.write(product.fileContentPrefix + "contents 1" 62 + project.fileContentSuffix); 63 file.close(); 64 } 65 return cmd; 66 } 67 } 68 } 69 70 Product { 71 Depends { name: "ruletest" } 72 type: ["test-output2"] 73 Rule { 74 inputsFromDependencies: ['test-output'] 75 Artifact { 76 fileTags: "test-output2" 77 filePath: input.fileName + ".out2" 78 } 79 80 prepare: { 81 var cmd = new JavaScriptCommand(); 82 cmd.highlight = "codegen"; 83 cmd.description = "Making output from other output"; 84 cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); } 85 return cmd; 86 } 87 } 88 } 89 90 references: "ruletest.qbs" 91 92 qbsSearchPaths: "." 93} 94