From b67a3f9a0ad624df126a5b21d94cbb7fed529b95 Mon Sep 17 00:00:00 2001 From: Tarry Singh Date: Wed, 29 Oct 2025 17:43:22 +0000 Subject: [PATCH] workspace: switch to libxev from Bazel Central Registry, completing migration away from custom registry --- MODULE.bazel | 2 +- MODULE.bazel.lock | 8 +- async/BUILD.bazel | 2 +- .../20240829.0-fc1db29/overlay/BUILD.bazel | 2 +- third_party/zls/zls.bzl | 187 ------------------ 5 files changed, 7 insertions(+), 194 deletions(-) delete mode 100644 third_party/zls/zls.bzl diff --git a/MODULE.bazel b/MODULE.bazel index 1b638ce..49f7507 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,7 +6,7 @@ bazel_dep(name = "abseil-cpp", version = "20250814.0") bazel_dep(name = "aspect_bazel_lib", version = "2.20.0") bazel_dep(name = "aspect_rules_py", version = "1.6.3") bazel_dep(name = "bazel_skylib", version = "1.8.1") -bazel_dep(name = "libxev", version = "20251010.0-9f785d2") +bazel_dep(name = "libxev", version = "0.0.0-20251014.0-9f785d2") bazel_dep(name = "patchelf", version = "0.18.0") bazel_dep(name = "pcre2", version = "10.45") bazel_dep(name = "platforms", version = "1.0.0") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index e5f0dd8..3bec3fe 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -69,6 +69,7 @@ "https://bazel-registry.zml.ai/modules/jsoncpp/1.9.5/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/jsoncpp/1.9.6/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/libpfm/4.11.0/MODULE.bazel": "not found", + "https://bazel-registry.zml.ai/modules/libxev/0.0.0-20251014.0-9f785d2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/nlohmann_json/3.6.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/package_metadata/0.0.2/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/patchelf/0.18.0/MODULE.bazel": "not found", @@ -170,7 +171,6 @@ "https://bazel-registry.zml.ai/modules/rules_shell/0.4.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_swift/1.16.0/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/rules_swift/2.1.1/MODULE.bazel": "not found", - "https://bazel-registry.zml.ai/modules/rules_zig/0.12.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.1/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.3/MODULE.bazel": "not found", "https://bazel-registry.zml.ai/modules/stardoc/0.5.4/MODULE.bazel": "not found", @@ -272,6 +272,8 @@ "https://bcr.bazel.build/modules/jsoncpp/1.9.6/MODULE.bazel": "2f8d20d3b7d54143213c4dfc3d98225c42de7d666011528dc8fe91591e2e17b0", "https://bcr.bazel.build/modules/jsoncpp/1.9.6/source.json": "a04756d367a2126c3541682864ecec52f92cdee80a35735a3cb249ce015ca000", "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", + "https://bcr.bazel.build/modules/libxev/0.0.0-20251014.0-9f785d2/MODULE.bazel": "d8bda6be48f8c0613d3393cfe15143467a7ee17d7e702fa15719ddc3e9fb646a", + "https://bcr.bazel.build/modules/libxev/0.0.0-20251014.0-9f785d2/source.json": "52ac2605138fd00de1413a13b2b8c5ceb4adc0d8e052133db888400f6768746f", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", "https://bcr.bazel.build/modules/package_metadata/0.0.2/MODULE.bazel": "fb8d25550742674d63d7b250063d4580ca530499f045d70748b1b142081ebb92", @@ -396,8 +398,6 @@ "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", "https://bcr.bazel.build/modules/rules_swift/2.1.1/MODULE.bazel": "494900a80f944fc7aa61500c2073d9729dff0b764f0e89b824eb746959bc1046", "https://bcr.bazel.build/modules/rules_swift/2.1.1/source.json": "40fc69dfaac64deddbb75bd99cdac55f4427d9ca0afbe408576a65428427a186", - "https://bcr.bazel.build/modules/rules_zig/0.12.1/MODULE.bazel": "5953094b681c212eebe3dd4275809c52b9177aeaa058d8f1bff433822c0dcd01", - "https://bcr.bazel.build/modules/rules_zig/0.12.1/source.json": "d880cdc3473bfcf172c9aad9292e856430496e198d805539bb8be98e79f58a7c", "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", "https://bcr.bazel.build/modules/stardoc/0.5.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", @@ -2811,7 +2811,7 @@ "@@rules_zig+//zig:extensions.bzl%zig": { "general": { "bzlTransitiveDigest": "wV3euhBZSI0D2ZlqbY1YW592mghFY88d9H6zBMQRaJY=", - "usagesDigest": "T0xLzuDAWCJjFcphcIcT31t1HM/Yg7RxtfOUb+XmxTw=", + "usagesDigest": "FR3I3Uy7g7MHBta/AuDtKPMdikDVo0hgQZNdLunZDX4=", "recordedFileInputs": { "@@//bazel/zig_index.json": "42ea73420b15741770d5d8d0ded1311a2dfda1f963f0802dea3418f6e060ffef", "@@rules_zig+//zig/private/versions.json": "6eb85ebaee72c4e6fbc82d8ad73f69e0899d839b70a7e19caa792ab6a5fa0c36" diff --git a/async/BUILD.bazel b/async/BUILD.bazel index 82fc096..647ac4d 100644 --- a/async/BUILD.bazel +++ b/async/BUILD.bazel @@ -16,7 +16,7 @@ zig_library( visibility = ["//visibility:public"], deps = [ "//stdx", - "@libxev//:xev", + "@libxev", ], ) diff --git a/third_party/modules/zigcoro/20240829.0-fc1db29/overlay/BUILD.bazel b/third_party/modules/zigcoro/20240829.0-fc1db29/overlay/BUILD.bazel index 29227e9..2aa934c 100644 --- a/third_party/modules/zigcoro/20240829.0-fc1db29/overlay/BUILD.bazel +++ b/third_party/modules/zigcoro/20240829.0-fc1db29/overlay/BUILD.bazel @@ -24,6 +24,6 @@ zig_library( visibility = ["//visibility:public"], deps = [ ":libcoro_options", - "@libxev//:xev", + "@libxev", ], ) diff --git a/third_party/zls/zls.bzl b/third_party/zls/zls.bzl deleted file mode 100644 index 9e28da6..0000000 --- a/third_party/zls/zls.bzl +++ /dev/null @@ -1,187 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -_VERSION = "0.15.0" - -_ARCH = { - "x86_64-linux": struct( - sha256 = "508bfe3fd637d2a02f07f3fc7da8900351f407116b03685c5dae26b4f01a30de", - exec_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", - ], - ), - "x86_64-macos": struct( - sha256 = "46c31838bfef5adcc7fee82428c3ec2b9abbfae38242639afea5f242ee133d93", - exec_compatible_with = [ - "@platforms//os:macos", - "@platforms//cpu:x86_64", - ], - ), - "aarch64-macos": struct( - sha256 = "76c7a23190f67e67970024065f689c2c49b3c7b0fc16876fb24ef199fb05fc2a", - exec_compatible_with = [ - "@platforms//os:macos", - "@platforms//cpu:aarch64", - ], - ), -} - -ZlsInfo = provider( - fields = { - "bin": "ZLS binary", - }, -) - -def _zls_toolchain_impl(ctx): - default = DefaultInfo( - files = depset(direct = [ctx.file.zls]), - ) - zlsinfo = ZlsInfo( - bin = ctx.file.zls, - ) - toolchain_info = platform_common.ToolchainInfo( - default = default, - zlsinfo = zlsinfo, - ) - - return [ - default, - zlsinfo, - toolchain_info, - ] - -zls_toolchain = rule( - implementation = _zls_toolchain_impl, - attrs = { - "zls": attr.label( - executable = True, - allow_single_file = True, - cfg = "exec", - ), - }, -) - -def _repo_impl(mctx): - for arch, config in _ARCH.items(): - http_archive( - name = "zls_{}".format(arch), - url = "https://github.com/zigtools/zls/releases/download/{version}/zls-{arch}.tar.xz".format( - version = _VERSION, - arch = arch, - ), - sha256 = config.sha256, - build_file_content = """\ -load("@zml//third_party/zls:zls.bzl", "zls_toolchain") -zls_toolchain(name = "toolchain", zls = "zls") -""", - ) - return mctx.extension_metadata( - reproducible = True, - root_module_direct_deps = "all", - root_module_direct_dev_deps = [], - ) - -repo = module_extension( - implementation = _repo_impl, -) - -def targets(): - for arch, config in _ARCH.items(): - native.toolchain( - name = "toolchain_{}".format(arch), - exec_compatible_with = config.exec_compatible_with, - target_compatible_with = config.exec_compatible_with, - toolchain = "@zls_{}//:toolchain".format(arch), - toolchain_type = "@zml//third_party/zls:toolchain_type", - ) - -def build_runner_tpl(target): - return """\ -const std = @import("std"); - -pub fn main() !void {{ - var gpa: std.heap.GeneralPurposeAllocator(.{{}}) = .{{}}; - defer _ = gpa.deinit(); - var arena_ = std.heap.ArenaAllocator.init(gpa.allocator()); - defer arena_.deinit(); - const arena = arena_.allocator(); - - const build_workspace_directory = try std.process.getEnvVarOwned(arena, "BUILD_WORKSPACE_DIRECTORY"); - var child = std.process.Child.init(&.{{ - "bazel", - "run", - {target}, - }}, arena); - child.stdin_behavior = .Ignore; - child.stdout_behavior = .Inherit; - child.stderr_behavior = .Inherit; - child.cwd = build_workspace_directory; - _ = try child.spawnAndWait(); -}} -""".format(target = repr(target)) - -def runner_tpl(zls, zig_exe_path, zig_lib_path, zig_cache, build_runner): - return """\ -#!/bin/bash -set -eo pipefail - -json_config="$(mktemp)" -cat < ${{json_config}} -{{ - "build_runner_path": "$(realpath {build_runner})", - "global_cache_path": "$(realpath {zig_cache})", - "zig_exe_path": "$(realpath {zig_exe_path})", - "zig_lib_path": "$(realpath {zig_lib_path})" -}} -EOF - -exec {zls} "${{@}}" --config-path "${{json_config}}" -""".format( - zig_lib_path = zig_lib_path, - zig_exe_path = zig_exe_path, - zig_cache = zig_cache, - zls = zls, - build_runner = build_runner, - ) - -def _zls_runner_impl(ctx): - zigtoolchaininfo = ctx.toolchains["@rules_zig//zig:toolchain_type"].zigtoolchaininfo - zlsinfo = ctx.toolchains["@zml//third_party/zls:toolchain_type"].zlsinfo - - build_runner = ctx.actions.declare_file(ctx.label.name + ".build_runner.zig") - ctx.actions.write(build_runner, build_runner_tpl(str(ctx.attr.target.label))) - - zls_runner = ctx.actions.declare_file(ctx.label.name + ".zls_runner.sh") - ctx.actions.write(zls_runner, runner_tpl( - zig_cache = zigtoolchaininfo.zig_cache, - zig_exe_path = zigtoolchaininfo.zig_exe.short_path, - zig_lib_path = zigtoolchaininfo.zig_lib.short_path, - zls = zlsinfo.bin.short_path, - build_runner = build_runner.short_path, - )) - - return [ - DefaultInfo( - files = depset([zls_runner]), - executable = zls_runner, - runfiles = ctx.runfiles( - files = [ - build_runner, - zlsinfo.bin, - ], - transitive_files = zigtoolchaininfo.zig_files, - ), - ), - ] - -zls_runner = rule( - implementation = _zls_runner_impl, - attrs = { - "target": attr.label(mandatory = True, executable = True, cfg = "exec"), - }, - executable = True, - toolchains = [ - "@rules_zig//zig:toolchain_type", - "@zml//third_party/zls:toolchain_type", - ], -)