Skip to content

Commit 934f084

Browse files
committed
Simplify setting up LLVM as bazel external repo
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
1 parent 4c15ad2 commit 934f084

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

utils/bazel/WORKSPACE

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ http_archive(
1616
],
1717
)
1818

19-
load(":configure.bzl", "llvm_configure")
20-
21-
llvm_configure(
22-
name = "llvm-project",
23-
overlay_path = "llvm-project-overlay",
24-
src_path = "../..",
19+
new_local_repository(
20+
name = "llvm-archive",
21+
path = "../../",
22+
build_file_content = "# empty",
2523
)
2624

25+
load("@llvm-archive//utils/bazel:configure.bzl", "llvm_configure")
26+
27+
llvm_configure(name = "llvm-project")
28+
2729
load(":terminfo.bzl", "llvm_terminfo_from_env")
2830

2931
maybe(

utils/bazel/configure.bzl

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""Helper macros to configure the LLVM overlay project."""
66

77
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
8-
load("@bazel_skylib//lib:paths.bzl", "paths")
98
load(":zlib.bzl", "llvm_zlib_disable", "llvm_zlib_system")
109
load(":terminfo.bzl", "llvm_terminfo_disable", "llvm_terminfo_system")
1110

@@ -33,23 +32,11 @@ DEFAULT_TARGETS = [
3332
]
3433

3534
def _overlay_directories(repository_ctx):
36-
src_workspace_path = str(repository_ctx.path(
37-
repository_ctx.attr.src_workspace,
38-
).dirname)
39-
40-
src_path = paths.join(src_workspace_path, repository_ctx.attr.src_path)
41-
42-
overlay_workspace_path = str(repository_ctx.path(
43-
repository_ctx.attr.overlay_workspace,
44-
).dirname)
45-
overlay_path = paths.join(
46-
overlay_workspace_path,
47-
repository_ctx.attr.overlay_path,
48-
)
35+
src_path = repository_ctx.path(Label("//:WORKSPACE")).dirname
36+
bazel_path = src_path.get_child("utils").get_child("bazel")
37+
overlay_path = bazel_path.get_child("llvm-project-overlay")
38+
script_path = bazel_path.get_child("overlay_directories.py")
4939

50-
overlay_script = repository_ctx.path(
51-
repository_ctx.attr._overlay_script,
52-
)
5340
python_bin = repository_ctx.which("python3")
5441
if not python_bin:
5542
# Windows typically just defines "python" as python3. The script itself
@@ -61,7 +48,7 @@ def _overlay_directories(repository_ctx):
6148

6249
cmd = [
6350
python_bin,
64-
overlay_script,
51+
script_path,
6552
"--src",
6653
src_path,
6754
"--overlay",
@@ -98,14 +85,6 @@ llvm_configure = repository_rule(
9885
local = True,
9986
configure = True,
10087
attrs = {
101-
"_overlay_script": attr.label(
102-
default = Label("//:overlay_directories.py"),
103-
allow_single_file = True,
104-
),
105-
"overlay_workspace": attr.label(default = Label("//:WORKSPACE")),
106-
"overlay_path": attr.string(default = DEFAULT_OVERLAY_PATH),
107-
"src_workspace": attr.label(default = Label("//:WORKSPACE")),
108-
"src_path": attr.string(mandatory = True),
10988
"targets": attr.string_list(default = DEFAULT_TARGETS),
11089
},
11190
)

utils/bazel/examples/http_archive/WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ http_archive(
1414
name = "bazel_skylib",
1515
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
1616
urls = [
17-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version=SKYLIB_VERSION),
18-
"https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version=SKYLIB_VERSION),
17+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION),
18+
"https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION),
1919
],
2020
)
2121

0 commit comments

Comments
 (0)