blob: a77cce6bed05325b6c2940f952f25fadd8942c9d [file] [log] [blame]
# Copyright 2021 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
# 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.
"""Implements the set of dependencies that bazel-embedded requires."""
def _toolchain_upstream_repository_impl(rctx):
"""Creates a remote repository with a set of toolchain components.
The bazel embedded toolchain expects two targets injected_headers
and polyfill. This is rule generates these targets so that
bazel-embedded can depend on them and so that the targets can depend
on pigweeds implementation of polyfill. This rule is only ever
intended to be instantiated with the name
"bazel_embedded_upstream_toolchain", and should only be used from
the "toolchain_upstream_deps" macro.
The bazel-embedded package expects to be able to access these
targets as @bazel_embedded_upstream_toolchain//:polyfill and
rctx: Repository context.
rctx.file("BUILD", """
package(default_visibility = ["//visibility:public"])
name = "polyfill",
deps = ["@pigweed//pw_polyfill:toolchain_polyfill_overrides"],
name = "injected_headers",
deps = ["@pigweed//pw_polyfill:toolchain_injected_headers"],
_toolchain_upstream_repository = repository_rule(
doc = """
toolchain_upstream_repository creates a remote repository that can be
accessed by a toolchain repository to configure system includes.
It's recommended to use this rule through the 'toolchain_upstream_deps'
macro rather than using this rule directly.
def toolchain_upstream_deps():
"""Implements the set of dependencies that bazel-embedded requires.
These targets are used to override the default toolchain
requirements in the remote bazel-embedded toolchain. The remote
toolchain expects to find two targets;
- "@bazel_embedded_upstream_toolchain//:polyfill" -> Additional
system headers for the toolchain
- "@bazel_embedded_upstream_toolchain//:injected_headers" ->
Headers that are injected into the toolchain via the -include
command line argument
name = "bazel_embedded_upstream_toolchain",