Skip to content

Commit af8dcc2

Browse files
committed
Adds spk-proto crate with flatbuffers schema for future index and package data.
Adds v0 SolverPackageSpec as a package implementation backed by a flatbuffer. Adds fb_converter functions for converting spk schema objects into and out of flatbuffer objects. Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
1 parent d83388a commit af8dcc2

File tree

20 files changed

+2460
-19
lines changed

20 files changed

+2460
-19
lines changed

Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ members = [
1616
"crates/spk-config",
1717
"crates/spk-exec",
1818
"crates/spk-launcher",
19+
"crates/spk-proto",
1920
"crates/spk-schema",
2021
"crates/spk-schema/crates/*",
2122
"crates/spk-solve",
@@ -136,6 +137,7 @@ spk-cmd-repo = { path = "crates/spk-cli/cmd-repo" }
136137
spk-cmd-test = { path = "crates/spk-cli/cmd-test" }
137138
spk-config = { path = "crates/spk-config" }
138139
spk-exec = { path = "crates/spk-exec" }
140+
spk-proto = { path = "crates/spk-proto" }
139141
spk-schema = { path = "crates/spk-schema" }
140142
spk-schema-foundation = { path = "crates/spk-schema/crates/foundation" }
141143
spk-schema-tera = { path = "crates/spk-schema/crates/tera" }

crates/spk-proto/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
authors = { workspace = true }
3+
edition = { workspace = true }
4+
name = "spk-proto"
5+
version = { workspace = true }
6+
license-file = { workspace = true }
7+
homepage = { workspace = true }
8+
repository = { workspace = true }
9+
readme = { workspace = true }
10+
description = { workspace = true }
11+
12+
[lints]
13+
workspace = true
14+
15+
[features]
16+
serde = ["dep:serde"]
17+
18+
[dependencies]
19+
data-encoding = { workspace = true }
20+
flatbuffers = { workspace = true }
21+
futures = { workspace = true }
22+
miette = { workspace = true }
23+
serde = { workspace = true, optional = true }
24+
thiserror = { workspace = true }
25+
26+
[build-dependencies]
27+
flatc-rust = "0.2"
28+
29+
[dev-dependencies]
30+
ring = { workspace = true }
31+
rstest = { workspace = true }

crates/spk-proto/build.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Contributors to the SPK project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
// https://github.com/spkenv/spk
4+
5+
use std::env;
6+
use std::path::{Path, PathBuf};
7+
8+
fn main() {
9+
println!("cargo:rerun-if-changed=schema/spk.fbs");
10+
11+
let cmd = match std::env::var_os("FLATC") {
12+
Some(exe) => flatc_rust::Flatc::from_path(exe),
13+
None => flatc_rust::Flatc::from_env_path(),
14+
};
15+
16+
let out_dir = env::var("OUT_DIR").unwrap();
17+
18+
cmd.run(flatc_rust::Args {
19+
lang: "rust",
20+
inputs: &[Path::new("schema/spk.fbs")],
21+
out_dir: &PathBuf::from(&out_dir),
22+
..Default::default()
23+
})
24+
.expect("schema compiler command");
25+
26+
let generated_file = PathBuf::from(out_dir).join("spk_generated.rs");
27+
println!(
28+
"cargo:rerun-if-changed=schema/spk.fbs generated file: {}",
29+
generated_file.display()
30+
);
31+
}

0 commit comments

Comments
 (0)