Skip to content

Commit 5219103

Browse files
authored
Add dependencies used in diagnostics package of the Rust TypeDB server (#564)
## Usage and product changes We add Rust crate dependencies for the TypeDB Server that are used by the newly introduced diagnostics package: * [hyper](https://crates.io/crates/hyper) - one of the most popular HTTP crates used for working with REST API (creating HTTP clients and servers); * [hyper-rustls](https://crates.io/crates/hyper-rustls) - TLS (HTTPS) support for `hyper` without dependencies on `openssl`; * [sysinfo](https://crates.io/crates/sysinfo) - a crate for retrieving information about the system (memory, disks, processes, etc.); * [xxhash-rust](https://crates.io/crates/xxhash-rust) - an implementation for a hasher with consistent results over all OSs, archs, and server reboots (used for database names hashing). We modify the `RustManifestSyncer` so it can process source (and compile time) files from a non-target (sub)directory. The original version used to abort the sync tool process in this case, blocking, for example, adding `VERSION` files from the root of a project as compile data to a target.
1 parent badb8e5 commit 5219103

File tree

4 files changed

+445
-321
lines changed

4 files changed

+445
-321
lines changed

builder/rust/cargo/project_aspect.bzl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,34 @@ rust_cargo_project_aspect = aspect(
7373
}
7474
)
7575

76+
# TODO: Consider merging with `rust_cargo_project_aspect`
77+
# (isolate from `if _should_generate_cargo_project(ctx, target)`)
78+
def _rust_cargo_properties_aspect_impl(target, ctx):
79+
if ctx.rule.kind not in _TARGET_TYPES.keys():
80+
# not a crate
81+
return []
82+
83+
crate_info = _crate_info(ctx, target)
84+
sources = [f for src in getattr(ctx.rule.attr, "srcs", []) + getattr(ctx.rule.attr, "compile_data", []) for f in src.files.to_list()]
85+
properties_file = _build_cargo_properties_file(target, ctx, sources, crate_info)
86+
87+
return [
88+
crate_info,
89+
OutputGroupInfo(rust_cargo_properties = depset([properties_file])),
90+
]
91+
92+
rust_cargo_properties_aspect = aspect(
93+
attr_aspects = ["deps", "proc_macro_deps", "crate"],
94+
implementation = _rust_cargo_properties_aspect_impl,
95+
attrs = {
96+
"_manifest_writer" : attr.label(
97+
default = Label("@typedb_dependencies//builder/rust/cargo:manifest-writer"),
98+
executable = True,
99+
cfg = "exec",
100+
)
101+
}
102+
)
103+
76104
def _crate_info(ctx, target):
77105
if _is_universe_crate(target):
78106
crate_name = str(target.label).split(".")[0].rsplit("-", 1)[0].removeprefix("@crates__")

0 commit comments

Comments
 (0)