forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WORKSPACE
481 lines (438 loc) · 18.4 KB
/
WORKSPACE
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
"""
Materialize's Bazel Workspace.
This `WORKSPACE` file defines all of the rule sets and remote repositories that
we depend on. It's important to note that ordering matters. If an object is
declared more than once it's the _first_ invocation that gets used. This can be
especially tricky when rule sets have their own dependencies, generally
included by calling a `*_dependencies()` macro.
"""
# `bazel-lib`/`bazel-skylib`
#
# Provides generic rules for Bazel to help make things fit together.
#
# For example, Rust build scripts might require files live in a certain
# location, but the dependent `c_library` can't specify an output location.
# `bazel-lib` provides rules to copy files into a new directory that we can
# then provide to the Rust rule.
#
# Note: In an ideal world the two rule sets would be combined into one.
BAZEL_SKYLIB_VERSION = "1.6.1"
BAZEL_SKYLIB_INTEGRITY = "sha256-nziIakBUjG6WwQa3UvJCEw7hGqoGila6flb0UR8z5PI="
maybe(
http_archive,
name = "bazel_skylib",
integrity = BAZEL_SKYLIB_INTEGRITY,
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz".format(BAZEL_SKYLIB_VERSION),
"https://github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz".format(BAZEL_SKYLIB_VERSION),
],
)
ASPECT_BAZEL_LIB_VERSION = "2.7.0"
ASPECT_BAZEL_LIB_INTEGRITY = "sha256-NX2tnSEjJ8NdkkQZDvAQqtMV5z/6G+0aKeIMNy+co0Y="
maybe(
http_archive,
name = "aspect_bazel_lib",
integrity = ASPECT_BAZEL_LIB_INTEGRITY,
strip_prefix = "bazel-lib-{0}".format(ASPECT_BAZEL_LIB_VERSION),
url = "https://github.com/aspect-build/bazel-lib/releases/download/v{0}/bazel-lib-v{0}.tar.gz".format(ASPECT_BAZEL_LIB_VERSION),
)
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains")
# Required bazel-lib dependencies
aspect_bazel_lib_dependencies()
# Register bazel-lib toolchains
aspect_bazel_lib_register_toolchains()
# `rules_cc`
#
# Rules for building C/C++ projects. These are slowly being upstreamed into the
# Bazel source tree, but some projects (e.g. protobuf) still depend on this
# rule set.
RULES_CC_VERSION = "0.0.9"
RULES_CC_INTEGRITY = "sha256-IDeHW5pEVtzkp50RKorohbvEqtlo5lh9ym5k86CQDN8="
maybe(
http_archive,
name = "rules_cc",
integrity = RULES_CC_INTEGRITY,
strip_prefix = "rules_cc-{0}".format(RULES_CC_VERSION),
urls = [
"https://mirror.bazel.build/bazelbuild/rules_cc/releases/download/{0}/rules_cc-{0}.tar.gz".format(RULES_CC_VERSION),
"https://github.com/bazelbuild/rules_cc/releases/download/{0}/rules_cc-{0}.tar.gz".format(RULES_CC_VERSION),
],
)
# `rules_pkg`
#
# Rules for building archives, e.g. `tar` or `zip`, for packages.
RULES_PKG_VERSION = "0.7.0"
RULES_PKG_INTEGRITY = "sha256-iimOgydi7aGDBZfWT+fbWBeKqEzVkm121bdE1lWJQcI="
maybe(
http_archive,
name = "rules_pkg",
integrity = RULES_PKG_INTEGRITY,
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/{0}/rules_pkg-{0}.tar.gz".format(RULES_PKG_VERSION),
"https://github.com/bazelbuild/rules_pkg/releases/download/{0}/rules_pkg-{0}.tar.gz".format(RULES_PKG_VERSION),
],
)
# `rules_foreign_cc`
#
# Rules for building C/C++ projects that use foreign build systems, e.g. Make. One case that we use
# this for is building `openssl`.
#
# TODO(parkmycar): We maintain a fork with the following fixes applied to the `mz-fixes` branch:
#
# 1. Versions of `make` >4.3 are buggy and have a segfault, we hit this segfault when building jemalloc.
# See: <https://github.com/bazelbuild/rules_foreign_cc/issues/898>
# See: <https://github.com/MaterializeInc/rules_foreign_cc/commit/8e28ba0bbbf7e73d70333b625bfec4a65114d8be>
#
# 2. Some libraries, e.g. jemalloc, preprocess and compile code in two separate steps, so we need
# to make sure the sysroot is provided in CPPFLAGS, if it's set in CFLAGS.
# See: <https://github.com/bazelbuild/rules_foreign_cc/pull/1023>
# See: <https://github.com/MaterializeInc/rules_foreign_cc/commit/2199b1c304140fa959c3703b0b7e9cbf7d39c4c2>
#
# 3. Specify the AR tool to use when bootstrapping `make`. On macOS explicitly set the path to
# be llvm-ar which we know exists in our toolchain.
# See: <https://github.com/MaterializeInc/rules_foreign_cc/commit/e94986f05edf95fff025b6aeb995e09be8889b89>
#
# 4. `make` 4.2 fails to compile on Linux because of unrecognized symbols so we patch the source.
# See: <https://github.com/MaterializeInc/rules_foreign_cc/commit/de4a79280f54d8796e86b7ab0b631939b7b44d05>
RULES_FOREIGN_CC_VERSION = "de4a79280f54d8796e86b7ab0b631939b7b44d05"
RULES_FOREIGN_CC_INTEGRITY = "sha256-WwRg/GJuUjT3SMJEagTni2ZH+g3szIkHaqGgbYCN1u0="
maybe(
http_archive,
name = "rules_foreign_cc",
integrity = RULES_FOREIGN_CC_INTEGRITY,
strip_prefix = "rules_foreign_cc-{0}".format(RULES_FOREIGN_CC_VERSION),
url = "https://github.com/MaterializeInc/rules_foreign_cc/archive/{0}.tar.gz".format(RULES_FOREIGN_CC_VERSION),
)
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies(make_version = "4.2")
# `clang`/`llvm`
#
# Normally Bazel will use the system's version of clang as the default C
# toolchain. This prevents the builds from being hermetic though so we include
# our own.
#
# All of the clang related tools are provided under the `@llvm_toolchain_llvm`
# repo. To see what's available run `bazel query @llvm_toolchain_llvm//...`.
# Version of the "toolchains_llvm" rule set, _not_ the version of clang/llvm.
TOOLCHAINS_LLVM_VERSION = "1.0.0"
TOOLCHAINS_LLVM_INTEGRITY = "sha256-6RxDYfmQEaVIFOGvvlxDbg0ymHEUajzVjCOitK+1Bzc="
# Version of clang/llvm we use.
#
# At the moment this is the newest version that is pre-compiled for all of the platforms we support.
LLVM_VERSION = "16.0.0"
maybe(
http_archive,
name = "toolchains_llvm",
integrity = TOOLCHAINS_LLVM_INTEGRITY,
strip_prefix = "toolchains_llvm-{0}".format(TOOLCHAINS_LLVM_VERSION),
canonical_id = "{0}".format(TOOLCHAINS_LLVM_VERSION),
url = "https://github.com/bazel-contrib/toolchains_llvm/releases/download/{0}/toolchains_llvm-{0}.tar.gz".format(TOOLCHAINS_LLVM_VERSION),
)
load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")
bazel_toolchain_dependencies()
load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")
llvm_toolchain(
name = "llvm_toolchain",
llvm_version = LLVM_VERSION,
)
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
llvm_register_toolchains()
# `rules_perl`
#
# Provides a `perl` toolchain which is required to build some libraries (e.g. openssl).
RULES_PERL_VERISON = "0.1.0"
RULES_PERL_INTEGRITY = "sha256-XO+tvypJvzQh7eAJ8sWiyYNquueSYg7S/5kYQTN1UyU="
maybe(
http_archive,
name = "rules_perl",
integrity = RULES_PERL_INTEGRITY,
strip_prefix = "rules_perl-{0}".format(RULES_PERL_VERISON),
urls = [
"https://mirror.bazel.build/bazelbuild/rules_perl/archive/refs/tags/{0}.tar.gz".format(RULES_PERL_VERISON),
"https://github.com/bazelbuild/rules_perl/archive/refs/tags/{0}.tar.gz".format(RULES_PERL_VERISON),
],
)
load("@rules_perl//perl:deps.bzl", "perl_register_toolchains", "perl_rules_dependencies")
perl_rules_dependencies()
perl_register_toolchains()
# Extra setup.
#
# Some libraries (e.g. protobuf) require bespoke rule sets. Because they're
# specific to a single library we move their definitions into separate files
# to avoid cluter.
load("//misc/bazel/c_deps:extra_setup.bzl", "protoc_setup")
protoc_setup()
# C Repositories
#
# Loads all of the C dependencies that we rely on.
load("//misc/bazel/c_deps:repositories.bzl", "c_repositories")
c_repositories()
# `rules_rust`
#
# Rules for building Rust crates, and several convienence macros for building all transitive
# dependencies.
RULES_RUST_VERSION = "0.44.0"
RULES_RUST_INTEGRITY = "sha256-pt9MIrs/tDVzpMQIjvbQ+v44oOzQ+FrSH/2IiAAzcDA="
maybe(
http_archive,
name = "rules_rust",
integrity = RULES_RUST_INTEGRITY,
urls = [
"https://github.com/bazelbuild/rules_rust/releases/download/{0}/rules_rust-v{0}.tar.gz".format(RULES_RUST_VERSION),
"https://mirror.bazel.build/bazelbuild/rules_rust/releases/download/{0}/rules_rust-v{0}.tar.gz".format(RULES_RUST_VERSION),
],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies")
rules_rust_dependencies()
# `rustc`
#
# Fetch and register the relevant Rust toolchains. We use a custom macro that
# depends on `rules_rust` but cuts down on bloat from their defaults.
RUST_VERSION = "1.79.0"
load("//misc/bazel/toolchains:rust.bzl", "rust_toolchains")
rust_toolchains(
RUST_VERSION,
[
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
]
)
# Load all dependencies for crate_universe.
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies()
load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "crate")
crates_repository(
name = "crates_io",
cargo_lockfile = "//:Cargo.lock",
lockfile = "//misc/bazel:Cargo.crates_io.lock",
rust_version = RUST_VERSION,
annotations = {
"librocksdb-sys": [crate.annotation(
additive_build_file = "@//misc/bazel/c_deps:rust-sys/BUILD.rocksdb.bazel",
# Note: The below targets are from the additive build file.
build_script_env = {
"ROCKSDB_STATIC": "true",
"ROCKSDB_LIB_DIR": "$(execpath :rocksdb_lib)",
"ROCKSDB_INCLUDE_DIR": "$(execpath :rocksdb_include)",
},
build_script_data = [
":rocksdb_lib",
":rocksdb_include",
],
compile_data = [":rocksdb_lib"],
)],
# TODO(parkmycar): Re-enable linking with a jemalloc built by Bazel.
# "tikv-jemalloc-sys": [crate.annotation(
# build_script_env = {
# "JEMALLOC_OVERRIDE": "$(execpath @jemalloc//:libjemalloc)",
# },
# build_script_data = ["@jemalloc//:libjemalloc"],
# compile_data = ["@jemalloc//:libjemalloc"],
# )],
"rdkafka-sys": [crate.annotation(
gen_build_script = False,
additive_build_file = "@//misc/bazel/c_deps:rust-sys/BUILD.librdkafka.bazel",
# Note: This is a target we add from the additive build file above.
deps = [":librdkafka"],
compile_data = [":rdkafka_lib"],
rustc_flags = [
"-Lnative=$(execpath :rdkafka_lib)",
"-lstatic=rdkafka",
]
)],
"libz-sys": [crate.annotation(
gen_build_script = False,
compile_data = ["@zlib//:zlib_static_lib"],
rustc_flags = [
"-Lnative=$(execpath @zlib//:zlib_static_lib)",
"-lstatic=zlib",
]
)],
"openssl-sys": [crate.annotation(
build_script_data = [
"@openssl//:openssl_lib",
"@openssl//:openssl_include",
],
build_script_data_glob = ["build/**/*.c"],
build_script_env = {
"OPENSSL_STATIC": "true",
"OPENSSL_NO_VENDOR": "1",
"OPENSSL_LIB_DIR": "$(execpath @openssl//:openssl_lib)",
"OPENSSL_INCLUDE_DIR": "$(execpath @openssl//:openssl_include)",
},
compile_data = ["@openssl//:openssl_lib"],
)],
"protobuf-src": [crate.annotation(
# Note: We shouldn't ever depend on protobuf-src, but if we do, don't try to bootstrap
# `protoc`.
gen_build_script = False,
rustc_env = { "INSTALL_DIR": "fake" },
)],
"protobuf-native": [crate.annotation(
gen_build_script = False,
additive_build_file = "@//misc/bazel/c_deps:rust-sys/BUILD.protobuf-native.bazel",
deps = [
":compiler-sys",
":compiler-bridge",
":io-sys",
":io-bridge",
":lib-sys",
":lib-bridge",
":internal-bridge",
],
)],
"launchdarkly-server-sdk": [crate.annotation(
build_script_env = {
"CARGO_PKG_AUTHORS": "LaunchDarkly",
"CARGO_PKG_DESCRIPTION": "",
"CARGO_PKG_HOMEPAGE": "https://docs.launchdarkly.com/sdk/server-side/rust",
"CARGO_PKG_LICENSE": "Apache-2.0",
"CARGO_PKG_REPOSITORY": "https://github.com/launchdarkly/rust-server-sdk",
"RUSTDOC": "",
},
)],
},
manifests = [
"//:Cargo.toml",
"//:src/adapter-types/Cargo.toml",
"//:src/adapter/Cargo.toml",
"//:src/alloc-default/Cargo.toml",
"//:src/alloc/Cargo.toml",
"//:src/arrow-util/Cargo.toml",
"//:src/audit-log/Cargo.toml",
"//:src/avro/Cargo.toml",
"//:src/aws-secrets-controller/Cargo.toml",
"//:src/aws-util/Cargo.toml",
"//:src/balancerd/Cargo.toml",
"//:src/build-info/Cargo.toml",
"//:src/build-tools/Cargo.toml",
"//:src/catalog-debug/Cargo.toml",
"//:src/catalog/Cargo.toml",
"//:src/ccsr/Cargo.toml",
"//:src/cloud-api/Cargo.toml",
"//:src/cloud-resources/Cargo.toml",
"//:src/cluster-client/Cargo.toml",
"//:src/cluster/Cargo.toml",
"//:src/clusterd/Cargo.toml",
"//:src/compute-client/Cargo.toml",
"//:src/compute-types/Cargo.toml",
"//:src/compute/Cargo.toml",
"//:src/controller-types/Cargo.toml",
"//:src/controller/Cargo.toml",
"//:src/dyncfg/Cargo.toml",
"//:src/dyncfgs/Cargo.toml",
"//:src/environmentd/Cargo.toml",
"//:src/expr-parser/Cargo.toml",
"//:src/expr-test-util/Cargo.toml",
"//:src/expr/Cargo.toml",
"//:src/fivetran-destination/Cargo.toml",
"//:src/frontegg-auth/Cargo.toml",
"//:src/frontegg-client/Cargo.toml",
"//:src/frontegg-mock/Cargo.toml",
"//:src/http-util/Cargo.toml",
"//:src/interchange/Cargo.toml",
"//:src/kafka-util/Cargo.toml",
"//:src/lowertest-derive/Cargo.toml",
"//:src/lowertest/Cargo.toml",
"//:src/lsp-server/Cargo.toml",
"//:src/metabase/Cargo.toml",
"//:src/metrics/Cargo.toml",
"//:src/mysql-util/Cargo.toml",
"//:src/mz/Cargo.toml",
"//:src/npm/Cargo.toml",
"//:src/orchestrator-kubernetes/Cargo.toml",
"//:src/orchestrator-process/Cargo.toml",
"//:src/orchestrator-tracing/Cargo.toml",
"//:src/orchestrator/Cargo.toml",
"//:src/ore-proc/Cargo.toml",
"//:src/ore/Cargo.toml",
"//:src/persist-cli/Cargo.toml",
"//:src/persist-client/Cargo.toml",
"//:src/persist-proc/Cargo.toml",
"//:src/persist-types/Cargo.toml",
"//:src/persist/Cargo.toml",
"//:src/pgcopy/Cargo.toml",
"//:src/pgrepr-consts/Cargo.toml",
"//:src/pgrepr/Cargo.toml",
"//:src/pgtest/Cargo.toml",
"//:src/pgtz/Cargo.toml",
"//:src/pgwire-common/Cargo.toml",
"//:src/pgwire/Cargo.toml",
"//:src/postgres-client/Cargo.toml",
"//:src/postgres-util/Cargo.toml",
"//:src/proc/Cargo.toml",
"//:src/prof-http/Cargo.toml",
"//:src/prof/Cargo.toml",
"//:src/proto/Cargo.toml",
"//:src/regexp/Cargo.toml",
"//:src/repr-test-util/Cargo.toml",
"//:src/repr/Cargo.toml",
"//:src/rocksdb-types/Cargo.toml",
"//:src/rocksdb/Cargo.toml",
"//:src/s3-datagen/Cargo.toml",
"//:src/secrets/Cargo.toml",
"//:src/segment/Cargo.toml",
"//:src/server-core/Cargo.toml",
"//:src/service/Cargo.toml",
"//:src/sql-lexer/Cargo.toml",
"//:src/sql-parser/Cargo.toml",
"//:src/sql-pretty/Cargo.toml",
"//:src/sql/Cargo.toml",
"//:src/sqllogictest/Cargo.toml",
"//:src/ssh-util/Cargo.toml",
"//:src/storage-client/Cargo.toml",
"//:src/storage-controller/Cargo.toml",
"//:src/storage-operators/Cargo.toml",
"//:src/storage-types/Cargo.toml",
"//:src/storage/Cargo.toml",
"//:src/testdrive/Cargo.toml",
"//:src/timely-util/Cargo.toml",
"//:src/timestamp-oracle/Cargo.toml",
"//:src/tls-util/Cargo.toml",
"//:src/tracing/Cargo.toml",
"//:src/transform/Cargo.toml",
"//:src/txn-wal/Cargo.toml",
"//:src/walkabout/Cargo.toml",
"//:src/workspace-hack/Cargo.toml",
"//:test/metabase/smoketest/Cargo.toml",
"//:test/test-util/Cargo.toml",
"//:misc/bazel/cargo-gazelle/Cargo.toml",
],
# When `isolated` is true, Bazel will create a new `$CARGO_HOME`, i.e. it
# won't use `~/.cargo`, when re-pinning. This is nice but not totally
# necessary, and it makes re-pinning painfully slow, so we disable it.
isolated = False,
# Only used if developing rules_rust.
# generator = "@cargo_bazel_bootstrap//:cargo-bazel",
)
load("@crates_io//:defs.bzl", "crate_repositories")
crate_repositories()
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies()
# Third-Party Rust Tools
#
# A few crates bind to an external C/C++ library using `cxx`. To build these
# with Bazel we need to include the `cxx` command line binary.
load("//misc/bazel/rust_deps:repositories.bzl", "rust_repositories")
rust_repositories()
# Load and include any dependencies the third-party Rust binaries require.
#
# Ideally we would call `load(...)` from `rust_repositories()`, but load
# statements can only be called from the top-level WORKSPACE, so we must do it
# here.
#
# TODO(parkmycar): This should get better when we switch to bzlmod.
load("@cxxbridge//:defs.bzl", cxxbridge_cmd_deps = "crate_repositories")
cxxbridge_cmd_deps()