You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, if you're testing a rule that returns platform_common.ToolchainInfo, getting at the value is a bit awkward -- ToolchainInfo is a single provider type, but it carries toolchain-specific attributes.
The regular TargetSubject.provider function can work, but it means you have to manually unwrap the values to continue returning a Subject object. For example, if you have a toolchain rule such as:
I suppose my_lang_toolchain_info could be a lambda that did the unwrapping directly. In either case, this is kind of annoying.
A few API ideas:
# 1. special accessor on TargetSubject that accepts the attr name
target.toolchain_attr("my_lang_info", factory=my_lang_info_subject_new)
# 2. Generic ToolchainInfoSubject with attr-based accessor
target.provider(ToolchainInfo).attr("my_lang_info", factory=my_lang_info_subject_new)
(1) seems like a convenience API for (2). (2) seems like potential overkill -- ToolchainInfo is basically a plain struct and doesn't have any well known fields. So other than an attr() method, I don't know what else it would have.
The text was updated successfully, but these errors were encountered:
Today, if you're testing a rule that returns
platform_common.ToolchainInfo
, getting at the value is a bit awkward -- ToolchainInfo is a single provider type, but it carries toolchain-specific attributes.The regular
TargetSubject.provider
function can work, but it means you have to manually unwrap the values to continue returning a Subject object. For example, if you have a toolchain rule such as:A naive rules-testing accessor would look like:
I suppose
my_lang_toolchain_info
could be a lambda that did the unwrapping directly. In either case, this is kind of annoying.A few API ideas:
(1) seems like a convenience API for (2). (2) seems like potential overkill -- ToolchainInfo is basically a plain struct and doesn't have any well known fields. So other than an
attr()
method, I don't know what else it would have.The text was updated successfully, but these errors were encountered: