aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/snippets
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-12-02 22:17:21 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-12-05 01:09:15 +0200
commitd3dcef7efc1df3b7a645eb6dc75c4a66a9131cb9 (patch)
treebbfdc29b9d8050b078ca8df01630a10d9260ad3e /docs/markdown/snippets
parent678daad6cc11e850f5d7aa7f1744725d3acaf621 (diff)
downloadmeson-d3dcef7efc1df3b7a645eb6dc75c4a66a9131cb9.zip
meson-d3dcef7efc1df3b7a645eb6dc75c4a66a9131cb9.tar.gz
meson-d3dcef7efc1df3b7a645eb6dc75c4a66a9131cb9.tar.bz2
Added documentation for disabler objects.
Diffstat (limited to 'docs/markdown/snippets')
-rw-r--r--docs/markdown/snippets/disabler.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/markdown/snippets/disabler.md b/docs/markdown/snippets/disabler.md
new file mode 100644
index 0000000..1323048
--- /dev/null
+++ b/docs/markdown/snippets/disabler.md
@@ -0,0 +1,33 @@
+# Added disabler object
+
+A disabler object is a new kind of object that has very specific
+semantics. If it is used as part of any other operation such as an
+argument to a function call, logical operations etc, it will cause the
+operation to not be evaluated. Instead the return value of said
+operation will also be the disabler object.
+
+For example if you have an setup like this:
+
+```meson
+dep = dependency('foo')
+lib = shared_library('mylib', 'mylib.c',
+ dependencies : dep)
+exe = executable('mytest', 'mytest.c',
+ link_with : lib)
+test('mytest', exe)
+```
+
+If you replace the dependency with a disabler object like this:
+
+```meson
+dep = disabler()
+lib = shared_library('mylib', 'mylib.c',
+ dependencies : dep)
+exe = executable('mytest', 'mytest.c',
+ link_with : lib)
+test('mytest', exe)
+```
+
+Then the shared library, executable and unit test are not
+created. This is a handy mechanism to cut down on the number of `if`
+statements.