Fetch cli prod deps via bazel or erlang.mk instead of mix

In preparation for offline bazel builds
This commit is contained in:
Rin Kuryloski 2023-03-14 14:27:47 +01:00
parent bb78f77aa4
commit eba1d531c9
8 changed files with 92 additions and 3 deletions

View File

@ -168,6 +168,13 @@ erlang_package.hex_package(
version = "3.2.0", version = "3.2.0",
) )
erlang_package.hex_package(
name = "csv",
build_file = "@rabbitmq-server//bazel:BUILD.csv",
sha256 = "54508938ac67e27966b10ef49606e3ad5995d665d7fc2688efb3eab1307c9079",
version = "2.4.1",
)
erlang_package.hex_package( erlang_package.hex_package(
name = "cuttlefish", name = "cuttlefish",
build_file = "@rabbitmq-server//bazel:BUILD.cuttlefish", build_file = "@rabbitmq-server//bazel:BUILD.cuttlefish",
@ -217,6 +224,13 @@ erlang_package.git_package(
repository = "michaelklishin/erlang-jose", repository = "michaelklishin/erlang-jose",
) )
erlang_package.hex_package(
name = "json",
build_file = "@rabbitmq-server//bazel:BUILD.json",
sha256 = "9abf218dbe4ea4fcb875e087d5f904ef263d012ee5ed21d46e9dbca63f053d16",
version = "1.4.1",
)
erlang_package.hex_package( erlang_package.hex_package(
name = "thoas", name = "thoas",
build_file = "@rabbitmq-server//bazel:BUILD.thoas", build_file = "@rabbitmq-server//bazel:BUILD.thoas",
@ -319,12 +333,14 @@ use_repo(
"cowboy", "cowboy",
"cowlib", "cowlib",
"credentials_obfuscation", "credentials_obfuscation",
"csv",
"cuttlefish", "cuttlefish",
"eetcd", "eetcd",
"gen_batch_server", "gen_batch_server",
"getopt", "getopt",
"gun", "gun",
"jose", "jose",
"json",
"observer_cli", "observer_cli",
"osiris", "osiris",
"prometheus", "prometheus",

10
bazel/BUILD.csv Normal file
View File

@ -0,0 +1,10 @@
filegroup(
name = "sources",
srcs = [
"mix.exs",
] + glob([
"LICENSE*",
"lib/**/*",
]),
visibility = ["//visibility:public"],
)
Can't render this file because it contains an unexpected character in line 2 and column 12.

10
bazel/BUILD.json Normal file
View File

@ -0,0 +1,10 @@
filegroup(
name = "sources",
srcs = [
"mix.exs",
] + glob([
"LICENSE*",
"lib/**/*",
]),
visibility = ["//visibility:public"],
)

View File

@ -23,6 +23,10 @@ rabbitmqctl(
"@observer_cli//:erlang_app", "@observer_cli//:erlang_app",
"@stdout_formatter//:erlang_app", "@stdout_formatter//:erlang_app",
], ],
source_deps = {
"@csv//:sources": "csv",
"@json//:sources": "json",
},
) )
select_file( select_file(
@ -124,6 +128,10 @@ rabbitmqctl_test(
"@observer_cli//:erlang_app", "@observer_cli//:erlang_app",
"@stdout_formatter//:erlang_app", "@stdout_formatter//:erlang_app",
], ],
source_deps = {
"@csv//:sources": "csv",
"@json//:sources": "json",
},
) )
test_suite( test_suite(

View File

@ -1,9 +1,12 @@
PROJECT = rabbitmq_cli PROJECT = rabbitmq_cli
BUILD_DEPS = rabbit_common BUILD_DEPS = rabbit_common
DEPS = observer_cli stdout_formatter DEPS = csv json observer_cli stdout_formatter
TEST_DEPS = amqp_client rabbit TEST_DEPS = amqp_client rabbit
dep_csv = hex 2.4.1
dep_json = hex 1.4.1
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk

View File

@ -138,8 +138,14 @@ defmodule RabbitMQCtl.MixfileBase do
is_bazel = System.get_env("IS_BAZEL") != nil is_bazel = System.get_env("IS_BAZEL") != nil
[ [
{:json, "1.4.1"}, {
{:csv, "2.4.1"}, :json,
path: Path.join(deps_dir, "json")
},
{
:csv,
path: Path.join(deps_dir, "csv")
},
{ {
:stdout_formatter, :stdout_formatter,
path: Path.join(deps_dir, "stdout_formatter"), path: Path.join(deps_dir, "stdout_formatter"),

View File

@ -68,6 +68,21 @@ def _impl(ctx):
deps_dir_files = deps_dir_contents(ctx, deps, deps_dir) deps_dir_files = deps_dir_contents(ctx, deps, deps_dir)
for dep, app_name in ctx.attr.source_deps.items():
for src in dep.files.to_list():
if not src.is_directory:
rp = additional_file_dest_relative_path(dep.label, src)
f = ctx.actions.declare_file(path_join(
deps_dir,
app_name,
rp,
))
ctx.actions.symlink(
output = f,
target_file = src,
)
deps_dir_files.append(f)
package_dir = path_join( package_dir = path_join(
ctx.label.workspace_root, ctx.label.workspace_root,
ctx.label.package, ctx.label.package,
@ -203,6 +218,7 @@ rabbitmqctl_private = rule(
"deps": attr.label_list( "deps": attr.label_list(
providers = [ErlangAppInfo], providers = [ErlangAppInfo],
), ),
"source_deps": attr.label_keyed_string_dict(),
}, },
toolchains = [ toolchains = [
"//bazel/elixir:toolchain_type", "//bazel/elixir:toolchain_type",

View File

@ -7,6 +7,10 @@ load(
"path_join", "path_join",
"windows_path", "windows_path",
) )
load(
"@rules_erlang//private:util.bzl",
"additional_file_dest_relative_path",
)
load( load(
"//bazel/elixir:elixir_toolchain.bzl", "//bazel/elixir:elixir_toolchain.bzl",
"elixir_dirs", "elixir_dirs",
@ -30,6 +34,21 @@ def _impl(ctx):
deps_dir, deps_dir,
) )
for dep, app_name in ctx.attr.source_deps.items():
for src in dep.files.to_list():
if not src.is_directory:
rp = additional_file_dest_relative_path(dep.label, src)
f = ctx.actions.declare_file(path_join(
deps_dir,
app_name,
rp,
))
ctx.actions.symlink(
output = f,
target_file = src,
)
deps_dir_files.append(f)
package_dir = path_join( package_dir = path_join(
ctx.label.workspace_root, ctx.label.workspace_root,
ctx.label.package, ctx.label.package,
@ -189,6 +208,7 @@ rabbitmqctl_private_test = rule(
"srcs": attr.label_list(allow_files = [".ex", ".exs"]), "srcs": attr.label_list(allow_files = [".ex", ".exs"]),
"data": attr.label_list(allow_files = True), "data": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = [ErlangAppInfo]), "deps": attr.label_list(providers = [ErlangAppInfo]),
"source_deps": attr.label_keyed_string_dict(),
"rabbitmq_run": attr.label( "rabbitmq_run": attr.label(
executable = True, executable = True,
cfg = "target", cfg = "target",