bazel: allow overriding filegroup and genrule

Adds support for overriding more rules in internal google builds.
This is to propagate non_prod rules internally to all sub-targets
that come from AOSP.

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

Change-Id: Iec046b8813b04b2cfe798f748470ce7a2293cbf7
diff --git a/BUILD b/BUILD
index 264030b..4a9b088 100644
--- a/BUILD
+++ b/BUILD
@@ -17,7 +17,10 @@
 load("@perfetto_cfg//:perfetto_cfg.bzl", "PERFETTO_CONFIG")
 load(
     "@perfetto//bazel:rules.bzl",
+    "perfetto_build_config_cc_library",
     "perfetto_cc_binary",
+    "perfetto_filegroup",
+    "perfetto_genrule",
     "perfetto_cc_ipc_library",
     "perfetto_cc_library",
     "perfetto_cc_proto_descriptor",
@@ -309,7 +312,7 @@
 )
 
 # GN target: //include/perfetto/base:base
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_base_base",
     srcs = [
         "include/perfetto/base/build_config.h",
@@ -328,7 +331,7 @@
 )
 
 # GN target: //include/perfetto/ext/base:base
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_base_base",
     srcs = [
         "include/perfetto/ext/base/circular_queue.h",
@@ -373,7 +376,7 @@
 )
 
 # GN target: //include/perfetto/ext/ipc:ipc
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_ipc_ipc",
     srcs = [
         "include/perfetto/ext/ipc/async_result.h",
@@ -390,7 +393,7 @@
 )
 
 # GN target: //include/perfetto/ext/trace_processor/importers/memory_tracker:memory_tracker
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_trace_processor_importers_memory_tracker_memory_tracker",
     srcs = [
         "include/perfetto/ext/trace_processor/importers/memory_tracker/graph.h",
@@ -403,7 +406,7 @@
 )
 
 # GN target: //include/perfetto/ext/trace_processor:export_json
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_trace_processor_export_json",
     srcs = [
         "include/perfetto/ext/trace_processor/export_json.h",
@@ -411,7 +414,7 @@
 )
 
 # GN target: //include/perfetto/ext/traced:sys_stats_counters
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_traced_sys_stats_counters",
     srcs = [
         "include/perfetto/ext/traced/sys_stats_counters.h",
@@ -419,7 +422,7 @@
 )
 
 # GN target: //include/perfetto/ext/traced:traced
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_traced_traced",
     srcs = [
         "include/perfetto/ext/traced/data_source_types.h",
@@ -428,7 +431,7 @@
 )
 
 # GN target: //include/perfetto/ext/tracing/core:core
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_tracing_core_core",
     srcs = [
         "include/perfetto/ext/tracing/core/basic_types.h",
@@ -448,7 +451,7 @@
 )
 
 # GN target: //include/perfetto/ext/tracing/ipc:ipc
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_ext_tracing_ipc_ipc",
     srcs = [
         "include/perfetto/ext/tracing/ipc/consumer_ipc_client.h",
@@ -459,7 +462,7 @@
 )
 
 # GN target: //include/perfetto/profiling:pprof_builder
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_profiling_pprof_builder",
     srcs = [
         "include/perfetto/profiling/pprof_builder.h",
@@ -467,7 +470,7 @@
 )
 
 # GN target: //include/perfetto/protozero:protozero
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_protozero_protozero",
     srcs = [
         "include/perfetto/protozero/contiguous_memory_range.h",
@@ -490,7 +493,7 @@
 )
 
 # GN target: //include/perfetto/public:public
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_public_public",
     srcs = [
         "include/perfetto/public/consumer_api.h",
@@ -498,7 +501,7 @@
 )
 
 # GN target: //include/perfetto/trace_processor:basic_types
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_trace_processor_basic_types",
     srcs = [
         "include/perfetto/trace_processor/basic_types.h",
@@ -507,7 +510,7 @@
 )
 
 # GN target: //include/perfetto/trace_processor:storage
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_trace_processor_storage",
     srcs = [
         "include/perfetto/trace_processor/trace_processor_storage.h",
@@ -515,7 +518,7 @@
 )
 
 # GN target: //include/perfetto/trace_processor:trace_processor
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_trace_processor_trace_processor",
     srcs = [
         "include/perfetto/trace_processor/iterator.h",
@@ -525,7 +528,7 @@
 )
 
 # GN target: //include/perfetto/tracing/core:core
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_tracing_core_core",
     srcs = [
         "include/perfetto/tracing/core/chrome_config.h",
@@ -538,7 +541,7 @@
 )
 
 # GN target: //include/perfetto/tracing/core:forward_decls
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_tracing_core_forward_decls",
     srcs = [
         "include/perfetto/tracing/core/forward_decls.h",
@@ -546,7 +549,7 @@
 )
 
 # GN target: //include/perfetto/tracing:tracing
-filegroup(
+perfetto_filegroup(
     name = "include_perfetto_tracing_tracing",
     srcs = [
         "include/perfetto/tracing/backend_type.h",
@@ -591,7 +594,7 @@
 )
 
 # GN target: //src/android_internal:headers
-filegroup(
+perfetto_filegroup(
     name = "src_android_internal_headers",
     srcs = [
         "src/android_internal/atrace_hal.h",
@@ -604,7 +607,7 @@
 )
 
 # GN target: //src/android_internal:lazy_library_loader
-filegroup(
+perfetto_filegroup(
     name = "src_android_internal_lazy_library_loader",
     srcs = [
         "src/android_internal/lazy_library_loader.cc",
@@ -613,7 +616,7 @@
 )
 
 # GN target: //src/android_stats:android_stats
-filegroup(
+perfetto_filegroup(
     name = "src_android_stats_android_stats",
     srcs = [
         "src/android_stats/statsd_logging_helper.cc",
@@ -622,7 +625,7 @@
 )
 
 # GN target: //src/android_stats:perfetto_atoms
-filegroup(
+perfetto_filegroup(
     name = "src_android_stats_perfetto_atoms",
     srcs = [
         "src/android_stats/perfetto_atoms.h",
@@ -683,7 +686,7 @@
     linkstatic = True,
 )
 
-genrule(
+perfetto_genrule(
     name = "src_base_version_gen_h",
     srcs = [
         "CHANGELOG",
@@ -698,7 +701,7 @@
 )
 
 # GN target: //src/ipc:client
-filegroup(
+perfetto_filegroup(
     name = "src_ipc_client",
     srcs = [
         "src/ipc/client_impl.cc",
@@ -708,7 +711,7 @@
 )
 
 # GN target: //src/ipc:common
-filegroup(
+perfetto_filegroup(
     name = "src_ipc_common",
     srcs = [
         "src/ipc/buffered_frame_deserializer.cc",
@@ -719,7 +722,7 @@
 )
 
 # GN target: //src/ipc:host
-filegroup(
+perfetto_filegroup(
     name = "src_ipc_host",
     srcs = [
         "src/ipc/host_impl.cc",
@@ -728,7 +731,7 @@
 )
 
 # GN target: //src/kallsyms:kallsyms
-filegroup(
+perfetto_filegroup(
     name = "src_kallsyms_kallsyms",
     srcs = [
         "src/kallsyms/kernel_symbol_map.cc",
@@ -749,7 +752,7 @@
 )
 
 # GN target: //src/perfetto_cmd:perfetto_cmd
-filegroup(
+perfetto_filegroup(
     name = "src_perfetto_cmd_perfetto_cmd",
     srcs = [
         "src/perfetto_cmd/config.cc",
@@ -766,7 +769,7 @@
 )
 
 # GN target: //src/perfetto_cmd:trigger_producer
-filegroup(
+perfetto_filegroup(
     name = "src_perfetto_cmd_trigger_producer",
     srcs = [
         "src/perfetto_cmd/trigger_producer.cc",
@@ -775,7 +778,7 @@
 )
 
 # GN target: //src/profiling/symbolizer:symbolize_database
-filegroup(
+perfetto_filegroup(
     name = "src_profiling_symbolizer_symbolize_database",
     srcs = [
         "src/profiling/symbolizer/symbolize_database.cc",
@@ -784,7 +787,7 @@
 )
 
 # GN target: //src/profiling/symbolizer:symbolizer
-filegroup(
+perfetto_filegroup(
     name = "src_profiling_symbolizer_symbolizer",
     srcs = [
         "src/profiling/symbolizer/breakpad_parser.cc",
@@ -806,7 +809,7 @@
 )
 
 # GN target: //src/profiling:deobfuscator
-filegroup(
+perfetto_filegroup(
     name = "src_profiling_deobfuscator",
     srcs = [
         "src/profiling/deobfuscator.cc",
@@ -815,7 +818,7 @@
 )
 
 # GN target: //src/protozero/filtering:bytecode_common
-filegroup(
+perfetto_filegroup(
     name = "src_protozero_filtering_bytecode_common",
     srcs = [
         "src/protozero/filtering/filter_bytecode_common.h",
@@ -823,7 +826,7 @@
 )
 
 # GN target: //src/protozero/filtering:bytecode_generator
-filegroup(
+perfetto_filegroup(
     name = "src_protozero_filtering_bytecode_generator",
     srcs = [
         "src/protozero/filtering/filter_bytecode_generator.cc",
@@ -832,7 +835,7 @@
 )
 
 # GN target: //src/protozero/filtering:bytecode_parser
-filegroup(
+perfetto_filegroup(
     name = "src_protozero_filtering_bytecode_parser",
     srcs = [
         "src/protozero/filtering/filter_bytecode_parser.cc",
@@ -841,7 +844,7 @@
 )
 
 # GN target: //src/protozero/filtering:filter_util
-filegroup(
+perfetto_filegroup(
     name = "src_protozero_filtering_filter_util",
     srcs = [
         "src/protozero/filtering/filter_util.cc",
@@ -850,7 +853,7 @@
 )
 
 # GN target: //src/protozero/filtering:message_filter
-filegroup(
+perfetto_filegroup(
     name = "src_protozero_filtering_message_filter",
     srcs = [
         "src/protozero/filtering/message_filter.cc",
@@ -860,7 +863,7 @@
 )
 
 # GN target: //src/protozero:proto_ring_buffer
-filegroup(
+perfetto_filegroup(
     name = "src_protozero_proto_ring_buffer",
     srcs = [
         "src/protozero/proto_ring_buffer.cc",
@@ -869,7 +872,7 @@
 )
 
 # GN target: //src/trace_processor/analysis:analysis
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_analysis_analysis",
     srcs = [
         "src/trace_processor/analysis/describe_slice.cc",
@@ -904,7 +907,7 @@
 )
 
 # GN target: //src/trace_processor/db:db
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_db_db",
     srcs = [
         "src/trace_processor/db/column.cc",
@@ -918,7 +921,7 @@
 )
 
 # GN target: //src/trace_processor/importers/common:common
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_importers_common_common",
     srcs = [
         "src/trace_processor/importers/common/args_tracker.cc",
@@ -945,7 +948,7 @@
 )
 
 # GN target: //src/trace_processor/importers/memory_tracker:graph_processor
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_importers_memory_tracker_graph_processor",
     srcs = [
         "src/trace_processor/importers/memory_tracker/graph.cc",
@@ -1006,7 +1009,7 @@
     ],
 )
 
-genrule(
+perfetto_genrule(
     name = "src_trace_processor_metrics_gen_merged_sql_metrics",
     srcs = [
         "src/trace_processor/metrics/android/android_batt.sql",
@@ -1105,7 +1108,7 @@
 )
 
 # GN target: //src/trace_processor/metrics:lib
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_metrics_lib",
     srcs = [
         "src/trace_processor/metrics/metrics.cc",
@@ -1114,7 +1117,7 @@
 )
 
 # GN target: //src/trace_processor/rpc:httpd
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_rpc_httpd",
     srcs = [
         "src/trace_processor/rpc/httpd.cc",
@@ -1123,7 +1126,7 @@
 )
 
 # GN target: //src/trace_processor/rpc:rpc
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_rpc_rpc",
     srcs = [
         "src/trace_processor/rpc/query_result_serializer.cc",
@@ -1134,7 +1137,7 @@
 )
 
 # GN target: //src/trace_processor/sqlite:sqlite
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_sqlite_sqlite",
     srcs = [
         "src/trace_processor/sqlite/db_sqlite_table.cc",
@@ -1162,7 +1165,7 @@
 )
 
 # GN target: //src/trace_processor/storage:storage
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_storage_storage",
     srcs = [
         "src/trace_processor/storage/metadata.h",
@@ -1173,7 +1176,7 @@
 )
 
 # GN target: //src/trace_processor/tables:tables
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_tables_tables",
     srcs = [
         "src/trace_processor/tables/android_tables.h",
@@ -1191,7 +1194,7 @@
 )
 
 # GN target: //src/trace_processor/types:types
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_types_types",
     srcs = [
         "src/trace_processor/types/destructible.cc",
@@ -1209,7 +1212,7 @@
 )
 
 # GN target: //src/trace_processor/util:descriptors
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_util_descriptors",
     srcs = [
         "src/trace_processor/util/descriptors.cc",
@@ -1218,7 +1221,7 @@
 )
 
 # GN target: //src/trace_processor/util:gzip
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_util_gzip",
     srcs = [
         "src/trace_processor/util/gzip_utils.cc",
@@ -1227,7 +1230,7 @@
 )
 
 # GN target: //src/trace_processor/util:interned_message_view
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_util_interned_message_view",
     srcs = [
         "src/trace_processor/util/interned_message_view.h",
@@ -1235,7 +1238,7 @@
 )
 
 # GN target: //src/trace_processor/util:proto_to_args_parser
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_util_proto_to_args_parser",
     srcs = [
         "src/trace_processor/util/debug_annotation_parser.cc",
@@ -1246,7 +1249,7 @@
 )
 
 # GN target: //src/trace_processor/util:protozero_to_text
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_util_protozero_to_text",
     srcs = [
         "src/trace_processor/util/protozero_to_text.cc",
@@ -1255,7 +1258,7 @@
 )
 
 # GN target: //src/trace_processor/util:trace_blob_view
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_util_trace_blob_view",
     srcs = [
         "src/trace_processor/util/trace_blob_view.h",
@@ -1263,7 +1266,7 @@
 )
 
 # GN target: //src/trace_processor/util:util
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_util_util",
     srcs = [
         "src/trace_processor/util/status_macros.h",
@@ -1271,7 +1274,7 @@
 )
 
 # GN target: //src/trace_processor:export_json
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_export_json",
     srcs = [
         "src/trace_processor/export_json.cc",
@@ -1280,7 +1283,7 @@
 )
 
 # GN target: //src/trace_processor:ftrace_descriptors
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_ftrace_descriptors",
     srcs = [
         "src/trace_processor/importers/ftrace/ftrace_descriptors.cc",
@@ -1289,7 +1292,7 @@
 )
 
 # GN target: //src/trace_processor:lib
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_lib",
     srcs = [
         "src/trace_processor/dynamic/ancestor_generator.cc",
@@ -1324,7 +1327,7 @@
 )
 
 # GN target: //src/trace_processor:metatrace
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_metatrace",
     srcs = [
         "src/trace_processor/tp_metatrace.cc",
@@ -1333,7 +1336,7 @@
 )
 
 # GN target: //src/trace_processor:storage_full
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_storage_full",
     srcs = [
         "src/trace_processor/importers/additional_modules.cc",
@@ -1406,7 +1409,7 @@
 )
 
 # GN target: //src/trace_processor:storage_minimal
-filegroup(
+perfetto_filegroup(
     name = "src_trace_processor_storage_minimal",
     srcs = [
         "src/trace_processor/forwarding_trace_parser.cc",
@@ -1484,7 +1487,7 @@
 )
 
 # GN target: //src/traced/probes/android_log:android_log
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_android_log_android_log",
     srcs = [
         "src/traced/probes/android_log/android_log_data_source.cc",
@@ -1493,7 +1496,7 @@
 )
 
 # GN target: //src/traced/probes/common:common
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_common_common",
     srcs = [
         "src/traced/probes/common/cpu_freq_info.cc",
@@ -1502,7 +1505,7 @@
 )
 
 # GN target: //src/traced/probes/filesystem:filesystem
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_filesystem_filesystem",
     srcs = [
         "src/traced/probes/filesystem/file_scanner.cc",
@@ -1521,7 +1524,7 @@
 )
 
 # GN target: //src/traced/probes/ftrace/format_parser:format_parser
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_ftrace_format_parser_format_parser",
     srcs = [
         "src/traced/probes/ftrace/format_parser/format_parser.cc",
@@ -1530,7 +1533,7 @@
 )
 
 # GN target: //src/traced/probes/ftrace:ftrace
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_ftrace_ftrace",
     srcs = [
         "src/traced/probes/ftrace/atrace_hal_wrapper.cc",
@@ -1568,7 +1571,7 @@
 )
 
 # GN target: //src/traced/probes/ftrace:ftrace_procfs
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_ftrace_ftrace_procfs",
     srcs = [
         "src/traced/probes/ftrace/ftrace_procfs.cc",
@@ -1577,7 +1580,7 @@
 )
 
 # GN target: //src/traced/probes/initial_display_state:initial_display_state
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_initial_display_state_initial_display_state",
     srcs = [
         "src/traced/probes/initial_display_state/initial_display_state_data_source.cc",
@@ -1586,7 +1589,7 @@
 )
 
 # GN target: //src/traced/probes/metatrace:metatrace
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_metatrace_metatrace",
     srcs = [
         "src/traced/probes/metatrace/metatrace_data_source.cc",
@@ -1595,7 +1598,7 @@
 )
 
 # GN target: //src/traced/probes/packages_list:packages_list
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_packages_list_packages_list",
     srcs = [
         "src/traced/probes/packages_list/packages_list_data_source.cc",
@@ -1604,7 +1607,7 @@
 )
 
 # GN target: //src/traced/probes/packages_list:packages_list_parser
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_packages_list_packages_list_parser",
     srcs = [
         "src/traced/probes/packages_list/packages_list_parser.cc",
@@ -1613,7 +1616,7 @@
 )
 
 # GN target: //src/traced/probes/power:power
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_power_power",
     srcs = [
         "src/traced/probes/power/android_power_data_source.cc",
@@ -1622,7 +1625,7 @@
 )
 
 # GN target: //src/traced/probes/ps:ps
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_ps_ps",
     srcs = [
         "src/traced/probes/ps/process_stats_data_source.cc",
@@ -1631,7 +1634,7 @@
 )
 
 # GN target: //src/traced/probes/sys_stats:sys_stats
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_sys_stats_sys_stats",
     srcs = [
         "src/traced/probes/sys_stats/sys_stats_data_source.cc",
@@ -1640,7 +1643,7 @@
 )
 
 # GN target: //src/traced/probes/system_info:system_info
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_system_info_system_info",
     srcs = [
         "src/traced/probes/system_info/system_info_data_source.cc",
@@ -1649,7 +1652,7 @@
 )
 
 # GN target: //src/traced/probes:data_source
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_data_source",
     srcs = [
         "src/traced/probes/probes_data_source.cc",
@@ -1658,7 +1661,7 @@
 )
 
 # GN target: //src/traced/probes:probes
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_probes",
     srcs = [
         "src/traced/probes/probes.cc",
@@ -1666,7 +1669,7 @@
 )
 
 # GN target: //src/traced/probes:probes_src
-filegroup(
+perfetto_filegroup(
     name = "src_traced_probes_probes_src",
     srcs = [
         "src/traced/probes/kmem_activity_trigger.cc",
@@ -1677,7 +1680,7 @@
 )
 
 # GN target: //src/traced/service:service
-filegroup(
+perfetto_filegroup(
     name = "src_traced_service_service",
     srcs = [
         "src/traced/service/builtin_producer.cc",
@@ -1687,7 +1690,7 @@
 )
 
 # GN target: //src/tracing/consumer_api_deprecated:consumer_api_deprecated
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_consumer_api_deprecated_consumer_api_deprecated",
     srcs = [
         "src/tracing/consumer_api_deprecated/consumer_api_deprecated.cc",
@@ -1695,7 +1698,7 @@
 )
 
 # GN target: //src/tracing/core:core
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_core_core",
     srcs = [
         "src/tracing/core/id_allocator.cc",
@@ -1714,7 +1717,7 @@
 )
 
 # GN target: //src/tracing/core:service
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_core_service",
     srcs = [
         "src/tracing/core/metatrace_writer.cc",
@@ -1729,7 +1732,7 @@
 )
 
 # GN target: //src/tracing/ipc/consumer:consumer
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_ipc_consumer_consumer",
     srcs = [
         "src/tracing/ipc/consumer/consumer_ipc_client_impl.cc",
@@ -1738,7 +1741,7 @@
 )
 
 # GN target: //src/tracing/ipc/producer:producer
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_ipc_producer_producer",
     srcs = [
         "src/tracing/ipc/producer/producer_ipc_client_impl.cc",
@@ -1747,7 +1750,7 @@
 )
 
 # GN target: //src/tracing/ipc/service:service
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_ipc_service_service",
     srcs = [
         "src/tracing/ipc/service/consumer_ipc_service.cc",
@@ -1760,7 +1763,7 @@
 )
 
 # GN target: //src/tracing/ipc:common
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_ipc_common",
     srcs = [
         "src/tracing/ipc/default_socket.cc",
@@ -1774,7 +1777,7 @@
 )
 
 # GN target: //src/tracing:client_api_without_backends
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_client_api_without_backends",
     srcs = [
         "src/tracing/console_interceptor.cc",
@@ -1804,7 +1807,7 @@
 )
 
 # GN target: //src/tracing:common
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_common",
     srcs = [
         "src/tracing/trace_writer_base.cc",
@@ -1812,7 +1815,7 @@
 )
 
 # GN target: //src/tracing:in_process_backend
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_in_process_backend",
     srcs = [
         "src/tracing/internal/in_process_tracing_backend.cc",
@@ -1820,7 +1823,7 @@
 )
 
 # GN target: //src/tracing:platform_impl
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_platform_impl",
     srcs = [
         "src/tracing/platform_posix.cc",
@@ -1829,7 +1832,7 @@
 )
 
 # GN target: //src/tracing:system_backend
-filegroup(
+perfetto_filegroup(
     name = "src_tracing_system_backend",
     srcs = [
         "src/tracing/internal/system_tracing_backend.cc",
@@ -1837,7 +1840,7 @@
 )
 
 # GN target: //tools/trace_to_text:common
-filegroup(
+perfetto_filegroup(
     name = "tools_trace_to_text_common",
     srcs = [
         "tools/trace_to_text/deobfuscate_profile.cc",
@@ -1858,7 +1861,7 @@
 )
 
 # GN target: //tools/trace_to_text:full
-filegroup(
+perfetto_filegroup(
     name = "tools_trace_to_text_full",
     srcs = [
         "tools/trace_to_text/proto_full_utils.cc",
@@ -1878,7 +1881,7 @@
 )
 
 # GN target: //tools/trace_to_text:pprofbuilder
-filegroup(
+perfetto_filegroup(
     name = "tools_trace_to_text_pprofbuilder",
     srcs = [
         "tools/trace_to_text/pprof_builder.cc",
@@ -1886,7 +1889,7 @@
 )
 
 # GN target: //tools/trace_to_text:utils
-filegroup(
+perfetto_filegroup(
     name = "tools_trace_to_text_utils",
     srcs = [
         "tools/trace_to_text/utils.cc",
@@ -4030,7 +4033,7 @@
 
 # Deliberately NOT a perfetto_cc_library, to avoid cyclic deps.
 # This is pulled as a default dep by all targets.
-cc_library(
+perfetto_build_config_cc_library(
     name = "build_config_hdr",
     hdrs = [build_config_dir_ + "/perfetto_build_flags.h"],
     includes = [build_config_dir_],