Skip to content

Commit

Permalink
feat: slim down
Browse files Browse the repository at this point in the history
reduce tonic features, add feature flags to compile only server, client,
both or neither
  • Loading branch information
alemidev committed Sep 30, 2024
1 parent 1474c37 commit 403200d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ authors = [
"cschen <[email protected]>"
]
license = "GPL-3.0-only"
version = "0.7.0"
version = "0.7.1"
edition = "2021"

[lib]
name = "codemp_proto"

[dependencies]
prost = "0.13"
tonic = "0.12"
uuid = "1.7"
uuid = "1.10"
tonic = { version = "0.12", default-features = false, features = ["codegen", "prost"] }

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

[features]
default = ["client"]
client = []
server = []
44 changes: 32 additions & 12 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(tonic_build::configure().compile(
&[
"proto/common.proto",
"proto/cursor.proto",
"proto/files.proto",
"proto/auth.proto",
"proto/session.proto",
"proto/workspace.proto",
"proto/buffer.proto",
],
&["proto"],
)?)
let server = {
#[cfg(feature = "server")] { true }
#[cfg(not(feature = "server"))] { false }
};

let client = {
#[cfg(feature = "client")] { true }
#[cfg(not(feature = "client"))] { false }
};

let transport = {
#[cfg(any(feature = "server", feature = "client"))] { true }
#[cfg(not(any(feature = "server", feature = "client")))] { false }
};

Ok
(tonic_build::configure()
.build_server(server)
.build_client(client)
.build_transport(transport)
.compile_protos(
&[
"proto/common.proto",
"proto/cursor.proto",
"proto/files.proto",
"proto/auth.proto",
"proto/session.proto",
"proto/workspace.proto",
"proto/buffer.proto",
],
&["proto"],
)?)
}

0 comments on commit 403200d

Please sign in to comment.