For some developer-overrides configuration use-cases in Fuchsia, I'd like to add a new function to GN:
some_label = "//baz:bar"
result = label_matches(some_label, [ "//foo/bar/*", "//baz:*" ])
# result == true
And along with this, two related functions that are similar to the file-path filtering functions.
filter_include_labels(labels, patterns)
filter_exclude_labels(labels, patterns)
The motivation for the first function (label_matches()) is to allow us (Fuchsia) to implement developer overrides of configs / optimization for specified targets within the build graph, in particular for Rust compilation:
args.gn:
rust_rbe_enable = true
rust_incremental_targets = [
"//src/lib/assembly/*",
"//src/connectivity/netstack/netstack3/*",
]
The above would allow the build to use the RBE remote builders by default, and then would switch those targets that match the rust_incremental_targets to use rustc's incremental recompilation options that utilize a local cache to greatly speed up compilation (but isn't compatible with remote builders).
The filter_include|exclude_labels() methods are motivated as a nicety for processing a list of targets at once, and would allow the replacement of matching against file paths in our BUILDCONFIG.gn when doing variant selection.