Skip to content

Commit

Permalink
Merge pull request #5223 from rabbitmq/pjk25/package-generic-unix-macro
Browse files Browse the repository at this point in the history
enhance package-generic-unix bazel macro
  • Loading branch information
HoloRin authored Jul 14, 2022
2 parents 73b8e4a + e2ca5d4 commit 18963c9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 49 deletions.
41 changes: 39 additions & 2 deletions 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()""",
)

package_generic_unix(PLUGINS)
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"],
)

source_archive(PLUGINS + ["//deps/rabbitmq_cli:rabbitmqctl"])
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 = PLUGINS)

source_archive(plugins = 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 = None,
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 = None,
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 18963c9

Please sign in to comment.