[GN] Forward visibility from invoker

Change-Id: Ib93524b4c613228fefe89a2dad18ebd795a3f4ef
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/protobuf/+/446394
Fuchsia-Auto-Submit: Zach Bush <zmbush@google.com>
Reviewed-by: Gary Miguel <garymm@google.com>
diff --git a/proto_library.gni b/proto_library.gni
index b74e5fe..55d2c7e 100644
--- a/proto_library.gni
+++ b/proto_library.gni
@@ -96,6 +96,8 @@
   assert(defined(invoker.sources), "Need sources for proto_library")
   proto_sources = invoker.sources
 
+  forward_variables_from(invoker, ["visibility"])
+
   # Don't apply OS-specific sources filtering to the assignments later on.
   # Platform files should have gotten filtered out in the sources assignment
   # when this template was invoked. If they weren't, it was on purpose and
@@ -232,6 +234,7 @@
 
   # Generate protobuf stubs.
   action(action_name) {
+    visibility = []
     visibility = [ ":*" ]
     script = "//third_party/protobuf/protoc_wrapper.py"
     sources = proto_sources
@@ -371,8 +374,9 @@
                                "defines",
                                "deps",
                                "testonly",
-                               "visibility",
                              ])
+      visibility = []
+      visibility = [ ":*" ]
       output_name = target_name
       sources = []
       foreach(source, get_target_outputs(":${action_name}")) {