Skip to content

Commit

Permalink
Merge pull request #11510 from rabbitmq/mergify/bp/v3.12.x/pr-11485
Browse files Browse the repository at this point in the history
Use rules_elixir for rabbitmqctl (backport #11456) (backport #11485)
  • Loading branch information
michaelklishin authored Jun 22, 2024
2 parents f7da6c0 + 3362965 commit 8eaa545
Show file tree
Hide file tree
Showing 51 changed files with 845 additions and 1,449 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build --local_test_jobs=1

build --flag_alias=erlang_home=@rules_erlang//:erlang_home
build --flag_alias=erlang_version=@rules_erlang//:erlang_version
build --flag_alias=elixir_home=//:elixir_home
build --flag_alias=elixir_home=@rules_elixir//:elixir_home
build --flag_alias=test_build=//:enable_test_build

build --combined_report=lcov
Expand Down
9 changes: 1 addition & 8 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
load(
"@bazel_skylib//rules:common_settings.bzl",
"bool_flag",
"string_flag",
)
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("@bazel_gazelle//:def.bzl", "gazelle")
Expand All @@ -11,7 +10,7 @@ load("@rules_erlang//:dialyze.bzl", "DEFAULT_PLT_APPS", "plt")
load("@rules_erlang//:shell.bzl", "shell")
load("@rules_erlang//:erl_eval.bzl", "erl_eval")
load("@rules_erlang//gazelle:moduleindex.bzl", "moduleindex")
load("//bazel/elixir:iex_eval.bzl", "iex_eval")
load("@rules_elixir//:iex_eval.bzl", "iex_eval")
load(":rabbitmq_home.bzl", "rabbitmq_home")
load(":rabbitmq_run.bzl", "rabbitmq_run", "rabbitmq_run_command")
load(":rabbitmqctl.bzl", "rabbitmqctl")
Expand Down Expand Up @@ -124,12 +123,6 @@ config_setting(
},
)

string_flag(
name = "elixir_home",
build_setting_default = "",
visibility = ["//visibility:public"],
)

plt(
name = "base_plt",
apps = DEFAULT_PLT_APPS + [
Expand Down
16 changes: 13 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ bazel_dep(

bazel_dep(
name = "bazel_skylib",
version = "1.4.2",
version = "1.7.1",
)

bazel_dep(
name = "aspect_bazel_lib",
version = "2.5.3",
)

bazel_dep(
Expand Down Expand Up @@ -41,7 +46,12 @@ bazel_dep(

bazel_dep(
name = "rules_erlang",
version = "3.15.1",
version = "3.15.4",
)

bazel_dep(
name = "rules_elixir",
version = "1.0.0",
)

bazel_dep(
Expand Down Expand Up @@ -80,7 +90,7 @@ use_repo(
)

elixir_config = use_extension(
"//bazel/bzlmod:extensions.bzl",
"@rules_elixir//bzlmod:extensions.bzl",
"elixir_config",
)

Expand Down
7 changes: 1 addition & 6 deletions bazel/BUILD.ranch
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ filegroup(name = "private_hdrs")

filegroup(name = "public_hdrs")

filegroup(
name = "priv",
srcs = [
"ebin/ranch.appup", # keep
],
)
filegroup(name = "priv")

filegroup(
name = "licenses",
Expand Down
92 changes: 1 addition & 91 deletions bazel/bzlmod/extensions.bzl
Original file line number Diff line number Diff line change
@@ -1,99 +1,9 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(
":secondary_umbrella.bzl",
fetch_secondary_umbrella = "secondary_umbrella",
)
load(
"//bazel/repositories:elixir_config.bzl",
"INSTALLATION_TYPE_EXTERNAL",
"INSTALLATION_TYPE_INTERNAL",
_elixir_config_rule = "elixir_config",
)
load(
"//bazel/elixir:elixir.bzl",
"DEFAULT_ELIXIR_SHA256",
"DEFAULT_ELIXIR_VERSION",
)

def _elixir_config(ctx):
types = {}
versions = {}
urls = {}
strip_prefixs = {}
sha256s = {}
elixir_homes = {}

for mod in ctx.modules:
for elixir in mod.tags.external_elixir_from_path:
types[elixir.name] = INSTALLATION_TYPE_EXTERNAL
versions[elixir.name] = elixir.version
elixir_homes[elixir.name] = elixir.elixir_home

for elixir in mod.tags.internal_elixir_from_http_archive:
types[elixir.name] = INSTALLATION_TYPE_INTERNAL
versions[elixir.name] = elixir.version
urls[elixir.name] = elixir.url
strip_prefixs[elixir.name] = elixir.strip_prefix
sha256s[elixir.name] = elixir.sha256

for elixir in mod.tags.internal_elixir_from_github_release:
url = "https://github.com/elixir-lang/elixir/archive/refs/tags/v{}.tar.gz".format(
elixir.version,
)
strip_prefix = "elixir-{}".format(elixir.version)

types[elixir.name] = INSTALLATION_TYPE_INTERNAL
versions[elixir.name] = elixir.version
urls[elixir.name] = url
strip_prefixs[elixir.name] = strip_prefix
sha256s[elixir.name] = elixir.sha256

_elixir_config_rule(
name = "elixir_config",
rabbitmq_server_workspace = "@rabbitmq-server",
types = types,
versions = versions,
urls = urls,
strip_prefixs = strip_prefixs,
sha256s = sha256s,
elixir_homes = elixir_homes,
)

external_elixir_from_path = tag_class(attrs = {
"name": attr.string(),
"version": attr.string(),
"elixir_home": attr.string(),
})

internal_elixir_from_http_archive = tag_class(attrs = {
"name": attr.string(),
"version": attr.string(),
"url": attr.string(),
"strip_prefix": attr.string(),
"sha256": attr.string(),
})

internal_elixir_from_github_release = tag_class(attrs = {
"name": attr.string(
default = "internal",
),
"version": attr.string(
default = DEFAULT_ELIXIR_VERSION,
),
"sha256": attr.string(
default = DEFAULT_ELIXIR_SHA256,
),
})

elixir_config = module_extension(
implementation = _elixir_config,
tag_classes = {
"external_elixir_from_path": external_elixir_from_path,
"internal_elixir_from_http_archive": internal_elixir_from_http_archive,
"internal_elixir_from_github_release": internal_elixir_from_github_release,
},
)

def _secondary_umbrella(_ctx):
fetch_secondary_umbrella()
Expand Down
27 changes: 1 addition & 26 deletions bazel/elixir/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,26 +1 @@
load(
":elixir_as_app.bzl",
"elixir_as_app",
)

toolchain_type(
name = "toolchain_type",
visibility = ["//visibility:public"],
)

elixir_as_app(
name = "erlang_app",
visibility = ["//visibility:public"],
)

elixir_as_app(
name = "logger",
app = "logger",
visibility = ["//visibility:public"],
)

elixir_as_app(
name = "iex",
app = "iex",
visibility = ["//visibility:public"],
)
exports_files(["elixir_escript_main.exs"])
147 changes: 0 additions & 147 deletions bazel/elixir/elixir.bzl

This file was deleted.

Loading

0 comments on commit 8eaa545

Please sign in to comment.