Skip to content

Commit

Permalink
[chore]: sharing .proto files across workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
danielterwiel committed Sep 26, 2023
1 parent ab7ad7a commit b84f79e
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 47 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -2,6 +2,7 @@
members = [
# Tooling
"xtask",
"protos",
"cli",
"development_server",
"wasmtime_components",
Expand Down
9 changes: 2 additions & 7 deletions cli/build.rs
@@ -1,18 +1,13 @@
// FIXME: this is a copy of /development_server/build.rs
//
// > it prob makes sense to eventualy get this into its own package.
// > But, for now feel free to just repeat the boilerplate in the CLI.

use std::{env, path::PathBuf};

fn main() -> Result<(), Box<dyn std::error::Error>> {
// See https://github.com/hyperium/tonic/blob/master/examples/build.rs
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("development_descriptor.bin"))
.compile(&["proto/development.proto"], &["proto"])
.compile(&["../protos/proto/development.proto"], &["../protos/proto"])
.unwrap();

tonic_build::compile_protos("proto/development.proto")?;
tonic_build::compile_protos("../protos/proto/development.proto")?;
Ok(())
}
29 changes: 0 additions & 29 deletions cli/proto/development.proto

This file was deleted.

4 changes: 2 additions & 2 deletions development_server/build.rs
Expand Up @@ -5,9 +5,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("development_descriptor.bin"))
.compile(&["proto/development.proto"], &["proto"])
.compile(&["../protos/proto/development.proto"], &["../protos/proto"])
.unwrap();

tonic_build::compile_protos("proto/development.proto")?;
tonic_build::compile_protos("../protos/proto/development.proto")?;
Ok(())
}
6 changes: 0 additions & 6 deletions development_server/proto/development.http

This file was deleted.

12 changes: 12 additions & 0 deletions protos/Cargo.toml
@@ -0,0 +1,12 @@
[package]
name = "proto"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tonic-build = "0.10.0"

[dependencies]
tonic-build = "0.10.0"
13 changes: 13 additions & 0 deletions protos/build.rs
@@ -0,0 +1,13 @@
use std::{env, path::PathBuf};

fn main() -> Result<(), Box<dyn std::error::Error>> {
// See https://github.com/hyperium/tonic/blob/master/examples/build.rs
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("development_descriptor.bin"))
.compile(&["../protos/proto/development.proto"], &["../protos/proto"])
.unwrap();

tonic_build::compile_protos("proto/development.proto")?;
Ok(())
}
@@ -1,15 +1,14 @@
syntax = "proto3";
package development;

service Development {
service Development{
rpc Echo(EchoRequest) returns (EchoReply) {};
rpc DeployComponent(DeployRequest) returns (DeployReply) {};
rpc StopServer(Empty) returns (Empty);
}

message Empty {
message Empty {}

}

message DeployRequest {
string component_path = 1;
Expand Down
3 changes: 3 additions & 0 deletions protos/src/lib.rs
@@ -0,0 +1,3 @@
fn main() {
println!("intended for building common .proto files");
}

0 comments on commit b84f79e

Please sign in to comment.