From 2fd155e55d90be321269347d966d88cfdfc45359 Mon Sep 17 00:00:00 2001 From: Philip Kuryloski Date: Wed, 15 Jun 2022 09:52:08 +0200 Subject: [PATCH] Fixup the bazel build when used without bzlmod As currently we do not use bzlmod when building on Windows --- BUILD.bats | 5 ++++- BUILD.inet_tcp_proxy | 4 ++-- BUILD.jose | 10 ++++++++++ BUILD.ranch | 20 +++++++++++++------- BUILD.trust_store_http | 2 +- MODULE.bazel | 7 +++---- bazel/elixir/elixir.bzl | 6 +++--- workspace_helpers.bzl | 11 +++++++++++ 8 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 BUILD.jose diff --git a/BUILD.bats b/BUILD.bats index ed50b3c253..1fe48bc154 100644 --- a/BUILD.bats +++ b/BUILD.bats @@ -1,5 +1,8 @@ filegroup( name = "bin_dir", - srcs = glob(["bin/**/*", "libexec/**/*"]), + srcs = glob([ + "bin/**/*", + "libexec/**/*", + ]), visibility = ["//visibility:public"], ) diff --git a/BUILD.inet_tcp_proxy b/BUILD.inet_tcp_proxy index f7470869c8..eab7e2e2d5 100644 --- a/BUILD.inet_tcp_proxy +++ b/BUILD.inet_tcp_proxy @@ -1,8 +1,8 @@ load("@rules_erlang//:erlang_app.bzl", "erlang_app") erlang_app( - app_name = "inet_tcp_proxy_dist", - app_version = "0.1.0", app_description = "Erlang distribution proxy to simulate network failures", app_module = "inet_tcp_proxy_dist_app", + app_name = "inet_tcp_proxy_dist", + app_version = "0.1.0", ) diff --git a/BUILD.jose b/BUILD.jose new file mode 100644 index 0000000000..9321fd00bc --- /dev/null +++ b/BUILD.jose @@ -0,0 +1,10 @@ +load("@rules_erlang//:erlang_app.bzl", "erlang_app") + +erlang_app( + app_name = "jose", + erlc_opts = [ + "+deterministic", + "+debug_info", + ], + stamp = 0, +) diff --git a/BUILD.ranch b/BUILD.ranch index 5baffd6385..55f02b0a7d 100644 --- a/BUILD.ranch +++ b/BUILD.ranch @@ -1,14 +1,17 @@ load("@rules_erlang//:app_file.bzl", "app_file") load("@rules_erlang//:erlang_app_info.bzl", "erlang_app_info") load("@rules_erlang//:erlang_app.bzl", "DEFAULT_ERLC_OPTS") -load("@rules_erlang//:erlc.bzl", "erlc") +load("@rules_erlang//:erlang_bytecode.bzl", "erlang_bytecode") -erlc( +erlang_bytecode( name = "beam_files", - hdrs = glob(["include/**/*.hrl", "src/**/*.hrl"]), srcs = glob(["src/**/*.erl"]), - erlc_opts = DEFAULT_ERLC_OPTS, + hdrs = glob([ + "include/**/*.hrl", + "src/**/*.hrl", + ]), dest = "ebin", + erlc_opts = DEFAULT_ERLC_OPTS, ) genrule( @@ -27,9 +30,12 @@ app_file( erlang_app_info( name = "erlang_app", - app_name = "ranch", - app = ":app_file", hdrs = glob(["include/**/*.hrl"]), - beam = [":beam_files", ":appup"], + app = ":app_file", + app_name = "ranch", + beam = [ + ":beam_files", + ":appup", + ], visibility = ["//visibility:public"], ) diff --git a/BUILD.trust_store_http b/BUILD.trust_store_http index efe4f97add..7e0f7869bd 100644 --- a/BUILD.trust_store_http +++ b/BUILD.trust_store_http @@ -1,9 +1,9 @@ load("@rules_erlang//:erlang_app.bzl", "erlang_app") erlang_app( - app_name = "trust_store_http", app_description = "Trust store HTTP server", app_module = "trust_store_http_app", + app_name = "trust_store_http", app_version = "1.0.0", extra_apps = [ "ssl", diff --git a/MODULE.bazel b/MODULE.bazel index fd53a01423..eac03c90d1 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -137,14 +137,13 @@ erlang_package.hex_package( erlang_package.git_package( repository = "rabbitmq/osiris", branch = "main", - patch_cmds = [""" -VERSION=$(git rev-parse HEAD) + patch_cmds = ["""VERSION=$(git rev-parse HEAD) echo "Injecting ${VERSION} into Makefile..." sed -i"_orig" -E '/PROJECT_VERSION/ s/[0-9]+\\.[0-9]+\\.[0-9]+/'${VERSION}'/' Makefile echo "Injecting ${VERSION} into BUILD.bazel..." sed -i"_orig" -E '/VERSION/ s/[0-9]+\\.[0-9]+\\.[0-9]+/'${VERSION}'/' BUILD.bazel - -sed -i"_orig2" -E 's/ct_sharded\\.bzl/ct.bzl/' BUILD.bazel +""", +"""sed -i"_orig2" -E 's/ct_sharded\\.bzl/ct.bzl/' BUILD.bazel """], ) diff --git a/bazel/elixir/elixir.bzl b/bazel/elixir/elixir.bzl index b533c83e64..8d6fbb25d1 100644 --- a/bazel/elixir/elixir.bzl +++ b/bazel/elixir/elixir.bzl @@ -32,7 +32,7 @@ def elixir_toolchain_external(): elixir_constraint, ], toolchain = ":elixir_external", - toolchain_type = Label("@rabbitmq-server//bazel/elixir:toolchain_type"), + toolchain_type = Label("//bazel/elixir:toolchain_type"), visibility = ["//visibility:public"], ) @@ -69,7 +69,7 @@ def elixir_toolchain_from_http_archive( elixir_constraint, ], toolchain = ":elixir{}".format(name_suffix), - toolchain_type = Label("@rabbitmq-server//bazel/elixir:toolchain_type"), + toolchain_type = Label("//bazel/elixir:toolchain_type"), visibility = ["//visibility:public"], ) @@ -78,7 +78,7 @@ def elixir_toolchain_from_github_release( version = None, sha256 = None): [major, minor, patch] = version.split(".") - elixir_constraint = Label("@rabbitmq-server//bazel/platforms:elixir_{}_{}".format(major, minor)) + elixir_constraint = Label("//bazel/platforms:elixir_{}_{}".format(major, minor)) url = "https://github.com/elixir-lang/elixir/archive/refs/tags/v{}.tar.gz".format(version) elixir_toolchain_from_http_archive( name_suffix = name_suffix, diff --git a/workspace_helpers.bzl b/workspace_helpers.bzl index 13f4be02f9..10a3efd4b9 100644 --- a/workspace_helpers.bzl +++ b/workspace_helpers.bzl @@ -131,6 +131,7 @@ erlang_app( ref = "2b1d66b5f4fbe33cb198149a8cb23895a2c877ea", version = "2b1d66b5f4fbe33cb198149a8cb23895a2c877ea", sha256 = "7816f39d00655f2605cfac180755e97e268dba86c2f71037998ff63792ca727b", + build_file = rabbitmq_workspace + "//:BUILD.jose", ) hex_pm_erlang_app( @@ -154,6 +155,16 @@ erlang_app( name = "osiris", branch = "main", remote = "https://github.com/rabbitmq/osiris.git", + patch_cmds = [ + """VERSION=$(git rev-parse HEAD) +echo "Injecting ${VERSION} into Makefile..." +sed -i"_orig" -E '/PROJECT_VERSION/ s/[0-9]+\\.[0-9]+\\.[0-9]+/'${VERSION}'/' Makefile +echo "Injecting ${VERSION} into BUILD.bazel..." +sed -i"_orig" -E '/VERSION/ s/[0-9]+\\.[0-9]+\\.[0-9]+/'${VERSION}'/' BUILD.bazel +""", + """sed -i"_orig2" -E 's/ct_sharded\\.bzl/ct.bzl/' BUILD.bazel +""", + ], ) hex_pm_erlang_app(