forked from OSchip/llvm-project
Simplify setting up LLVM as bazel external repo
Only require one intermediate repository instead of two. Fewer parameters in llvm_config. Second attempt of https://reviews.llvm.org/D107714, this time also updating `third_party_build` and `deps_impl` paths. Reviewed By: GMNGeoffrey Differential Revision: https://reviews.llvm.org/D108274
This commit is contained in:
parent
96fbd5cd5e
commit
81d5412439
|
@ -16,15 +16,17 @@ http_archive(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
load(":configure.bzl", "llvm_configure")
|
new_local_repository(
|
||||||
|
name = "llvm-raw",
|
||||||
llvm_configure(
|
path = "../../",
|
||||||
name = "llvm-project",
|
build_file_content = "# empty",
|
||||||
overlay_path = "llvm-project-overlay",
|
|
||||||
src_path = "../..",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
load(":terminfo.bzl", "llvm_terminfo_from_env")
|
load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
|
||||||
|
|
||||||
|
llvm_configure(name = "llvm-project")
|
||||||
|
|
||||||
|
load("@llvm-raw//utils/bazel:terminfo.bzl", "llvm_terminfo_from_env")
|
||||||
|
|
||||||
maybe(
|
maybe(
|
||||||
llvm_terminfo_from_env,
|
llvm_terminfo_from_env,
|
||||||
|
@ -34,7 +36,7 @@ maybe(
|
||||||
maybe(
|
maybe(
|
||||||
http_archive,
|
http_archive,
|
||||||
name = "zlib",
|
name = "zlib",
|
||||||
build_file = "//third_party_build:zlib.BUILD",
|
build_file = "@llvm-raw//utils/bazel/third_party_build:zlib.BUILD",
|
||||||
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
|
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
|
||||||
strip_prefix = "zlib-1.2.11",
|
strip_prefix = "zlib-1.2.11",
|
||||||
urls = [
|
urls = [
|
||||||
|
@ -43,7 +45,7 @@ maybe(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
load(":zlib.bzl", "llvm_zlib_from_env")
|
load("@llvm-raw//utils/bazel:zlib.bzl", "llvm_zlib_from_env")
|
||||||
|
|
||||||
maybe(
|
maybe(
|
||||||
llvm_zlib_from_env,
|
llvm_zlib_from_env,
|
||||||
|
@ -54,7 +56,7 @@ maybe(
|
||||||
maybe(
|
maybe(
|
||||||
http_archive,
|
http_archive,
|
||||||
name = "vulkan_headers",
|
name = "vulkan_headers",
|
||||||
build_file = "//third_party_build:vulkan_headers.BUILD",
|
build_file = "@llvm-raw//utils/bazel/third_party_build:vulkan_headers.BUILD",
|
||||||
sha256 = "19f491784ef0bc73caff877d11c96a48b946b5a1c805079d9006e3fbaa5c1895",
|
sha256 = "19f491784ef0bc73caff877d11c96a48b946b5a1c805079d9006e3fbaa5c1895",
|
||||||
strip_prefix = "Vulkan-Headers-9bd3f561bcee3f01d22912de10bb07ce4e23d378",
|
strip_prefix = "Vulkan-Headers-9bd3f561bcee3f01d22912de10bb07ce4e23d378",
|
||||||
urls = [
|
urls = [
|
||||||
|
@ -62,7 +64,7 @@ maybe(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
load(":vulkan_sdk.bzl", "vulkan_sdk_setup")
|
load("@llvm-raw//utils/bazel:vulkan_sdk.bzl", "vulkan_sdk_setup")
|
||||||
|
|
||||||
maybe(
|
maybe(
|
||||||
vulkan_sdk_setup,
|
vulkan_sdk_setup,
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"""Helper macros to configure the LLVM overlay project."""
|
"""Helper macros to configure the LLVM overlay project."""
|
||||||
|
|
||||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
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(":zlib.bzl", "llvm_zlib_disable", "llvm_zlib_system")
|
||||||
load(":terminfo.bzl", "llvm_terminfo_disable", "llvm_terminfo_system")
|
load(":terminfo.bzl", "llvm_terminfo_disable", "llvm_terminfo_system")
|
||||||
|
|
||||||
|
@ -33,23 +32,11 @@ DEFAULT_TARGETS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
def _overlay_directories(repository_ctx):
|
def _overlay_directories(repository_ctx):
|
||||||
src_workspace_path = str(repository_ctx.path(
|
src_path = repository_ctx.path(Label("//:WORKSPACE")).dirname
|
||||||
repository_ctx.attr.src_workspace,
|
bazel_path = src_path.get_child("utils").get_child("bazel")
|
||||||
).dirname)
|
overlay_path = bazel_path.get_child("llvm-project-overlay")
|
||||||
|
script_path = bazel_path.get_child("overlay_directories.py")
|
||||||
|
|
||||||
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")
|
python_bin = repository_ctx.which("python3")
|
||||||
if not python_bin:
|
if not python_bin:
|
||||||
# Windows typically just defines "python" as python3. The script itself
|
# Windows typically just defines "python" as python3. The script itself
|
||||||
|
@ -61,7 +48,7 @@ def _overlay_directories(repository_ctx):
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
python_bin,
|
python_bin,
|
||||||
overlay_script,
|
script_path,
|
||||||
"--src",
|
"--src",
|
||||||
src_path,
|
src_path,
|
||||||
"--overlay",
|
"--overlay",
|
||||||
|
@ -98,14 +85,6 @@ llvm_configure = repository_rule(
|
||||||
local = True,
|
local = True,
|
||||||
configure = True,
|
configure = True,
|
||||||
attrs = {
|
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),
|
"targets": attr.string_list(default = DEFAULT_TARGETS),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,21 +17,16 @@ http_archive(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Or wherever your submodule is located.
|
new_local_repository(
|
||||||
SUBMODULE_PATH = "third_party/llvm-project"
|
name = "llvm-raw",
|
||||||
|
build_file_content = "# empty",
|
||||||
local_repository(
|
# Or wherever your submodule is located.
|
||||||
name = "llvm-bazel",
|
path = "third_party/llvm-project",
|
||||||
path = SUBMODULE_PATH + "/utils/bazel",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
load("@llvm-bazel//:configure.bzl", "llvm_configure", "llvm_disable_optional_support_deps")
|
load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure", "llvm_disable_optional_support_deps")
|
||||||
|
|
||||||
llvm_configure(
|
llvm_configure(name = "llvm-project")
|
||||||
name = "llvm-project",
|
|
||||||
src_path = SUBMODULE_PATH,
|
|
||||||
src_workspace = "@submodule_example//:WORKSPACE",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Disables optional dependencies for Support like zlib and terminfo. You may
|
# Disables optional dependencies for Support like zlib and terminfo. You may
|
||||||
# instead want to configure them using the macros in the corresponding bzl
|
# instead want to configure them using the macros in the corresponding bzl
|
||||||
|
|
|
@ -27,7 +27,7 @@ def _llvm_terminfo_disable_impl(repository_ctx):
|
||||||
|
|
||||||
_terminfo_disable_attrs = {
|
_terminfo_disable_attrs = {
|
||||||
"_disable_build_template": attr.label(
|
"_disable_build_template": attr.label(
|
||||||
default = Label("//deps_impl:terminfo_disable.BUILD"),
|
default = Label("//utils/bazel/deps_impl:terminfo_disable.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -147,11 +147,11 @@ def _merge_attrs(attrs_list):
|
||||||
|
|
||||||
_terminfo_system_attrs = _merge_attrs([_terminfo_disable_attrs, {
|
_terminfo_system_attrs = _merge_attrs([_terminfo_disable_attrs, {
|
||||||
"_system_build_template": attr.label(
|
"_system_build_template": attr.label(
|
||||||
default = Label("//deps_impl:terminfo_system.BUILD"),
|
default = Label("//utils/bazel/deps_impl:terminfo_system.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
"_terminfo_test_source": attr.label(
|
"_terminfo_test_source": attr.label(
|
||||||
default = Label("//deps_impl:terminfo_test.c"),
|
default = Label("//utils/bazel/deps_impl:terminfo_test.c"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
"candidate_system_linkopts": attr.string_list(
|
"candidate_system_linkopts": attr.string_list(
|
||||||
|
|
|
@ -33,7 +33,7 @@ llvm_zlib_external = repository_rule(
|
||||||
implementation = _llvm_zlib_external_impl,
|
implementation = _llvm_zlib_external_impl,
|
||||||
attrs = {
|
attrs = {
|
||||||
"_external_build_template": attr.label(
|
"_external_build_template": attr.label(
|
||||||
default = Label("//deps_impl:zlib_external.BUILD"),
|
default = Label("//utils/bazel/deps_impl:zlib_external.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
"external_zlib": attr.string(
|
"external_zlib": attr.string(
|
||||||
|
@ -56,7 +56,7 @@ llvm_zlib_system = repository_rule(
|
||||||
implementation = _llvm_zlib_system_impl,
|
implementation = _llvm_zlib_system_impl,
|
||||||
attrs = {
|
attrs = {
|
||||||
"_system_build_template": attr.label(
|
"_system_build_template": attr.label(
|
||||||
default = Label("//deps_impl:zlib_system.BUILD"),
|
default = Label("//utils/bazel/deps_impl:zlib_system.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -73,7 +73,7 @@ llvm_zlib_disable = repository_rule(
|
||||||
implementation = _llvm_zlib_disable_impl,
|
implementation = _llvm_zlib_disable_impl,
|
||||||
attrs = {
|
attrs = {
|
||||||
"_disable_build_template": attr.label(
|
"_disable_build_template": attr.label(
|
||||||
default = Label("//deps_impl:zlib_disable.BUILD"),
|
default = Label("//utils/bazel/deps_impl:zlib_disable.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -92,15 +92,15 @@ llvm_zlib_from_env = repository_rule(
|
||||||
implementation = _llvm_zlib_from_env_impl,
|
implementation = _llvm_zlib_from_env_impl,
|
||||||
attrs = {
|
attrs = {
|
||||||
"_disable_build_template": attr.label(
|
"_disable_build_template": attr.label(
|
||||||
default = Label("//deps_impl:zlib_disable.BUILD"),
|
default = Label("//utils/bazel/deps_impl:zlib_disable.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
"_external_build_template": attr.label(
|
"_external_build_template": attr.label(
|
||||||
default = Label("//deps_impl:zlib_external.BUILD"),
|
default = Label("//utils/bazel/deps_impl:zlib_external.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
"_system_build_template": attr.label(
|
"_system_build_template": attr.label(
|
||||||
default = Label("//deps_impl:zlib_system.BUILD"),
|
default = Label("//utils/bazel/deps_impl:zlib_system.BUILD"),
|
||||||
allow_single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
"external_zlib": attr.label(
|
"external_zlib": attr.label(
|
||||||
|
|
Loading…
Reference in New Issue