Files
carbon-lang/toolchain/install/bazel/make_include_copts.bzl
T
Chandler Carruth 896338d281 Remove duplicate file and fix to include the bin directory (#7073)
Noticed this when testing the Carbon toolchain with a more complex
environment, don't have any way to observe this at the moment in Bazel
though.

Assisted-by: Antigravity with Gemini
2026-04-16 21:42:06 +00:00

27 lines
965 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$(BINDIR)/{}{}/{}".format(prefix, package_name, include_dir))
copts.append("-I$(GENDIR)/{}{}/{}".format(prefix, package_name, include_dir))
return copts