Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proto types #81

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ thiserror = "1.0.40"
chrono = { version = "0.4.26", default-features = false, features = ["alloc"] }
nom = "7.1.3"
paste = "1.0.14"
prost = { version = "0.13", optional = true }
prost-types = { version = "0.13.2", optional = true }
prost-wkt = { version = "0.6", optional = true }
prost-wkt-types = { version = "0.6", optional = true }
serde = "1.0.196"
regex = "1.10.5"
serde_json = { version = "1.0.124", optional = true }
base64 = { version = "0.22.1", optional = true }

[build-dependencies]
prost-build = { version = "0.13", optional = true }
prost-wkt-build = { version = "0.6", optional = true }

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
serde_bytes = "0.11.14"
Expand All @@ -28,5 +36,6 @@ name = "runtime"
harness = false

[features]
proto = ["dep:prost", "dep:prost-types", "dep:prost-build", "dep:prost-wkt", "dep:prost-wkt-build", "dep:prost-wkt-types", "serde/derive"]
json = ["dep:base64", "dep:serde_json"]

30 changes: 30 additions & 0 deletions interpreter/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use prost_wkt_build::*;
use std::{env, path::PathBuf};

fn main() {
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
let descriptor_file = out.join("descriptors.bin");
let mut prost_build = prost_build::Config::new();
prost_build
.type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]")
.extern_path(".google.protobuf.Any", "::prost_wkt_types::Any")
.extern_path(".google.protobuf.Duration", "::prost_wkt_types::Duration")
.extern_path(".google.protobuf.Timestamp", "::prost_wkt_types::Timestamp")
.extern_path(".google.protobuf.Value", "::prost_wkt_types::Value")
.file_descriptor_set_path(&descriptor_file)
.compile_protos(
&[
"../proto/cel/expr/syntax.proto",
"../proto/cel/expr/checked.proto",
"../proto/cel/expr/value.proto",
],
&["../proto/"],
)
.unwrap();

let descriptor_bytes = std::fs::read(descriptor_file).unwrap();

let descriptor = FileDescriptorSet::decode(&descriptor_bytes[..]).unwrap();

prost_wkt_build::add_serde(out, descriptor);
}
2 changes: 2 additions & 0 deletions interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub use ser::to_value;

#[cfg(feature = "json")]
mod json;
#[cfg(feature = "proto")]
pub mod proto;
#[cfg(test)]
mod testing;

Expand Down
1 change: 1 addition & 0 deletions interpreter/src/proto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/cel.expr.rs"));
Loading