From 6785335b3be5be4c388fa8d967d880e19b70244c Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sat, 6 Jul 2019 17:13:39 +0200 Subject: Add a complete example for a Rule in a Product Change-Id: I4739440cb90f7ef5795f79da053246f8071aa57e Reviewed-by: Christian Kandeler --- examples/examples.qbs | 3 ++- examples/rule/lorem_ipsum.txt | 4 ++++ examples/rule/rule.qbs | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 examples/rule/lorem_ipsum.txt create mode 100644 examples/rule/rule.qbs (limited to 'examples') 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]; + } + } +} -- cgit v1.2.3