diff --git a/utils/bazel/WORKSPACE b/utils/bazel/WORKSPACE --- a/utils/bazel/WORKSPACE +++ b/utils/bazel/WORKSPACE @@ -16,15 +16,17 @@ ], ) -load(":configure.bzl", "llvm_configure") - -llvm_configure( - name = "llvm-project", - overlay_path = "llvm-project-overlay", - src_path = "../..", +new_local_repository( + name = "llvm-raw", + path = "../../", + build_file_content = "# empty", ) -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( llvm_terminfo_from_env, @@ -34,7 +36,7 @@ maybe( http_archive, name = "zlib", - build_file = "//third_party_build:zlib.BUILD", + build_file = "@llvm-raw//utils/bazel/third_party_build:zlib.BUILD", sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", strip_prefix = "zlib-1.2.11", urls = [ @@ -43,7 +45,7 @@ ], ) -load(":zlib.bzl", "llvm_zlib_from_env") +load("@llvm-raw//utils/bazel:zlib.bzl", "llvm_zlib_from_env") maybe( llvm_zlib_from_env, @@ -54,7 +56,7 @@ maybe( http_archive, 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", strip_prefix = "Vulkan-Headers-9bd3f561bcee3f01d22912de10bb07ce4e23d378", urls = [ @@ -62,7 +64,7 @@ ], ) -load(":vulkan_sdk.bzl", "vulkan_sdk_setup") +load("@llvm-raw//utils/bazel:vulkan_sdk.bzl", "vulkan_sdk_setup") maybe( vulkan_sdk_setup, diff --git a/utils/bazel/configure.bzl b/utils/bazel/configure.bzl --- a/utils/bazel/configure.bzl +++ b/utils/bazel/configure.bzl @@ -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") @@ -33,23 +32,11 @@ ] 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 @@ -61,7 +48,7 @@ cmd = [ python_bin, - overlay_script, + script_path, "--src", src_path, "--overlay", @@ -98,14 +85,6 @@ 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), }, ) diff --git a/utils/bazel/examples/submodule/WORKSPACE b/utils/bazel/examples/submodule/WORKSPACE --- a/utils/bazel/examples/submodule/WORKSPACE +++ b/utils/bazel/examples/submodule/WORKSPACE @@ -17,21 +17,16 @@ ], ) -# Or wherever your submodule is located. -SUBMODULE_PATH = "third_party/llvm-project" - -local_repository( - name = "llvm-bazel", - path = SUBMODULE_PATH + "/utils/bazel", +new_local_repository( + name = "llvm-raw", + build_file_content = "# empty", + # Or wherever your submodule is located. + path = "third_party/llvm-project", ) -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( - name = "llvm-project", - src_path = SUBMODULE_PATH, - src_workspace = "@submodule_example//:WORKSPACE", -) +llvm_configure(name = "llvm-project") # Disables optional dependencies for Support like zlib and terminfo. You may # instead want to configure them using the macros in the corresponding bzl diff --git a/utils/bazel/terminfo.bzl b/utils/bazel/terminfo.bzl --- a/utils/bazel/terminfo.bzl +++ b/utils/bazel/terminfo.bzl @@ -27,7 +27,7 @@ _terminfo_disable_attrs = { "_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, ), } @@ -147,11 +147,11 @@ _terminfo_system_attrs = _merge_attrs([_terminfo_disable_attrs, { "_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, ), "_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, ), "candidate_system_linkopts": attr.string_list( diff --git a/utils/bazel/zlib.bzl b/utils/bazel/zlib.bzl --- a/utils/bazel/zlib.bzl +++ b/utils/bazel/zlib.bzl @@ -33,7 +33,7 @@ implementation = _llvm_zlib_external_impl, attrs = { "_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, ), "external_zlib": attr.string( @@ -56,7 +56,7 @@ implementation = _llvm_zlib_system_impl, attrs = { "_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, ), }, @@ -73,7 +73,7 @@ implementation = _llvm_zlib_disable_impl, attrs = { "_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, ), }, @@ -92,15 +92,15 @@ implementation = _llvm_zlib_from_env_impl, attrs = { "_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, ), "_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, ), "_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, ), "external_zlib": attr.label(