Files
carbon-lang/toolchain/install/bazel/make_include_copts.bzl
T
Chandler CarruthandDana Jansens 5d41529590 Introduce a Bazel-integrated build for the installed runtimes (#6872)
This shifts the Bazel toolchain configuration of our installation to
build all of the Clang runtimes Carbon uses on-demand natively in Bazel.
We export the information about how to build into a generated Starlark
file, and emit BUILD files and Starlark logic into the installation to
orchestrate the build.

This requires some complex management of Bazel toolchains -- we need to
first set-up a "runtimes toolchain" that doesn't have runtimes of its
own, but can be used to _build_ runtimes. Then we build the runtimes
using that toolchain, and assemble them into the standard layout for a
Carbon runtimes tree. Finally we configure the _actual_ toolchain with
this built tree.

Currently, this is only setup for the installed toolchain, but I plan to
factor this runtimes build into one that can be used directly as well to
break up the monolithic runtimes build step into Bazel-integrated build
of the runtimes. This will also serve as the foundation for adding
bootstrapping support directly to our Bazel build.

---------

Co-authored-by: Dana Jansens <danakj@orodu.net>
2026-03-12 01:24:56 +00:00

26 lines
879 B
Python

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Workaround for lack of easy way to add private includes.
This is a workaround for the following Bazel issue:
https://github.com/bazelbuild/bazel/issues/2670
"""
def make_include_copts(include_dirs):
"""Create `copts` to search the provided directories for includes."""
copts = []
prefix = ""
repo_name = native.repository_name()
if repo_name != "@":
prefix = "external/{}/".format(repo_name[1:])
package_name = native.package_name()
for include_dir in include_dirs:
copts.append("-I{}{}/{}".format(prefix, package_name, include_dir))
copts.append("-I$(GENDIR)/{}{}/{}".format(prefix, package_name, include_dir))
return copts