2022-11-12 00:07:48 +01:00
|
|
|
use std::io::Result;
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
2022-11-26 02:14:02 +01:00
|
|
|
#[allow(unused_mut)]
|
|
|
|
let mut builder = tonic_build::configure();
|
|
|
|
|
2023-09-26 09:30:35 +02:00
|
|
|
#[cfg(feature = "tonic-reflection")]
|
2022-11-26 02:14:02 +01:00
|
|
|
{
|
|
|
|
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
|
|
|
let descriptor_path = out_dir.join("tvix.store.v1.bin");
|
|
|
|
|
2023-02-15 15:47:14 +01:00
|
|
|
builder = builder.file_descriptor_set_path(descriptor_path);
|
2022-11-26 02:14:02 +01:00
|
|
|
};
|
|
|
|
|
2023-07-19 17:52:50 +02:00
|
|
|
builder
|
|
|
|
.build_server(true)
|
|
|
|
.build_client(true)
|
fix(tvix): don't emit rerun-if-changed
`build.rs` emits rerun-if-changed statements for all proto files, as
well as all include paths we pass it.
Unfortunately, due to protobufs include path rules, we need to specify
the path to the depot root itself as an include path, at least when
building impurely with `cargo`. This causes cargo to essentially always
rebuild, as it also puts its own temporary files in there.
Unfortunately, tonic-build does not chase down to individual .proto
files that are included.
Disable emitting these `rerun-if-changed` statements for now.
This could cause cargo to not rebuild protos every time, causing stale
data until the next local `cargo clean`, but considering the protos
change not that frequently, and it'll immediately surface if trying to
build via Nix (either locally or in CI), it's a good-enough compromise.
Change-Id: Ifd279a2216222ef3fc0e70c5a2fe6f87997f562e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11157
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
2024-03-15 21:58:46 +01:00
|
|
|
.emit_rerun_if_changed(false)
|
2024-07-09 15:06:03 +02:00
|
|
|
.bytes(["."])
|
|
|
|
.extern_path(".tvix.castore.v1", "::tvix_castore::proto")
|
|
|
|
.compile(
|
2023-07-19 17:52:50 +02:00
|
|
|
&[
|
2024-07-23 15:14:17 +02:00
|
|
|
"store/protos/pathinfo.proto",
|
|
|
|
"store/protos/rpc_pathinfo.proto",
|
2023-07-19 17:52:50 +02:00
|
|
|
],
|
|
|
|
// If we are in running `cargo build` manually, using `../..` works fine,
|
|
|
|
// but in case we run inside a nix build, we need to instead point PROTO_ROOT
|
2024-08-19 13:42:17 +02:00
|
|
|
// to a custom tree containing that structure.
|
2023-07-19 17:52:50 +02:00
|
|
|
&[match std::env::var_os("PROTO_ROOT") {
|
|
|
|
Some(proto_root) => proto_root.to_str().unwrap().to_owned(),
|
2024-07-23 15:14:17 +02:00
|
|
|
None => "..".to_string(),
|
2023-07-19 17:52:50 +02:00
|
|
|
}],
|
fix(tvix): don't emit rerun-if-changed
`build.rs` emits rerun-if-changed statements for all proto files, as
well as all include paths we pass it.
Unfortunately, due to protobufs include path rules, we need to specify
the path to the depot root itself as an include path, at least when
building impurely with `cargo`. This causes cargo to essentially always
rebuild, as it also puts its own temporary files in there.
Unfortunately, tonic-build does not chase down to individual .proto
files that are included.
Disable emitting these `rerun-if-changed` statements for now.
This could cause cargo to not rebuild protos every time, causing stale
data until the next local `cargo clean`, but considering the protos
change not that frequently, and it'll immediately surface if trying to
build via Nix (either locally or in CI), it's a good-enough compromise.
Change-Id: Ifd279a2216222ef3fc0e70c5a2fe6f87997f562e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11157
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
2024-03-15 21:58:46 +01:00
|
|
|
)
|
2022-11-12 00:07:48 +01:00
|
|
|
}
|