aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/markdown/Reference-manual.md5
-rw-r--r--docs/markdown/snippets/custom-target-index.md21
2 files changed, 26 insertions, 0 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 7aa4bca..c3636b8 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -1567,6 +1567,11 @@ contains a target with the following methods:
this and will also allow Meson to setup inter-target dependencies
correctly. Please file a bug if that doesn't work for you.
+- `[index]` returns an opaque object that references this target, and can be
+ used as a source in other targets. When it is used as such it will make that
+ target depend on this custom target, but the only source added will be the
+ one that corresponds to the index of the custom target's output argument.
+
### `dependency` object
This object is returned by [`dependency()`](#dependency) and contains
diff --git a/docs/markdown/snippets/custom-target-index.md b/docs/markdown/snippets/custom-target-index.md
new file mode 100644
index 0000000..10d7cf1
--- /dev/null
+++ b/docs/markdown/snippets/custom-target-index.md
@@ -0,0 +1,21 @@
+# Can index CustomTaget objects
+
+The `CustomTarget` object can now be indexed like an array. The resulting
+object can be used as a source file for other Targets, this will create a
+dependency on the original `CustomTarget`, but will only insert the generated
+file corresponding to the index value of the `CustomTarget`'s `output` keyword.
+
+ c = CustomTarget(
+ ...
+ output : ['out.h', 'out.c'],
+ )
+ lib1 = static_library(
+ 'lib1',
+ [lib1_sources, c[0]],
+ ...
+ )
+ exec = executable(
+ 'executable',
+ c[1],
+ link_with : lib1,
+ )