Matthew Riley | 03a01e3 | 2022-05-24 10:16:04 -0700 | [diff] [blame] | 1 | # 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 Anforowicz | 4c77264 | 2022-05-30 11:11:02 -0700 | [diff] [blame] | 7 | llvm_install_tree_build_file_contents = """ |
Matthew Riley | 03a01e3 | 2022-05-24 10:16:04 -0700 | [diff] [blame] | 8 | package(default_visibility = ["//visibility:public"]) |
| 9 | |
| 10 | # An extremely coarse-grained target that provides *all* headers and libraries. |
| 11 | cc_library( |
| 12 | name = "all", |
| 13 | srcs = glob([ |
Lukasz Anforowicz | 4c77264 | 2022-05-30 11:11:02 -0700 | [diff] [blame] | 14 | "lib/*.a", |
Matthew Riley | 03a01e3 | 2022-05-24 10:16:04 -0700 | [diff] [blame] | 15 | ], exclude = [ |
| 16 | "**/*.i386.a", |
| 17 | ]), |
| 18 | hdrs = glob([ |
Lukasz Anforowicz | 4c77264 | 2022-05-30 11:11:02 -0700 | [diff] [blame] | 19 | "include/**", |
Matthew Riley | 03a01e3 | 2022-05-24 10:16:04 -0700 | [diff] [blame] | 20 | ]), |
| 21 | includes = [ |
Lukasz Anforowicz | 4c77264 | 2022-05-30 11:11:02 -0700 | [diff] [blame] | 22 | "include/", |
Matthew Riley | 03a01e3 | 2022-05-24 10:16:04 -0700 | [diff] [blame] | 23 | ], |
| 24 | linkopts = ["-lncurses", "-lz"], |
| 25 | ) |
| 26 | """ |
| 27 | |
| 28 | def 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 Anforowicz | 4c77264 | 2022-05-30 11:11:02 -0700 | [diff] [blame] | 33 | path = "${LLVM_INSTALL_PATH}", # template value |
| 34 | build_file_content = llvm_install_tree_build_file_contents, |
Matthew Riley | 03a01e3 | 2022-05-24 10:16:04 -0700 | [diff] [blame] | 35 | ) |
| 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 | ) |