-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathBUILD.bazel
More file actions
224 lines (207 loc) · 6.51 KB
/
BUILD.bazel
File metadata and controls
224 lines (207 loc) · 6.51 KB
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# Global build settings
load("@bazel_lib//lib:write_source_files.bzl", "write_source_file")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
package(default_visibility = ["//visibility:public"])
# TODO(agent-build): remove below `gazelle:exclude` directives and add corresponding paths to bazel/go.work
# gazelle:exclude cmd
# gazelle:exclude comp
# gazelle:exclude internal/remote-agent
# gazelle:exclude internal/third_party
# gazelle:exclude internal/tools/gotest-custom
# gazelle:exclude internal/tools/independent-lint
# gazelle:exclude internal/tools/modformatter
# gazelle:exclude pkg/aggregator
# gazelle:exclude pkg/api
# gazelle:exclude pkg/cli
# gazelle:exclude pkg/cloudfoundry
# gazelle:exclude pkg/clusteragent
# gazelle:exclude pkg/collector
# gazelle:exclude pkg/commonchecks
# gazelle:exclude pkg/compliance
# gazelle:exclude pkg/config
# gazelle:exclude pkg/containerlifecycle
# gazelle:exclude pkg/databasemonitoring
# gazelle:exclude pkg/diagnose
# gazelle:exclude pkg/discovery
# gazelle:exclude pkg/dyninst
# gazelle:exclude pkg/ebpf
# gazelle:exclude pkg/errors
# gazelle:exclude pkg/eventmonitor
# gazelle:exclude pkg/fips
# gazelle:exclude pkg/flare
# gazelle:exclude pkg/fleet
# gazelle:exclude pkg/gohai
# gazelle:exclude pkg/gpu
# gazelle:exclude pkg/hosttags
# gazelle:exclude pkg/inventory
# gazelle:exclude pkg/jmxfetch
# gazelle:exclude pkg/kubestatemetrics
# gazelle:exclude pkg/languagedetection
# gazelle:exclude pkg/logs
# gazelle:exclude pkg/metrics
# gazelle:exclude pkg/network
# gazelle:exclude pkg/networkconfigmanagement
# gazelle:exclude pkg/networkdevice
# gazelle:exclude pkg/networkpath
# gazelle:exclude pkg/obfuscate
# gazelle:exclude pkg/opentelemetry-mapping-go
# gazelle:exclude pkg/orchestrator
# gazelle:exclude pkg/persistentcache
# gazelle:exclude pkg/pidfile
# gazelle:exclude pkg/privateactionrunner
# gazelle:exclude pkg/privileged-logs
# gazelle:exclude pkg/process
# gazelle:exclude pkg/procmgr
# gazelle:exclude pkg/proto
# gazelle:exclude pkg/redact
# gazelle:exclude pkg/remoteconfig
# gazelle:exclude pkg/runtime
# gazelle:exclude pkg/sbom
# gazelle:exclude pkg/security
# gazelle:exclude pkg/serializer
# gazelle:exclude pkg/serverless
# gazelle:exclude pkg/snmp
# gazelle:exclude pkg/ssi
# gazelle:exclude pkg/status
# gazelle:exclude pkg/system-probe
# gazelle:exclude pkg/tagger
# gazelle:exclude pkg/tagset
# gazelle:exclude pkg/telemetry
# gazelle:exclude pkg/trace
# gazelle:exclude pkg/util
# gazelle:exclude pkg/version
# gazelle:exclude pkg/windowsdriver
# gazelle:exclude rtloader
# gazelle:exclude tasks
# gazelle:exclude test
# gazelle:exclude tools
# gazelle:exclude .gitlab
# gazelle:prefix github.com/DataDog/datadog-agent
gazelle_binary(
name = "gazelle_bin",
languages = [
"@gazelle//language/go",
"@gazelle//language/proto",
"//bazel/rules/go_stringer:gazelle",
],
)
gazelle(
name = "gazelle",
args = ["-external=static"], # don't use the network: https://github.com/bazel-contrib/bazel-gazelle/issues/1385
gazelle = ":gazelle_bin",
)
# bazel run //:go -- ...
alias(
name = "go",
actual = "@rules_go//go",
)
# bazel run //:go_mod_tidy_all -- -x
alias(
name = "go_mod_tidy_all",
actual = "//bazel/tools:go_mod_tidy_all",
)
run_binary(
name = "gen_go_work",
srcs = [
":go.work",
":modules.yml",
],
outs = ["go.work.new"],
args = [
"--path",
"$(location go.work)",
"--modules-file",
"$(location modules.yml)",
"--output",
"$(location go.work.new)",
],
tool = "//internal/tools/worksynchronizer",
)
# bazel run //:write_go_work
write_source_file(
name = "write_go_work",
in_file = ":gen_go_work",
out_file = "go.work",
)
filegroup(
name = "python_version",
srcs = [".python-version"],
)
config_setting(
name = "macos_arm64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
)
config_setting(
name = "macos_x86_64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
)
config_setting(
name = "linux_x86_64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)
config_setting(
name = "linux_arm64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
)
config_setting(
name = "windows_x86_64",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
)
# The location that the bulk of the agent gets installed to. Like most *nix tools, this
# is in /opt. That will hold shared libraries, and python packages. It is not the
# complete installation, becuase some things go to /etc or /usr.
#
# Migration to bazel warning:
# The goal we are aiming for is that output base is always passed to build
# scripts and we install artifacts to output_base + install_dir. Unfortunately,
# many existing scripts only use install_dir, without regard to a a base. They
# put etc files under opt/datadog, then move them to /etc in the final part of the
# build.
# TODO: We need to learn how people expect to use install dir to create custom
# builds for local testing that do not wipe out their local installation.
string_flag(
name = "install_dir",
build_setting_default = "/opt/datadog-agent",
make_variable = "INSTALL_DIR",
)
# Configuration value to determine if we are using the standard install path.
# This can be used to detect custom builds, where we might not to create some pieces.
# Currently this is used only for installer symlinks. It is likely that we should not
# continue to do that. My hunch is that it was only done to prevent disk stomping in
# developer builds.
config_setting(
name = "is_standard_install",
flag_values = {
"//:install_dir": "/opt/datadog-agent",
},
)
# This seems to be the base of where to write config files during
# the build. That is, if we were creating /etc/foo, it would be
# the path prepended to /etc to get a safe place to write.
# We can set this from the omnibus variable OUTPUT_CONFIG_DIR.
# But, it seems to be empty in CI runs, so we end up writing to /.
# The default is /tmp so we don't shoot our feet off in local testing.
# If we end up keeping this flag, let's give it a better name and
# git it a better value.
string_flag(
name = "output_config_dir",
build_setting_default = "/tmp",
make_variable = "OUTPUT_CONFIG_DIR",
)