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,12 @@ ] 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, - ) - overlay_script = repository_ctx.path( - repository_ctx.attr._overlay_script, - ) + 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") + python_bin = repository_ctx.which("python3") if not python_bin: # Windows typically just defines "python" as python3. The script itself @@ -61,7 +49,7 @@ cmd = [ python_bin, - overlay_script, + script_path, "--src", src_path, "--overlay", @@ -99,13 +87,9 @@ configure = True, attrs = { "_overlay_script": attr.label( - default = Label("//:overlay_directories.py"), + default = Label("//utils/bazel: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/http_archive/WORKSPACE b/utils/bazel/examples/http_archive/WORKSPACE --- a/utils/bazel/examples/http_archive/WORKSPACE +++ b/utils/bazel/examples/http_archive/WORKSPACE @@ -8,17 +8,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -SKYLIB_VERSION = "1.0.3" - -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), - ], -) - # Replace with the LLVM commit you want to use. LLVM_COMMIT = "09ac97ce350316b95b8cddb796d52f71b6f68296" @@ -27,30 +16,18 @@ # archive and make the build reproducible. LLVM_SHA256 = "2fb1aa06d12f8db349a27426cb0ced062987c5c2a75143c69f4284929e2750ff" -# FIXME: It shouldn't be necessary to use http_archive twice here. Caching -# should mean that this isn't too expensive though. - http_archive( - name = "llvm-project-raw", - build_file_content = "#empty", + name = "llvm-archive", + build_file_content = "# empty", sha256 = LLVM_SHA256, strip_prefix = "llvm-project-" + LLVM_COMMIT, urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)], ) -http_archive( - name = "llvm-bazel", - sha256 = LLVM_SHA256, - strip_prefix = "llvm-project-{}/utils/bazel".format(LLVM_COMMIT), - urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)], -) - -load("@llvm-bazel//:configure.bzl", "llvm_configure", "llvm_disable_optional_support_deps") +load("@llvm-archive//utils/bazel:configure.bzl", "llvm_configure") llvm_configure( name = "llvm-project", - src_path = ".", - src_workspace = "@llvm-project-raw//:WORKSPACE", ) # Disables optional dependencies for Support like zlib and terminfo. You may 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 @@ -6,32 +6,16 @@ workspace(name = "submodule_example") -SKYLIB_VERSION = "1.0.3" - -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), - ], +new_local_repository( + name = "llvm-archive", + build_file_content = "# empty", + # Or wherever your submodule is located. + path = "third_party/llvm-project", ) -# Or wherever your submodule is located. -SUBMODULE_PATH = "third_party/llvm-project" - -local_repository( - name = "llvm-bazel", - path = SUBMODULE_PATH + "/utils/bazel", -) +load("@llvm-archive//utils/bazel:configure.bzl", "llvm_configure") -load("@llvm-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