Files
carbon-lang/WORKSPACE
T
Jon MeowandChandler Carruth f58e5da827 Modify clang detection to build clang (#261)
Per chandlerc's comment:

First, this builds inside the Bazel tree rather than in the source
repository. This ensures we start in a clean directory each time the
repository rule is run again. We don't need to detect an existing build
with this, and it will only be rebuilt when the workspace file or the
repository rule implementation is changed. This can be forced by using:
```
bazel sync --configure
```

Second, we use an implicit dependency on the `WORKSPACE` file to locate
the workspace directory automatically, and the `HEAD` file from the
`llvm-project` submodule to trigger a rebuild if the submodule is
updated.

Third, teach the CMake script to try to use a system-installed `clang`
if installed and not overridden by the `CC` environment variable. This
is very different from the prior logic -- this is only used with the
CMake build, and so should work with any system C++ compiler that can
build Clang and LLVM.

Lastly, this tweaks the CMake options to tune this build given that we
now fully control it and it will only be used in this context. This
still results in a 1.5gb build for me. =/ But its as small as I can make
it really. It's a frustrating long list, but I couldn't find a more
brief way of representing this.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-02-08 17:17:58 -08:00

64 lines
2.1 KiB
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
workspace(name = "carbon")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# We want to use LLVM via an external CMake build, so pull in the Bazel
# infrastructure that provides direct CMake interfacing support.
http_archive(
name = "rules_foreign_cc",
strip_prefix = "rules_foreign_cc-master",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/master.zip",
)
# Add Bazel's python rules.
http_archive(
name = "rules_python",
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz",
)
# Set up necessary dependencies for working with the foreign C++ rules.
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
# Bootstrap a Clang and LLVM toolchain.
load("//bazel/cc_toolchains:clang_bootstrap.bzl", "bootstrap_clang_toolchain")
bootstrap_clang_toolchain(name = "bootstrap_clang_toolchain")
# Configure the bootstrapped Clang and LLVM toolchain for Bazel.
load("//bazel/cc_toolchains:clang_configuration.bzl", "configure_clang_toolchain")
configure_clang_toolchain(
name = "bazel_cc_toolchain",
clang = "@bootstrap_clang_toolchain//:bin/clang",
)
local_repository(
name = "llvm_bazel",
path = "third_party/llvm-bazel/llvm-bazel",
)
load("@llvm_bazel//:configure.bzl", "llvm_configure")
llvm_configure(
name = "llvm-project",
src_path = "third_party/llvm-project",
src_workspace = "@carbon//:WORKSPACE",
)
load("@llvm_bazel//:terminfo.bzl", "llvm_terminfo_system")
# We require successful detection and use of a system terminfo library.
llvm_terminfo_system(name = "llvm_terminfo")
load("@llvm_bazel//:zlib.bzl", "llvm_zlib_system")
# We require successful detection and use of a system zlib library.
llvm_zlib_system(name = "llvm_zlib")