diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-07-25 16:31:05 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2016-07-28 06:56:51 +0000 |
commit | 8927f9cc52f021d6bac362cab8900c98437143be (patch) | |
tree | 404bfe3433c54863ad87a14906ef3dd1df9dafe7 /tests/auto/blackbox/testdata/nested-groups | |
parent | 236bc3d6c34519f48f9127a58e5071ddf750faf9 (diff) |
Allow nested group items
This serves two use cases.
Use case 1: Groups with overlapping conditions can be structured more
naturally, possibly getting rid of redundant property assignments.
Consider this:
Group {
condition: qbs.targetOS.contains("unix")
cpp.dynamicLibraries: ["pthread"]
files: ["unix_all.cpp"]
}
Group {
condition: qbs.targetOS.contains("linux")
cpp.dynamicLibraries: ["pthread", "dl"]
files: ["linux.cpp"]
}
Group {
condition: qbs.targetOS.contains("unix")
&& !qbs.targetOS.contains("linux")
cpp.dynamicLibraries: ["pthread"]
files: ["unix_nonlinux.cpp"]
}
Whereas now we can write:
Group {
condition: qbs.targetOS.contains("unix")
cpp.dynamicLibraries: ["pthread"]
files: ["unix_all.cpp"]
Group {
condition: qbs.targetOS.contains("linux")
cpp.dynamicLibraries: outer.concat(["dl"])
files: ["linux.cpp"]
}
Group {
condition: !qbs.targetOS.contains("linux")
files: ["unix_nonlinux.cpp"]
}
}
Use case 2: Putting source files into a dedicated project file which can
be instantiated from different products (similar to pri files in qmake)
becomes much more useful when these files can actually contain more than
one group. In this context, the top-level Group item will often act
purely as a structural element, satisfying the QML syntax' requirement
of a single root item.
[ChangeLog] Made the Group item nestable.
Change-Id: Ie1d7bed7bca33f6f023b625e8726d2e8db08e45d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'tests/auto/blackbox/testdata/nested-groups')
12 files changed, 91 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/nested-groups/file1.cpp b/tests/auto/blackbox/testdata/nested-groups/file1.cpp new file mode 100644 index 000000000..67363fe7e --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/file1.cpp @@ -0,0 +1,9 @@ +#ifndef REQUIRED_FOR_FILE1 +#error "missing define" +#endif + +#ifndef ALSO_REQUIRED_FOR_FILE1 +#error "missing define" +#endif + +void file1() {} diff --git a/tests/auto/blackbox/testdata/nested-groups/file1.h b/tests/auto/blackbox/testdata/nested-groups/file1.h new file mode 100644 index 000000000..ff9f36a50 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/file1.h @@ -0,0 +1 @@ +void file1(); diff --git a/tests/auto/blackbox/testdata/nested-groups/file2.cpp b/tests/auto/blackbox/testdata/nested-groups/file2.cpp new file mode 100644 index 000000000..7f4c0f0a7 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/file2.cpp @@ -0,0 +1,9 @@ +#ifdef BREAKS_FILE2 +#error "unexpected define" +#endif + +#ifndef REQUIRED_FOR_FILE2 +#error "missing define" +#endif + +void file2() {} diff --git a/tests/auto/blackbox/testdata/nested-groups/file2.h b/tests/auto/blackbox/testdata/nested-groups/file2.h new file mode 100644 index 000000000..94c191c43 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/file2.h @@ -0,0 +1 @@ +void file2(); diff --git a/tests/auto/blackbox/testdata/nested-groups/file3.cpp b/tests/auto/blackbox/testdata/nested-groups/file3.cpp new file mode 100644 index 000000000..43ebb246b --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/file3.cpp @@ -0,0 +1,5 @@ +#ifndef REQUIRED_FOR_FILE3 +#error "missing define" +#endif + +void file3() {} diff --git a/tests/auto/blackbox/testdata/nested-groups/file3.h b/tests/auto/blackbox/testdata/nested-groups/file3.h new file mode 100644 index 000000000..c860a8d6b --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/file3.h @@ -0,0 +1 @@ +void file3(); diff --git a/tests/auto/blackbox/testdata/nested-groups/main.cpp b/tests/auto/blackbox/testdata/nested-groups/main.cpp new file mode 100644 index 000000000..27a52a560 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/main.cpp @@ -0,0 +1,12 @@ +#include "file1.h" +#include "file2.h" +#include "file3.h" +#include "other.h" + +int main() +{ + file1(); + file2(); + file3(); + other(); +} diff --git a/tests/auto/blackbox/testdata/nested-groups/main2.cpp b/tests/auto/blackbox/testdata/nested-groups/main2.cpp new file mode 100644 index 000000000..8b8d58de0 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/main2.cpp @@ -0,0 +1 @@ +int main() { } diff --git a/tests/auto/blackbox/testdata/nested-groups/modules/themodule/themodule.qbs b/tests/auto/blackbox/testdata/nested-groups/modules/themodule/themodule.qbs new file mode 100644 index 000000000..de15aa7c8 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/modules/themodule/themodule.qbs @@ -0,0 +1,10 @@ +import qbs + +Module { + Group { + cpp.defines: ["REQUIRED_FOR_FILE3"] + Group { + files: ["file3.cpp", "file3.h"] + } + } +} diff --git a/tests/auto/blackbox/testdata/nested-groups/nested-groups.qbs b/tests/auto/blackbox/testdata/nested-groups/nested-groups.qbs new file mode 100644 index 000000000..9a76fd76e --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/nested-groups.qbs @@ -0,0 +1,32 @@ +import qbs + +CppApplication { + Depends { name: "themodule" } + files: ["main.cpp"] + Group { + cpp.defines: ["REQUIRED_FOR_FILE1", "BREAKS_FILE2"] + + // This group has no files, and that's okay. + + Group { + files: ["other.cpp", "other.h"] + Group { + cpp.defines: outer.concat(["ALSO_REQUIRED_FOR_FILE1"]) + files: ["file1.cpp", "file1.h"] + } + Group { + cpp.defines: ["REQUIRED_FOR_FILE2"] + files: ["file2.cpp", "file2.h"] + } + Group { + name: "disabled" + condition: false + Group { + name: "indirectly disabled" + condition: true + files: ["main2.cpp"] + } + } + } + } +} diff --git a/tests/auto/blackbox/testdata/nested-groups/other.cpp b/tests/auto/blackbox/testdata/nested-groups/other.cpp new file mode 100644 index 000000000..debb4a4c6 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/other.cpp @@ -0,0 +1,9 @@ +#ifndef REQUIRED_FOR_FILE1 +#error "missing define" +#endif + +#ifndef BREAKS_FILE2 +#error "missing define" +#endif + +void other() { } diff --git a/tests/auto/blackbox/testdata/nested-groups/other.h b/tests/auto/blackbox/testdata/nested-groups/other.h new file mode 100644 index 000000000..00835b8b5 --- /dev/null +++ b/tests/auto/blackbox/testdata/nested-groups/other.h @@ -0,0 +1 @@ +void other(); |