blob: 359d941eb8353a472b51474f542222a39027ab27 [file] [log] [blame]
Matthew Riley03a01e32022-05-24 10:16:04 -07001# Part of the Crubit 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
5# Provide LLVM from a local tree built with CMake.
6
Lukasz Anforowicz4c772642022-05-30 11:11:02 -07007llvm_install_tree_build_file_contents = """
Matthew Riley03a01e32022-05-24 10:16:04 -07008package(default_visibility = ["//visibility:public"])
9
10# An extremely coarse-grained target that provides *all* headers and libraries.
11cc_library(
12 name = "all",
13 srcs = glob([
Lukasz Anforowicz4c772642022-05-30 11:11:02 -070014 "lib/*.a",
Matthew Riley03a01e32022-05-24 10:16:04 -070015 ], exclude = [
16 "**/*.i386.a",
17 ]),
18 hdrs = glob([
Lukasz Anforowicz4c772642022-05-30 11:11:02 -070019 "include/**",
Matthew Riley03a01e32022-05-24 10:16:04 -070020 ]),
21 includes = [
Lukasz Anforowicz4c772642022-05-30 11:11:02 -070022 "include/",
Matthew Riley03a01e32022-05-24 10:16:04 -070023 ],
24 linkopts = ["-lncurses", "-lz"],
25)
26"""
27
28def llvm_repository(name):
29 # First, create an intermediate repo that overlays the BUILD file onto the
30 # prebuilt LLVM tree, yielding the single ":all" target.
31 native.new_local_repository(
32 name = "prebuilt-llvm",
Lukasz Anforowicz4c772642022-05-30 11:11:02 -070033 path = "${LLVM_INSTALL_PATH}", # template value
34 build_file_content = llvm_install_tree_build_file_contents,
Matthew Riley03a01e32022-05-24 10:16:04 -070035 )
36
37 # Next, create the final repo that emulates the layout of Bazel targets in
38 # llvm-project.
39 native.local_repository(
40 name = name,
41 path = "bazel/llvm_project",
42 )