blob: c7294bed06ee75e06526fbdc19af6b6eb1b70cb8 [file] [edit]
# Copyright 2026 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Rule to transition a dependency to a specific platform."""
def _transition_impl(settings, attr):
return {"//command_line_option:platforms": [attr.platform]}
platform_transition = transition(
implementation = _transition_impl,
inputs = [],
outputs = ["//command_line_option:platforms"],
)
def _transitioned_dep_impl(ctx):
# Forward DefaultInfo from the actual target
return [ctx.attr.dep[DefaultInfo]]
transitioned_dep = rule(
implementation = _transitioned_dep_impl,
attrs = {
"dep": attr.label(cfg = platform_transition),
"platform": attr.string(mandatory = True),
},
)