aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorIvan Komissarov <ABBAPOH@gmail.com>2019-07-06 17:13:39 +0200
committerIvan Komissarov <ABBAPOH@gmail.com>2019-07-10 11:43:51 +0000
commit6785335b3be5be4c388fa8d967d880e19b70244c (patch)
treece1135a9ef9174bbfe30e2647943ae463875e112 /examples
parentbcf2849298fa170e0286332414e08637faa60f6a (diff)
Add a complete example for a Rule in a Product
Change-Id: I4739440cb90f7ef5795f79da053246f8071aa57e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.qbs3
-rw-r--r--examples/rule/lorem_ipsum.txt4
-rw-r--r--examples/rule/rule.qbs36
3 files changed, 42 insertions, 1 deletions
diff --git a/examples/examples.qbs b/examples/examples.qbs
index abb6d5d9a..ff6e7a191 100644
--- a/examples/examples.qbs
+++ b/examples/examples.qbs
@@ -65,6 +65,7 @@ Project {
"install-bundle/install-bundle.qbs",
"protobuf/cpp/addressbook.qbs",
"protobuf/objc/addressbook.qbs",
- "baremetal/baremetal.qbs"
+ "baremetal/baremetal.qbs",
+ "rule/rule.qbs",
]
}
diff --git a/examples/rule/lorem_ipsum.txt b/examples/rule/lorem_ipsum.txt
new file mode 100644
index 000000000..2901fbcee
--- /dev/null
+++ b/examples/rule/lorem_ipsum.txt
@@ -0,0 +1,4 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer accumsan laoreet magna vitae
+elementum. Duis semper ex pellentesque nibh ullamcorper lacinia. Suspendisse sed diam magna.
+Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In id
+maximus turpis, mattis commodo mauris. Sed bibendum accumsan leo. Nulla placerat.
diff --git a/examples/rule/rule.qbs b/examples/rule/rule.qbs
new file mode 100644
index 000000000..8ec14ee40
--- /dev/null
+++ b/examples/rule/rule.qbs
@@ -0,0 +1,36 @@
+import qbs.TextFile
+
+Product {
+ type: "txt_output"
+
+ Group {
+ name: "lorem_ipsum"
+ files: "lorem_ipsum.txt"
+ fileTags: "txt_input"
+ }
+
+ //![1]
+ Rule {
+ multiplex: false
+ inputs: ["txt_input"]
+ Artifact {
+ filePath: input.fileName + ".out"
+ fileTags: ["txt_output"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = input.fileName + "->" + output.fileName;
+ cmd.highlight = "codegen";
+ cmd.sourceCode = function() {
+ var file = new TextFile(input.filePath);
+ var content = file.readAll();
+ file.close()
+ content = content.toUpperCase();
+ file = new TextFile(output.filePath, TextFile.WriteOnly);
+ file.write(content);
+ file.close();
+ }
+ return [cmd];
+ }
+ }
+}