forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
205 lines (183 loc) · 4.63 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_erlang//:dialyze.bzl", "plt")
load("@rules_erlang//:shell.bzl", "shell")
load("elixir_home.bzl", "elixir_home")
load(":rabbitmq_home.bzl", "rabbitmq_home")
load(":rabbitmq_run.bzl", "rabbitmq_run", "rabbitmq_run_command")
load(":rabbitmqctl.bzl", "rabbitmqctl")
load(":rabbitmq.bzl", "APP_VERSION", "all_plugins")
load(":dist.bzl", "collect_licenses", "versioned_rabbitmq_home")
exports_files([
"scripts/bazel/rabbitmq-run.sh",
"scripts/bazel/rabbitmq-run.bat",
])
config_setting(
name = "debug_build",
values = {
"compilation_mode": "dbg",
},
)
# This allows us to
# `bazel build //my/target \
# --//:elixir_home=/path/to/elixir/installation`
elixir_home(
name = "elixir_home",
build_setting_default = "~/.kiex/elixirs/elixir-1.10.4",
visibility = ["//visibility:public"],
)
platform(
name = "erlang_git_platform",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
"@bazel_tools//tools/cpp:clang",
],
exec_properties = {
"OSFamily": "Linux",
# linux-erlang-git-master
"container-image": "docker://pivotalrabbitmq/rabbitmq-server-buildenv@sha256:5d4fa38f723186668a497a8ee57e22010187e9347add5d4a7cc199dc13f1493f",
},
)
plt(
name = "base_plt",
visibility = ["//visibility:public"],
)
rabbitmq_home(
name = "broker-home",
plugins = all_plugins(rabbitmq_workspace = ""),
)
rabbitmq_run(
name = "rabbitmq-run",
home = ":broker-home",
visibility = ["//visibility:public"],
)
# Allow us to `bazel run broker`
# for the equivalent of `make run-broker`
rabbitmq_run_command(
name = "broker",
rabbitmq_run = ":rabbitmq-run",
subcommand = "run-broker",
)
# `bazel run rabbitmqctl`
rabbitmqctl(
name = "rabbitmqctl",
home = ":broker-home",
visibility = ["//visibility:public"],
)
rabbitmqctl(
name = "rabbitmq-diagnostics",
home = ":broker-home",
)
rabbitmqctl(
name = "rabbitmq-plugins",
home = ":broker-home",
)
shell(
name = "repl",
deps = all_plugins(rabbitmq_workspace = ""),
)
collect_licenses(
name = "licenses",
srcs = glob(
["LICENSE*"],
exclude = [
"LICENSE.md",
"LICENSE.txt",
],
),
deps = all_plugins(rabbitmq_workspace = ""),
)
versioned_rabbitmq_home(
name = "dist-home",
plugins = all_plugins(rabbitmq_workspace = ""),
)
pkg_tar(
name = "license-files",
srcs = [
":licenses",
"//deps/rabbit:INSTALL",
],
visibility = ["//visibility:public"],
)
pkg_tar(
name = "scripts",
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",
srcs = glob([
"release-notes/*.md",
"release-notes/*.txt",
]),
package_dir = "release-notes",
visibility = ["//visibility:public"],
)
pkg_tar(
name = "package-generic-unix",
srcs = [
":dist-home",
],
extension = "tar.xz",
package_dir = "rabbitmq_server-{}".format(APP_VERSION),
strip_prefix = "dist-home",
visibility = ["//visibility:public"],
deps = [
":license-files",
":release-notes",
":scripts",
"//deps/rabbit:manpages-dir",
],
)
genrule(
name = "test-logs",
outs = ["open-test-logs.sh"],
cmd = """set -euo pipefail
cat << 'EOF' > $@
set -euo pipefail
if [ $$# -eq 0 ]; then
echo "Usage: bazel run test-logs TEST_LABEL [shard_index]"
exit 1
fi
RELATIVE=$${1#//}
PACKAGE=$${RELATIVE%%:*}
SUITE=$${RELATIVE##*:}
OUTPUT_DIR=test.outputs
if [ $$# -gt 1 ]; then
OUTPUT_DIR=shard_$$2_of_*/test.outputs
fi
open bazel-testlogs/$$PACKAGE/$$SUITE/$$OUTPUT_DIR/index.html
EOF
""",
executable = True,
)
genrule(
name = "remote-test-logs",
outs = ["open-remote-test-logs.sh"],
cmd = """set -euo pipefail
cat << 'EOF' > $@
set -euo pipefail
if [ $$# -eq 0 ]; then
echo "Usage: bazel run remote-test-logs TEST_LABEL [shard_index]"
exit 1
fi
RELATIVE=$${1#//}
PACKAGE=$${RELATIVE%%:*}
SUITE=$${RELATIVE##*:}
OUTPUT_DIR=test.outputs
if [ $$# -gt 1 ]; then
OUTPUT_DIR=shard_$$2_of_*/test.outputs
fi
TESTLOGS=$$(echo $$(bazel info output_path)/k8-*/testlogs)
cd $$TESTLOGS/$$PACKAGE/$$SUITE/$$OUTPUT_DIR && unzip outputs.zip
open $$TESTLOGS/$$PACKAGE/$$SUITE/$$OUTPUT_DIR/index.html
EOF
""",
executable = True,
)