Merge pull request #11537 from rabbitmq/mergify/bp/v3.12.x/pr-11511

Use the latest rules_erlang & rules_elixir (backport #11506) (backport #11511)
This commit is contained in:
Michael Klishin 2024-06-24 06:32:36 -04:00 committed by GitHub
commit aeef4dc09d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 112 deletions

View File

@ -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(

View File

@ -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",
),
},
)

View File

@ -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",