make_include_copts.bzl 879 B

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