Add forward_variables_from() code example to help text Change-Id: Id90ced4ceaa5dc62369a97f9792aa61305049c90 Reviewed-on: https://gn-review.googlesource.com/2780 Reviewed-by: Brett Wilson <brettw@chromium.org> Commit-Queue: Brett Wilson <brettw@chromium.org>
diff --git a/docs/reference.md b/docs/reference.md index d73a94f..c7215df 100644 --- a/docs/reference.md +++ b/docs/reference.md
@@ -1901,6 +1901,13 @@ #### **Examples** ``` + # forward_variables_from(invoker, ["foo"]) + # is equivalent to: + assert(!defined(foo)) + if (defined(invoker.foo)) { + foo = invoker.foo + } + # This is a common action template. It would invoke a script with some given # parameters, and wants to use the various types of deps and the visibility # from the invoker if it's defined. It also injects an additional dependency
diff --git a/tools/gn/function_forward_variables_from.cc b/tools/gn/function_forward_variables_from.cc index de08072..875af91 100644 --- a/tools/gn/function_forward_variables_from.cc +++ b/tools/gn/function_forward_variables_from.cc
@@ -117,6 +117,13 @@ Examples + # forward_variables_from(invoker, ["foo"]) + # is equivalent to: + assert(!defined(foo)) + if (defined(invoker.foo)) { + foo = invoker.foo + } + # This is a common action template. It would invoke a script with some given # parameters, and wants to use the various types of deps and the visibility # from the invoker if it's defined. It also injects an additional dependency