Skip to content

Commit

Permalink
Adjust macros in dist.bzl to be used more generally
Browse files Browse the repository at this point in the history
and not just at the root of this repo
  • Loading branch information
HoloRin committed Jul 11, 2022
1 parent 8114efe commit 3f3df48
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 48 deletions.
39 changes: 38 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load(
"@bazel_skylib//rules:common_settings.bzl",
"string_flag",
)
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_erlang//:dialyze.bzl", "plt")
load("@rules_erlang//:shell.bzl", "shell")
load("@rules_erlang//:erl_eval.bzl", "erl_eval")
Expand Down Expand Up @@ -108,9 +109,45 @@ iex_eval(
expression = """File.write!(System.get_env("OUTS"), System.version()); System.halt()""",
)

filegroup(
name = "root-licenses",
srcs = glob(
["LICENSE*"],
exclude = [
"LICENSE.md",
"LICENSE.txt",
],
),
visibility = ["//visibility:public"],
)

pkg_tar(
name = "scripts-tar",
srcs = [
"scripts/bash_autocomplete.sh",
"scripts/rabbitmq-script-wrapper",
"scripts/rabbitmqctl-autocomplete.sh",
"scripts/zsh_autocomplete.sh",
],
package_dir = "scripts",
visibility = ["//visibility:public"],
)

pkg_tar(
name = "release-notes-tar",
srcs = glob([
"release-notes/*.md",
"release-notes/*.txt",
]),
package_dir = "release-notes",
visibility = ["//visibility:public"],
)

package_generic_unix(PLUGINS)

source_archive(PLUGINS + ["//deps/rabbitmq_cli:rabbitmqctl"])
source_archive(PLUGINS + [
"//deps/rabbitmq_cli:rabbitmqctl",
])

genrule(
name = "test-logs",
Expand Down
65 changes: 18 additions & 47 deletions dist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -229,48 +229,24 @@ def versioned_plugins_dir(**kwargs):
**kwargs
)

# This macro must be invoked from the top level BUILD.bazel of rabbitmq-server
def package_generic_unix(plugins):
def package_generic_unix(
plugins,
rabbitmq_workspace = "@",
package_dir = "rabbitmq_server-{}".format(APP_VERSION)):
collect_licenses(
name = "licenses",
srcs = native.glob(
["LICENSE*"],
exclude = [
"LICENSE.md",
"LICENSE.txt",
],
),
deps = plugins,
)

pkg_tar(
name = "license-files",
srcs = [
":licenses",
"//deps/rabbit:INSTALL",
rabbitmq_workspace + "//:root-licenses",
],
visibility = ["//visibility:public"],
deps = plugins,
)

pkg_tar(
name = "scripts",
name = "license-files-tar",
srcs = [
"scripts/bash_autocomplete.sh",
"scripts/rabbitmq-script-wrapper",
"scripts/rabbitmqctl-autocomplete.sh",
"scripts/zsh_autocomplete.sh",
":licenses",
rabbitmq_workspace + "//deps/rabbit:INSTALL",
],
package_dir = "scripts",
visibility = ["//visibility:public"],
)

pkg_tar(
name = "release-notes",
srcs = native.glob([
"release-notes/*.md",
"release-notes/*.txt",
]),
package_dir = "release-notes",
visibility = ["//visibility:public"],
)

Expand All @@ -297,31 +273,26 @@ def package_generic_unix(plugins):
srcs = [
":scripts-and-escripts",
],
package_dir = "rabbitmq_server-{}".format(APP_VERSION),
package_dir = package_dir,
strip_prefix = "scripts-and-escripts",
visibility = ["//visibility:public"],
deps = [
":plugins-tar",
":license-files",
":release-notes",
":scripts",
"//deps/rabbit:manpages-dir",
":license-files-tar",
rabbitmq_workspace + "//:release-notes-tar",
rabbitmq_workspace + "//:scripts-tar",
rabbitmq_workspace + "//deps/rabbit:manpages-dir",
],
)

# This macro must be invoked from the top level BUILD.bazel of rabbitmq-server
def source_archive(plugins):
def source_archive(
plugins,
rabbitmq_workspace = "@"):
source_tree(
name = "source-tree",
deps = plugins,
)

native.filegroup(
name = "root-licenses",
srcs = native.glob(["LICENSE*"]),
visibility = ["//visibility:public"],
)

pkg_tar(
name = "deps-archive",
srcs = [
Expand All @@ -343,7 +314,7 @@ def source_archive(plugins):
name = "source_archive",
extension = "tar.gz",
srcs = [
":root-licenses",
rabbitmq_workspace + "//:root-licenses",
],
deps = [
":deps-archive",
Expand Down

0 comments on commit 3f3df48

Please sign in to comment.