Skip to content
This repository was archived by the owner on Jun 22, 2023. It is now read-only.

Commit 84e94e5

Browse files
committed
Restructure to allow for wasm compatibility
1 parent 0607d34 commit 84e94e5

File tree

11 files changed

+728
-42
lines changed

11 files changed

+728
-42
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
[package]
22
name = "codectrl-protobuf-bindings"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
edition = "2021"
55

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

8-
[dependencies]
9-
tonic = "0.7"
10-
futures-core = "0.3"
11-
prost = "0.10"
128

9+
[target.'cfg(target_arch = "wasm32")'.dependencies]
10+
web = { path = "./web" }
1311

14-
[build-dependencies]
15-
tonic-build = "0.7"
12+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
13+
native = { path = "./native" }

native/Cargo.lock

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

native/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "native"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
tonic = "0.7"
10+
prost = "0.10"
11+
12+
[build-dependencies]
13+
tonic-build = "0.7"

build.rs renamed to native/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ fn main() {
22
tonic_build::configure()
33
.compile(
44
&[
5-
"proto/cc_service.proto",
6-
"proto/backtrace_data.proto",
7-
"proto/log.proto",
5+
"../proto/cc_service.proto",
6+
"../proto/backtrace_data.proto",
7+
"../proto/log.proto",
88
],
9-
&["proto"],
9+
&["../proto"],
1010
)
1111
.unwrap_or_else(|e| panic!("Failed to compile protos {e:#?}"));
1212
}

native/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// This is the module to emulate the structure of the protobuf file imports to
2+
/// prevent any build issues.
3+
4+
pub mod data {
5+
pub mod backtrace_data {
6+
tonic::include_proto!("codectrl.data.backtrace_data");
7+
}
8+
pub mod log {
9+
tonic::include_proto!("codectrl.data.log");
10+
}
11+
12+
pub use backtrace_data::*;
13+
pub use log::*;
14+
}
15+
16+
pub mod logs_service {
17+
tonic::include_proto!("codectrl.logs_service");
18+
19+
#[cfg(not(target_arch = "wasm32"))]
20+
pub use log_server_server::{
21+
LogServer as LogServerTrait, LogServerServer as LogServerService,
22+
};
23+
24+
#[cfg(not(target_arch = "wasm32"))]
25+
pub use log_client_server::{
26+
LogClient as LogClientTrait, LogClientServer as LogClientService,
27+
};
28+
29+
pub use log_client_client::LogClientClient as LoggerClient;
30+
}

src/lib.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
1-
/// This is the module to emulate the structure of the protobuf file imports to
2-
/// prevent any build issues.
1+
#[cfg(target_arch = "wasm32")]
2+
pub use web::*;
33

4-
pub mod data {
5-
pub mod backtrace_data {
6-
tonic::include_proto!("codectrl.data.backtrace_data");
7-
}
8-
pub mod log {
9-
tonic::include_proto!("codectrl.data.log");
10-
}
11-
12-
pub use backtrace_data::*;
13-
pub use log::*;
14-
}
15-
16-
pub mod logs_service {
17-
tonic::include_proto!("codectrl.logs_service");
18-
19-
pub use log_server_server::{
20-
LogServer as LogServerTrait, LogServerServer as LogServerService,
21-
};
22-
23-
pub use log_client_server::{
24-
LogClient as LogClientTrait, LogClientServer as LogClientService,
25-
};
26-
}
4+
#[cfg(not(target_arch = "wasm32"))]
5+
pub use native::*;

0 commit comments

Comments
 (0)