Skip to content

Commit 99b25ed

Browse files
authored
Moved C Bridge from dotnet-sdk to core-sdk repo (#951)
Moved in Core C bridge from sdk-dotnet. Also fixed unused import warning in integration tests on Linux/ARM. C bridge breaking changes: - Renamed crate to `temporal_sdk_core_c_bridge` - Renamed header file to `temporal-sdk-core-c-bridge.h` - Added `temporal_core_` prefix to exported C functions and `TemporalCore` prefix to exported types - Changed `TestServerOptions::download_ttl_ms` to `download_ttl_seconds` Other: - Upgraded to edition 2024, cleaned up dependencies - Added missing RPC calls - Added some smoke tests for the bridge - Moved LTO profile to workspace root - Added git diff check to CI - Various lints and formatting
1 parent 15163c4 commit 99b25ed

File tree

18 files changed

+5212
-7
lines changed

18 files changed

+5212
-7
lines changed

.github/workflows/per-pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
- run: cargo doc --workspace --all-features --no-deps
3535
- run: cargo lint
3636
- run: cargo test-lint
37+
- run: cargo check
38+
- run: git diff --exit-code
3739

3840
test:
3941
name: Unit Tests

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ document as your quick reference when submitting pull requests.
88
- `core/` – implementation of the core SDK
99
- `client/` – clients for communicating with Temporal clusters
1010
- `core-api/` – API definitions exposed by core
11+
- `core-c-bridge/` – C interface for core
1112
- `sdk/` – pre-alpha Rust SDK built on top of core (used mainly for tests)
1213
- `sdk-core-protos/` – protobuf definitions shared across crates
1314
- `fsm/` – state machine implementation and macros

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["core", "client", "core-api", "fsm", "test-utils", "sdk-core-protos", "sdk"]
2+
members = ["core", "client", "core-api", "fsm", "test-utils", "sdk-core-protos", "sdk", "core-c-bridge"]
33
resolver = "2"
44

55
[workspace.package]
@@ -18,3 +18,7 @@ prost-types = "0.13"
1818

1919
[workspace.lints.rust]
2020
unreachable_pub = "warn"
21+
22+
[profile.release-lto]
23+
inherits = "release"
24+
lto = true

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ installed to build Core.
2626

2727
This repo is composed of multiple crates:
2828

29-
- temporal-sdk-core-protos `./sdk-core-protos` - Holds the generated proto code and extensions
30-
- temporal-client `./client` - Defines client(s) for interacting with the Temporal gRPC service
31-
- temporal-sdk-core-api `./core-api` - Defines the API surface exposed by Core
32-
- temporal-sdk-core `./core` - The Core implementation
29+
- temporal-sdk-core-protos `./sdk-core-protos` - Holds the generated proto code and extensions.
30+
- temporal-client `./client` - Defines client(s) for interacting with the Temporal gRPC service.
31+
- temporal-sdk-core-api `./core-api` - Defines the API surface exposed by Core.
32+
- temporal-sdk-core `./core` - The Core implementation.
33+
- temporal-sdk-core-c-bridge `./core-c-bridge` - Provides C bindings for Core.
3334
- temporal-sdk `./sdk` - A (currently prototype) Rust SDK built on top of Core. Used for testing.
3435
- rustfsm `./fsm` - Implements a procedural macro used by core for defining state machines
35-
(contains subcrates). It is temporal agnostic.
36+
(contains subcrates). It is Temporal-agnostic.
3637

3738
Visualized (dev dependencies are in blue):
3839

core-c-bridge/Cargo.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[package]
2+
name = "temporal-sdk-core-c-bridge"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[lib]
7+
name = "temporal_sdk_core_c_bridge"
8+
crate-type = ["cdylib"]
9+
10+
[dependencies]
11+
anyhow = "1.0"
12+
async-trait = "0.1"
13+
libc = "0.2"
14+
prost = { workspace = true }
15+
# We rely on Cargo semver rules not updating a 0.x to 0.y. Per the rand
16+
# documentation, before 1.0, minor 0.x updates _can_ break portability which can
17+
# cause non-determinism.
18+
rand = "0.8.5"
19+
rand_pcg = "0.3.1"
20+
serde_json = "1.0"
21+
tokio = "1.26"
22+
tokio-stream = "0.1"
23+
tokio-util = "0.7"
24+
tonic = { workspace = true }
25+
tracing = "0.1"
26+
url = "2.2"
27+
28+
[dependencies.temporal-client]
29+
path = "../client"
30+
31+
[dependencies.temporal-sdk-core]
32+
path = "../core"
33+
features = ["ephemeral-server"]
34+
35+
[dependencies.temporal-sdk-core-api]
36+
path = "../core-api"
37+
38+
[dependencies.temporal-sdk-core-protos]
39+
path = "../sdk-core-protos"
40+
41+
[dev-dependencies]
42+
futures-util = "0.3"
43+
thiserror = { workspace = true }
44+
45+
[dev-dependencies.temporal-sdk-core-test-utils]
46+
path = "../test-utils"
47+
48+
[build-dependencies]
49+
cbindgen = { version = "0.29", default-features = false }

core-c-bridge/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
extern crate cbindgen;
2+
3+
use std::env;
4+
5+
fn main() {
6+
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
7+
8+
let changed = cbindgen::Builder::new()
9+
.with_cpp_compat(true)
10+
.with_crate(crate_dir)
11+
.with_pragma_once(true)
12+
.with_language(cbindgen::Language::C)
13+
.with_item_prefix("TemporalCore")
14+
.generate()
15+
.expect("Unable to generate bindings")
16+
.write_to_file("include/temporal-sdk-core-c-bridge.h");
17+
18+
// If this changed and an env var disallows change, error
19+
if let Ok(env_val) = env::var("TEMPORAL_SDK_BRIDGE_DISABLE_HEADER_CHANGE") {
20+
if changed && env_val == "true" {
21+
println!("cargo:warning=bridge's header file changed unexpectedly from what's on disk");
22+
std::process::exit(1);
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)