Revert "Simplify setting up LLVM as bazel external repo"

This breaks the rules for creating repository dependencies when invoked
from another workspace. See comment on https://reviews.llvm.org/D107714

This reverts commit 934f084ad4.

Differential Revision: https://reviews.llvm.org/D108245
This commit is contained in:
Geoffrey Martin-Noble 2021-08-17 14:45:43 -07:00
parent 16890e0040
commit 0bfe614bc2
3 changed files with 34 additions and 15 deletions

View File

@ -16,16 +16,14 @@ http_archive(
],
)
new_local_repository(
name = "llvm-archive",
path = "../../",
build_file_content = "# empty",
load(":configure.bzl", "llvm_configure")
llvm_configure(
name = "llvm-project",
overlay_path = "llvm-project-overlay",
src_path = "../..",
)
load("@llvm-archive//utils/bazel:configure.bzl", "llvm_configure")
llvm_configure(name = "llvm-project")
load(":terminfo.bzl", "llvm_terminfo_from_env")
maybe(

View File

@ -5,6 +5,7 @@
"""Helper macros to configure the LLVM overlay project."""
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_skylib//lib:paths.bzl", "paths")
load(":zlib.bzl", "llvm_zlib_disable", "llvm_zlib_system")
load(":terminfo.bzl", "llvm_terminfo_disable", "llvm_terminfo_system")
@ -32,11 +33,23 @@ DEFAULT_TARGETS = [
]
def _overlay_directories(repository_ctx):
src_path = repository_ctx.path(Label("//:WORKSPACE")).dirname
bazel_path = src_path.get_child("utils").get_child("bazel")
overlay_path = bazel_path.get_child("llvm-project-overlay")
script_path = bazel_path.get_child("overlay_directories.py")
src_workspace_path = str(repository_ctx.path(
repository_ctx.attr.src_workspace,
).dirname)
src_path = paths.join(src_workspace_path, repository_ctx.attr.src_path)
overlay_workspace_path = str(repository_ctx.path(
repository_ctx.attr.overlay_workspace,
).dirname)
overlay_path = paths.join(
overlay_workspace_path,
repository_ctx.attr.overlay_path,
)
overlay_script = repository_ctx.path(
repository_ctx.attr._overlay_script,
)
python_bin = repository_ctx.which("python3")
if not python_bin:
# Windows typically just defines "python" as python3. The script itself
@ -48,7 +61,7 @@ def _overlay_directories(repository_ctx):
cmd = [
python_bin,
script_path,
overlay_script,
"--src",
src_path,
"--overlay",
@ -85,6 +98,14 @@ llvm_configure = repository_rule(
local = True,
configure = True,
attrs = {
"_overlay_script": attr.label(
default = Label("//:overlay_directories.py"),
allow_single_file = True,
),
"overlay_workspace": attr.label(default = Label("//:WORKSPACE")),
"overlay_path": attr.string(default = DEFAULT_OVERLAY_PATH),
"src_workspace": attr.label(default = Label("//:WORKSPACE")),
"src_path": attr.string(mandatory = True),
"targets": attr.string_list(default = DEFAULT_TARGETS),
},
)

View File

@ -14,8 +14,8 @@ http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION),
"https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION),
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version=SKYLIB_VERSION),
"https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version=SKYLIB_VERSION),
],
)