Skip to content

Commit

Permalink
Simplify setting up LLVM as bazel external repo
Browse files Browse the repository at this point in the history
Only require one intermediate repository instead of two.
Fewer parameters in llvm_config.
Remove bazel_skylib dependency.

Reviewed By: goncharov

Differential Revision: https://reviews.llvm.org/D107714
  • Loading branch information
chsigg committed Aug 17, 2021
1 parent 4c15ad2 commit 934f084
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 34 deletions.
14 changes: 8 additions & 6 deletions utils/bazel/WORKSPACE
Expand Up @@ -16,14 +16,16 @@ http_archive(
],
)

load(":configure.bzl", "llvm_configure")

llvm_configure(
name = "llvm-project",
overlay_path = "llvm-project-overlay",
src_path = "../..",
new_local_repository(
name = "llvm-archive",
path = "../../",
build_file_content = "# empty",
)

load("@llvm-archive//utils/bazel:configure.bzl", "llvm_configure")

llvm_configure(name = "llvm-project")

load(":terminfo.bzl", "llvm_terminfo_from_env")

maybe(
Expand Down
31 changes: 5 additions & 26 deletions utils/bazel/configure.bzl
Expand Up @@ -5,7 +5,6 @@
"""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")

Expand Down Expand Up @@ -33,23 +32,11 @@ DEFAULT_TARGETS = [
]

def _overlay_directories(repository_ctx):
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,
)
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")

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
Expand All @@ -61,7 +48,7 @@ def _overlay_directories(repository_ctx):

cmd = [
python_bin,
overlay_script,
script_path,
"--src",
src_path,
"--overlay",
Expand Down Expand Up @@ -98,14 +85,6 @@ 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),
},
)
Expand Down
4 changes: 2 additions & 2 deletions utils/bazel/examples/http_archive/WORKSPACE
Expand Up @@ -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),
],
)

Expand Down

0 comments on commit 934f084

Please sign in to comment.