From 3465eef2cd986051889ea77bebdae832e46fe052 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Thu, 20 Jun 2024 11:13:02 +0200 Subject: [PATCH] Use the latest rules_erlang & rules_elixir --- MODULE.bazel | 4 +- bazel/elixir/elixir_bytecode.bzl | 106 ------------------------------- deps/rabbitmq_cli/BUILD.bazel | 5 +- 3 files changed, 3 insertions(+), 112 deletions(-) delete mode 100644 bazel/elixir/elixir_bytecode.bzl diff --git a/MODULE.bazel b/MODULE.bazel index 253088585b38..a0d1687e1a95 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -46,12 +46,12 @@ bazel_dep( bazel_dep( name = "rules_erlang", - version = "3.15.4", + version = "3.16.0", ) bazel_dep( name = "rules_elixir", - version = "1.0.0", + version = "1.1.0", ) bazel_dep( diff --git a/bazel/elixir/elixir_bytecode.bzl b/bazel/elixir/elixir_bytecode.bzl deleted file mode 100644 index c4b3d306f14b..000000000000 --- a/bazel/elixir/elixir_bytecode.bzl +++ /dev/null @@ -1,106 +0,0 @@ -load("@bazel_skylib//lib:shell.bzl", "shell") -load("@rules_erlang//:erlang_app_info.bzl", "ErlangAppInfo", "flat_deps") -load("@rules_erlang//:util.bzl", "path_join") -load("@rules_erlang//private:util.bzl", "erl_libs_contents") - -def _impl(ctx): - ebin = ctx.actions.declare_directory(ctx.attr.dest) - - erl_libs_dir = ctx.label.name + "_deps" - - erl_libs_files = erl_libs_contents( - ctx, - target_info = None, - headers = True, - dir = erl_libs_dir, - deps = flat_deps(ctx.attr.deps), - ez_deps = ctx.files.ez_deps, - expand_ezs = True, - ) - - erl_libs_path = "" - if len(erl_libs_files) > 0: - erl_libs_path = path_join( - ctx.bin_dir.path, - ctx.label.workspace_root, - ctx.label.package, - erl_libs_dir, - ) - - env = "\n".join([ - "export {}={}".format(k, v) - for k, v in ctx.attr.env.items() - ]) - - script = """set -euo pipefail - -if [ -n "{erl_libs_path}" ]; then - export ERL_LIBS={erl_libs_path} -fi - -{env} - -{setup} -set -x -{elixirc} \\ - -o {out_dir} \\ - {elixirc_opts} \\ - {srcs} -""".format( - erl_libs_path = erl_libs_path, - env = env, - setup = ctx.attr.setup, - elixirc = ctx.executable._elixirc.path, - out_dir = ebin.path, - elixirc_opts = " ".join([shell.quote(opt) for opt in ctx.attr.elixirc_opts]), - srcs = " ".join([f.path for f in ctx.files.srcs]), - ) - - compiler_runfiles = ctx.attr._elixirc[DefaultInfo].default_runfiles - - inputs = depset( - direct = ctx.files.srcs + erl_libs_files, - transitive = [ - compiler_runfiles.files, - ], - ) - - ctx.actions.run_shell( - inputs = inputs, - outputs = [ebin], - command = script, - mnemonic = "ELIXIRC", - tools = [ctx.executable._elixirc], - ) - - return [ - DefaultInfo( - files = depset([ebin]), - ) - ] - -elixir_bytecode = rule( - implementation = _impl, - attrs = { - "srcs": attr.label_list( - allow_files = [".ex"], - ), - "elixirc_opts": attr.string_list(), - "env": attr.string_dict(), - "deps": attr.label_list( - providers = [ErlangAppInfo], - ), - "ez_deps": attr.label_list( - allow_files = [".ez"], - ), - "dest": attr.string( - mandatory = True, - ), - "setup": attr.string(), - "_elixirc": attr.label( - default = Label("@rules_elixir//tools:elixirc_wrapper"), - executable = True, - cfg = "target", - ), - }, -) diff --git a/deps/rabbitmq_cli/BUILD.bazel b/deps/rabbitmq_cli/BUILD.bazel index 136beb0f59a0..69ac9bffdf1c 100644 --- a/deps/rabbitmq_cli/BUILD.bazel +++ b/deps/rabbitmq_cli/BUILD.bazel @@ -1,4 +1,5 @@ load("@rules_elixir//:ex_unit_test.bzl", "ex_unit_test") +load("@rules_elixir//private:elixir_bytecode.bzl", "elixir_bytecode") load( "@rules_elixir//private:elixir_ebin_dir.bzl", "elixir_ebin_dir", @@ -20,10 +21,6 @@ load( ) load("//:rabbitmq_home.bzl", "rabbitmq_home") load("//:rabbitmq_run.bzl", "rabbitmq_run") -load( - "//bazel/elixir:elixir_bytecode.bzl", - "elixir_bytecode", -) load( "//bazel/elixir:elixir_escript_main.bzl", "elixir_escript_main",