forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD
191 lines (172 loc) · 6.05 KB
/
BUILD
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
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
load("@repo_license//:license.bzl", "REPO_LICENSE")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_uv//uv:pip.bzl", "pip_compile")
load("@rules_uv//uv:venv.bzl", "create_venv")
exports_files([
"Pipfile",
"Pipfile.lock",
"pyproject.toml",
"requirements.txt",
"requirements_lock.txt",
])
string_flag(
name = "cmk_version",
build_setting_default = "UNSET",
visibility = ["//:__subpackages__"],
)
string_flag(
# For a discussion of Linux Standard Base (LSB) vs Filesystem Hierarchy Standard (FHS),
# see https://lists.linux-foundation.org/pipermail/lsb-discuss/2011-February/006674.html
#
# Current state: debian-based distros use LSB and the others, including el{8,9} and sles
# use FHS.
name = "filesystem_layout",
build_setting_default = "FILESYSTEM_LAYOUT_INVALID",
visibility = ["//visibility:public"],
)
config_setting(
name = "lsb_filesystem_layout",
flag_values = {":filesystem_layout": "lsb"},
)
config_setting(
name = "fhs_filesystem_layout",
flag_values = {":filesystem_layout": "fhs"},
)
string_flag(
name = "repo_license",
build_setting_default = REPO_LICENSE,
visibility = ["//visibility:public"],
)
config_setting(
name = "gpl_repo",
flag_values = {":repo_license": "gpl"},
)
config_setting(
# We really mean the license here, editions are handled differently!
name = "gpl+enterprise_repo",
flag_values = {":repo_license": "gpl+enterprise"},
)
# Generate `compile_commands.json` with `bazel run //:refresh_compile_commands`.
refresh_compile_commands(
name = "refresh_compile_commands",
# TODO: Do we want that or not? We get quite a few duplicate entries which often differ without that option.
# exclude_headers = "all",
targets = {
# target: build-flags
"//packages/cmc:all": "",
"//packages/livestatus:all": "",
"//packages/neb:all": "",
"//packages/unixcat:all": "",
},
)
genrule(
name = "_append_dependencies_from_pipfile",
srcs = [
":requirements.txt",
"//cmk:requirements.txt",
],
outs = ["requirements_cmk.txt"],
cmd = "cat $(location :requirements.txt) $(location //cmk:requirements.txt) > $@",
)
pip_compile(
name = "requirements",
data = [
"//packages/cmk-agent-based:requirements.txt",
"//packages/cmk-agent-receiver:requirements.txt",
"//packages/cmk-ccc:requirements.txt",
"//packages/cmk-crypto:requirements.txt",
"//packages/cmk-events:requirements.txt",
"//packages/cmk-graphing:requirements.txt",
"//packages/cmk-livestatus-client:requirements.txt",
"//packages/cmk-messaging:requirements.txt",
"//packages/cmk-mkp-tool:requirements.txt",
"//packages/cmk-rulesets:requirements.txt",
"//packages/cmk-server-side-calls:requirements.txt",
"//packages/cmk-shared-typing:requirements.txt",
"//packages/cmk-trace:requirements.txt",
"//packages/cmk-werks:requirements.txt",
] + select({
"@//:gpl_repo": [],
"@//:gpl+enterprise_repo": [
"//non-free/packages/cmk-otel-collector:requirements.txt",
],
}),
requirements_in = ":requirements_cmk.txt",
requirements_txt = "@//:requirements_lock.txt",
tags = ["manual"],
visibility = ["//visibility:public"],
)
write_file(
# WHY?
# * we used to install the packages as editable in our pipenv
# * when creating a venv with bazel, we need to have everything sandbox-ed in bazel
# * however we still want to use the packages somehow editable
name = "sitecustomize",
out = "sitecustomize.py",
content = [
"import os",
"import sys",
"dirname = os.path.dirname(__file__)",
'sys.path.append(os.path.abspath(os.path.join(dirname, "../../../../")))',
'relative_packages_path = "../../../../packages"',
"for p in os.listdir(os.path.join(dirname, relative_packages_path)):",
" sys.path.append(os.path.abspath(os.path.join(dirname, relative_packages_path, p)))",
] + select({
"@//:gpl_repo": [],
"@//:gpl+enterprise_repo": [
'relative_packages_path_non_free = "../../../../non-free/packages"',
"for p in os.listdir(os.path.join(dirname, relative_packages_path_non_free)):",
" sys.path.append(os.path.abspath(os.path.join(dirname, relative_packages_path_non_free, p)))",
],
}),
)
create_venv(
name = "create_venv",
destination_folder = ".venv_uv",
requirements_txt = "@//:requirements_lock.txt",
site_packages_extra_files = [":sitecustomize.py"],
)
copy_file(
name = "_cmc_config_proto",
src = "//non-free/cmc-protocols/protocols:checkmk/cmc/config/v1/types.proto",
out = "cmc_proto/config/v1/types.proto",
)
copy_file(
name = "_cmc_cycletime_proto",
src = "//non-free/cmc-protocols/protocols:checkmk/cmc/cycletime/v1/types.proto",
out = "cmc_proto/cycletime/v1/types.proto",
)
copy_file(
name = "_cmc_state_proto",
src = "//non-free/cmc-protocols/protocols:checkmk/cmc/state/v1/types.proto",
out = "cmc_proto/state/v1/types.proto",
)
proto_library(
name = "cycletime_proto",
srcs = ["cmc_proto/cycletime/v1/types.proto"],
visibility = ["//visibility:public"],
)
proto_library(
name = "config_proto",
srcs = ["cmc_proto/config/v1/types.proto"],
visibility = ["//visibility:public"],
deps = [
":cycletime_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:timestamp_proto",
],
)
proto_library(
name = "state_proto",
srcs = ["cmc_proto/state/v1/types.proto"],
visibility = ["//visibility:public"],
deps = [
":cycletime_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:timestamp_proto",
],
)