Skip to content

Commit 52b6c66

Browse files
JasonAtClockworkclockwork-labs-botrekhoffjdetter
authored
Add C++ Bindings (#3544)
# Description of Changes This adds C++ server bindings (/crate/bindings-cpp) to allow writing C++ 20 modules. - Emscripten WASM build system integration with CMake - Macro-based code generation (SPACETIMEDB_TABLE, SPACETIMEDB_REDUCER, etc) - All SpacetimeDB types supported (primitives, Timestamp, Identity, Uuid, etc) - Product types via SPACETIMEDB_STRUCT - Sum types via SPACETIMEDB_ENUM - Constraints marked with FIELD* macros # API and ABI breaking changes None # Expected complexity level and risk 2 - Doesn't heavily impact any other areas but is complex macro C++ structure to support a similar developer experience, did have a small impact on init command # Testing - [x] modules/module-test-cpp - heavily tested every reducer - [x] modules/benchmarks-cpp - tested through the standalone (~6x faster than C#, ~6x slower than Rust) - [x] modules/sdk-test-cpp - [x] modules/sdk-test-procedure-cpp - [x] modules/sdk-test-view-cpp - [x] Wrote several test modules myself - [x] Quickstart smoketest [Currently in progress] - [ ] Write Blackholio C++ server module --------- Signed-off-by: Jason Larabie <jason@clockworklabs.io> Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com> Co-authored-by: Ryan <r.ekhoff@clockworklabs.io> Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
1 parent f8ce1ed commit 52b6c66

File tree

264 files changed

+38853
-727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+38853
-727
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,25 @@ jobs:
302302
with:
303303
run_install: true
304304

305+
# Install cmake and emscripten for C++ module compilation tests.
306+
- name: Install cmake and emscripten
307+
run: |
308+
sudo apt-get update
309+
sudo apt-get install -y cmake
310+
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
311+
cd ~/emsdk
312+
./emsdk install 4.0.21
313+
./emsdk activate 4.0.21
314+
305315
- name: Build typescript module sdk
306316
working-directory: crates/bindings-typescript
307317
run: pnpm build
308318

319+
# Source emsdk environment to make emcc (Emscripten compiler) available in PATH.
309320
- name: Run tests
310-
run: cargo ci test
321+
run: |
322+
source ~/emsdk/emsdk_env.sh
323+
cargo ci test
311324
312325
lints:
313326
name: Lints

.github/workflows/upgrade-version-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
run_install: true
2323
- name: Verify that upgrade-version still works
24-
run: cargo bump-versions 123.456.789 --rust-and-cli --csharp --typescript --accept-snapshots
24+
run: cargo bump-versions 123.456.789 --rust-and-cli --csharp --typescript --cpp --accept-snapshots
2525
- name: Show diff
2626
run: git diff HEAD
2727

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ new.json
231231
# Temporary templates dir for CLI's init command
232232
/crates/cli/.templates
233233

234+
# C++ build data
235+
modules/benchmarks-cpp/build/
236+
modules/module-test-cpp/build/
237+
234238
# Symlinked output from `nix build`
235239
result
236240

crates/bindings-cpp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build*/

0 commit comments

Comments
 (0)