Skip to content

Commit

Permalink
Merge pull request #23 from traP-jp/feat/schema-build
Browse files Browse the repository at this point in the history
build schema
  • Loading branch information
H1rono authored Jan 22, 2025
2 parents 1709fbf + 619c76e commit 4797c85
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 4 deletions.
15 changes: 14 additions & 1 deletion server/Cargo.lock

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

5 changes: 2 additions & 3 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["./."]
members = ["./.", "./schema"]

[workspace.package]
version = "0.1.0"
Expand Down Expand Up @@ -89,5 +89,4 @@ tracing.workspace = true
tracing-subscriber.workspace = true
uuid.workspace = true

[build-dependencies]
tonic-build.workspace = true
schema.path = "./schema"
17 changes: 17 additions & 0 deletions server/schema/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "schema"
version.workspace = true
edition.workspace = true
publish.workspace = true

[dependencies]
bytes.workspace = true
prost.workspace = true
prost-types.workspace = true
serde.workspace = true
tonic.workspace = true
tonic-types.workspace = true
tonic-web.workspace = true

[build-dependencies]
tonic-build.workspace = true
19 changes: 19 additions & 0 deletions server/schema/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::path::Path;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let proto_dir = Path::new("../../proto").canonicalize()?;
let proto_files = std::fs::read_dir(&proto_dir)?
.filter_map(|entry| {
let entry = entry.ok()?.path();
let ext = entry.extension()?.to_str()?;
(ext == "proto").then_some(entry)
})
.collect::<Vec<_>>();

tonic_build::configure()
.build_client(false)
.build_server(true)
.build_transport(true)
.compile_protos(&proto_files, &[proto_dir])?;
Ok(())
}
27 changes: 27 additions & 0 deletions server/schema/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pub mod auth {
tonic::include_proto!("auth");
}

pub mod explore {
tonic::include_proto!("explore");
}

pub mod msg {
tonic::include_proto!("msg");
}

pub mod reaction {
tonic::include_proto!("reaction");
}

pub mod speaker_phone {
tonic::include_proto!("speaker_phone");
}

pub mod user {
tonic::include_proto!("user");
}

pub mod world {
tonic::include_proto!("world");
}

0 comments on commit 4797c85

Please sign in to comment.