1# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2# See https://llvm.org/LICENSE.txt for license information.
3# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5"""An example WORKSPACE for configuring LLVM using http_archive."""
6
7workspace(name = "http_archive_example")
8
9load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
10
11# Replace with the LLVM commit you want to use.
12LLVM_COMMIT = "09ac97ce350316b95b8cddb796d52f71b6f68296"
13
14# The easiest way to calculate this for a new commit is to set it to empty and
15# then run a bazel build and it will report the digest necessary to cache the
16# archive and make the build reproducible.
17LLVM_SHA256 = "2fb1aa06d12f8db349a27426cb0ced062987c5c2a75143c69f4284929e2750ff"
18
19# FIXME: It shouldn't be necessary to use http_archive twice here. Caching
20# should mean that this isn't too expensive though.
21
22http_archive(
23    name = "llvm-project-raw",
24    build_file_content = "#empty",
25    sha256 = LLVM_SHA256,
26    strip_prefix = "llvm-project-" + LLVM_COMMIT,
27    urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
28)
29
30http_archive(
31    name = "llvm-bazel",
32    sha256 = LLVM_SHA256,
33    strip_prefix = "llvm-project-{}/utils/bazel".format(LLVM_COMMIT),
34    urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
35)
36
37load("@llvm-bazel//:configure.bzl", "llvm_configure", "llvm_disable_optional_support_deps")
38
39llvm_configure(
40    name = "llvm-project",
41    src_path = ".",
42    src_workspace = "@llvm-project-raw//:WORKSPACE",
43)
44
45# Disables optional dependencies for Support like zlib and terminfo. You may
46# instead want to configure them using the macros in the corresponding bzl
47# files.
48llvm_disable_optional_support_deps()
49