Can we add a 'label_matches()' and label filtering functions?

28 views
Skip to first unread message

Aaron Wood

unread,
Feb 15, 2024, 6:44:38 PMFeb 15
to gn-dev
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.



David Turner

unread,
Feb 16, 2024, 5:03:57 AMFeb 16
to Aaron Wood, gn-dev
Thanks Aaron,

I second this addition, it would simplify and improve the performance of our `gn gen` passes when enabling build-variants (as we need to perform manual filtering will foreach() loops are that are very slow in practice.

- Digit

--
To unsubscribe from this group and stop receiving emails from it, send an email to gn-dev+un...@chromium.org.

Dirk Pranke

unread,
Feb 20, 2024, 4:15:15 PMFeb 20
to Aaron Wood, gn-dev, David Turner
Hi Aaron, 

I think this sounds reasonable enough. Let's give this a few more days to see if anyone else objects, and then we can proceed with the change.

-- Dirk

Aaron Wood

unread,
Feb 20, 2024, 4:32:35 PMFeb 20
to Dirk Pranke, gn-dev, David Turner
Ok.  I'll pick the CL back up and address the comments I have from digit@ and some other cleanup it needs, then.
Reply all
Reply to author
Forward
0 new messages