bazel: allow overriding perfetto_cc_ipc_library and perfetto_cc_protocpp_library

Amending CL:1867790, the two macros need to support overriding more
rules in internal google builds as well, for other targets such as
traced and traced_probes, to propagate non_prod rules internally.

R=lalitm@google.com, primiano@google.com
CC=chinglinyu@google.com, eseckler@google.com, skyostil@google.com

Change-Id: Icfbc746048d9addb4080601104eccfac290bb1b4
diff --git a/bazel/rules.bzl b/bazel/rules.bzl
index d191297..49d4aaf 100644
--- a/bazel/rules.bzl
+++ b/bazel/rules.bzl
@@ -160,17 +160,19 @@
         fail("Too many proto deps for target %s" % name)
 
     # Generates .ipc.{cc,h}.
-    proto_gen(
-        name = name + "_src",
-        deps = _proto_deps,
-        suffix = "ipc",
-        plugin = PERFETTO_CONFIG.root + ":ipc_plugin",
-        wrapper_namespace = "gen",
-        protoc = PERFETTO_CONFIG.deps.protoc[0],
-        root = PERFETTO_CONFIG.root,
-    )
+    args = {
+        'name': name + "_src",
+        'deps': _proto_deps,
+        'suffix': "ipc",
+        'plugin': PERFETTO_CONFIG.root + ":ipc_plugin",
+        'wrapper_namespace': "gen",
+        'protoc': PERFETTO_CONFIG.deps.protoc[0],
+        'root': PERFETTO_CONFIG.root,
+    }
+    if not _rule_override("proto_gen", **args):
+        proto_gen(**args)
 
-    native.filegroup(
+    perfetto_filegroup(
         name = name + "_h",
         srcs = [":" + name + "_src"],
         output_group = "h",
@@ -209,17 +211,19 @@
     if len(_proto_deps) != 1:
         fail("Too many proto deps for target %s" % name)
 
-    proto_gen(
-        name = name + "_gen",
-        deps = _proto_deps,
-        suffix = "gen",
-        plugin = PERFETTO_CONFIG.root + ":cppgen_plugin",
-        wrapper_namespace = "gen",
-        protoc = PERFETTO_CONFIG.deps.protoc[0],
-        root = PERFETTO_CONFIG.root,
-    )
+    args = {
+        'name': name + "_gen",
+        'deps': _proto_deps,
+        'suffix': "gen",
+        'plugin': PERFETTO_CONFIG.root + ":cppgen_plugin",
+        'wrapper_namespace': "gen",
+        'protoc': PERFETTO_CONFIG.deps.protoc[0],
+        'root': PERFETTO_CONFIG.root,
+    }
+    if not _rule_override("proto_gen", **args):
+        proto_gen(**args)
 
-    native.filegroup(
+    perfetto_filegroup(
         name = name + "_gen_h",
         srcs = [":" + name + "_gen"],
         output_group = "h",