Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/axl-proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ rust_library(
"@crates//:tonic-prost",
"@crates//:tonic",
"@crates//:uuid",
":build_script"
"//crates/axl-types",
"//crates/starbuf-types",
":build_script",
],
proc_macro_deps = [
"@crates//:starlark_derive",
"//crates/starbuf-derive"
"//crates/starbuf-derive",
],
visibility = [
"//crates/axl-runtime:__pkg__",
Expand Down
1 change: 1 addition & 0 deletions crates/axl-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ prost = "0.14.1"
prost-types = "0.14.1"
starbuf-derive = { path = "../starbuf-derive" }
starbuf-types = { path = "../starbuf-types" }
axl-types = { path = "../axl-types" }
starlark = "0.13.0"
starlark_derive = "0.13.0"
tonic = { version = "0.14.2", features = ["transport", "tls-native-roots"] }
Expand Down
76 changes: 76 additions & 0 deletions crates/axl-proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ fn main() -> Result<(), std::io::Error> {
} else if field.type_name() == ".google.protobuf.Any" {
config.field_attribute(&path, format!(r#"#[starbuf(path = "{}", any)]"#, path));
config.field_attribute(&path, r#"#[allocative(skip)]"#);
// If this Any field is part of a oneof, also add allocative(skip)
// to the variant path so the Oneof derive can skip it.
if let Some(oneof_idx) = field.oneof_index {
if let Some(oneof) = desc.oneof_decl.get(oneof_idx as usize) {
let variant_path = format!(
"{}.{}.{}.{}",
prefix,
desc.name(),
oneof.name(),
field.name()
);
config.field_attribute(&variant_path, r#"#[allocative(skip)]"#);
}
}
} else {
config.field_attribute(&path, format!(r#"#[starbuf(path = "{}")]"#, path));
}
Expand Down Expand Up @@ -116,6 +130,51 @@ fn main() -> Result<(), std::io::Error> {
);
}

// Handle google.longrunning.Operation manually to avoid the prost_types::Any
// in the operation::Result oneof which lacks Starlark/Allocative impls.
config.type_attribute(
"google.longrunning.Operation",
r#"
#[derive(
::starlark::values::ProvidesStaticType,
::starlark::values::Trace,
::starlark::values::NoSerialize,
::allocative::Allocative,
::starbuf_derive::Message
)]
"#,
);
config.field_attribute(
"google.longrunning.Operation.name",
r#"#[starbuf(path = "google.longrunning.Operation.name")]"#,
);
config.field_attribute(
"google.longrunning.Operation.done",
r#"#[starbuf(path = "google.longrunning.Operation.done")]"#,
);
// metadata is prost_types::Any — expose via SBAny
config.field_attribute(
"google.longrunning.Operation.metadata",
r#"#[starbuf(path = "google.longrunning.Operation.metadata", any)]"#,
);
config.field_attribute(
"google.longrunning.Operation.metadata",
r#"#[allocative(skip)]"#,
);
config.field_attribute(
"google.longrunning.Operation.result",
r#"#[starbuf(path = "google.longrunning.Operation.result")]"#,
);
config.type_attribute(
"google.longrunning.Operation.result",
"#[derive(::starbuf_derive::Oneof, ::allocative::Allocative)]",
);
// The Response variant wraps prost_types::Any which doesn't impl Allocative
config.field_attribute(
"google.longrunning.Operation.result.response",
r#"#[allocative(skip)]"#,
);

configure()
.build_client(true)
.build_server(false)
Expand Down Expand Up @@ -208,6 +267,23 @@ pub mod workspace_log {{

{workspace_log}

}}
"#
),
)?;

let remote_logging = fs::read_to_string(format!("{out_dir}/remote_logging.rs"))?;

fs::write(
format!("{out_dir}/remote_logging.rs"),
format!(
r#"
/// @Generated by build.rs
#[starbuf_derive::types]
pub mod remote_logging {{

{remote_logging}

}}
"#
),
Expand Down
53 changes: 53 additions & 0 deletions crates/axl-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,55 @@ pub mod build {
)
)]
pub struct ActionCache;

#[starbuf_derive::service(
client = "crate::build::bazel::remote::execution::v2::execution_client::ExecutionClient",
methods(
name = "Execute",
method = "execute",
request = "crate::build::bazel::remote::execution::v2::ExecuteRequest",
response = "crate::google::longrunning::Operation",
streaming = true,
),
methods(
name = "WaitExecution",
method = "wait_execution",
request = "crate::build::bazel::remote::execution::v2::WaitExecutionRequest",
response = "crate::google::longrunning::Operation",
streaming = true,
)
)]
pub struct Execution;

#[starbuf_derive::service(
client = "crate::build::bazel::remote::execution::v2::content_addressable_storage_client::ContentAddressableStorageClient",
methods(
name = "FindMissingBlobs",
method = "find_missing_blobs",
request = "crate::build::bazel::remote::execution::v2::FindMissingBlobsRequest",
response = "crate::build::bazel::remote::execution::v2::FindMissingBlobsResponse",
),
methods(
name = "BatchUpdateBlobs",
method = "batch_update_blobs",
request = "crate::build::bazel::remote::execution::v2::BatchUpdateBlobsRequest",
response = "crate::build::bazel::remote::execution::v2::BatchUpdateBlobsResponse",
),
methods(
name = "BatchReadBlobs",
method = "batch_read_blobs",
request = "crate::build::bazel::remote::execution::v2::BatchReadBlobsRequest",
response = "crate::build::bazel::remote::execution::v2::BatchReadBlobsResponse",
),
methods(
name = "GetTree",
method = "get_tree",
request = "crate::build::bazel::remote::execution::v2::GetTreeRequest",
response = "crate::build::bazel::remote::execution::v2::GetTreeResponse",
streaming = true,
)
)]
pub struct ContentAddressableStorage;
}
}
}
Expand All @@ -51,6 +100,9 @@ pub mod build {
mod pb_impl;

pub mod google {
pub mod bytestream {
include!(concat!(env!("OUT_DIR"), "/google.bytestream.rs"));
}
pub mod devtools {
pub mod build {
pub mod v1 {
Expand Down Expand Up @@ -108,3 +160,4 @@ pub mod options {
pub mod stardoc_output {
include!(concat!(env!("OUT_DIR"), "/stardoc_output.rs"));
}
include!(concat!(env!("OUT_DIR"), "/remote_logging.rs"));
1 change: 1 addition & 0 deletions crates/axl-runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ rust_library(
"@crates//:semver",
"@crates//:sha2",
"//crates/axl-proto",
"//crates/axl-types",
"//crates/build-event-stream",
"//crates/galvanize",
],
Expand Down
1 change: 1 addition & 0 deletions crates/axl-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ liquid-core = "0.26.11"
minijinja = "2.12.0"

aspect-telemetry = { path = "../aspect-telemetry" }
axl-types = { path = "../axl-types" }
axl-proto = { path = "../axl-proto" }
build-event-stream = { path = "../build-event-stream" }
galvanize = { path = "../galvanize" }
Expand Down
15 changes: 15 additions & 0 deletions crates/axl-runtime/src/engine/globals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,19 @@ pub fn register_globals(globals: &mut GlobalsBuilder) {
counter: AtomicU64::new(0),
})
}

/// Creates a `Bytes` value from a hex-encoded string.
fn bytes<'v>(hex: &str, heap: Heap<'v>) -> anyhow::Result<starlark::values::Value<'v>> {
if hex.len() % 2 != 0 {
return Err(anyhow::anyhow!("hex string must have even length"));
}
let data = (0..hex.len())
.step_by(2)
.map(|i| {
u8::from_str_radix(&hex[i..i + 2], 16)
.map_err(|e| anyhow::anyhow!("bad hex at position {}: {}", i, e))
})
.collect::<anyhow::Result<Vec<u8>>>()?;
Ok(heap.alloc(starlark::values::bytes::StarlarkBytes::new(&data)))
}
}
3 changes: 3 additions & 0 deletions crates/axl-runtime/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ pub fn register_globals(globals: &mut GlobalsBuilder) {
globals.namespace("remote", |g| {
g.namespace("execution", |g| {
remote_execution::action_cache_service(g);
remote_execution::execution_service(g);
remote_execution::content_addressable_storage_service(g);
remote_execution::v2_toplevels(g);
});
g.namespace("logging", axl_proto::remote_logging_toplevels);
});
globals.namespace("aspect", aspect::register_globals);
globals.namespace("std", std::register_globals);
Expand Down
1 change: 0 additions & 1 deletion crates/axl-runtime/src/engine/std/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod fs;
mod io;
mod process;
pub mod stream;
mod stream_iter;

#[derive(Debug, Display, ProvidesStaticType, NoSerialize, Allocative)]
#[display("<std.Std>")]
Expand Down
Loading