Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ SDK #2516

Closed
7 of 11 tasks
emilk opened this issue Jun 26, 2023 · 2 comments
Closed
7 of 11 tasks

C++ SDK #2516

emilk opened this issue Jun 26, 2023 · 2 comments
Assignees
Labels
🏹 arrow concerning arrow 🌊 C++ API C/C++ API specific enhancement New feature or request 🎄 tracking issue issue that tracks a bunch of subissues

Comments

@emilk
Copy link
Member

emilk commented Jun 26, 2023

This is the tracking issue for our initial high-level C++ SDK

Goals

  • High-level API
  • Easy to use
  • Easy to install
  • For developers on their own machines

Non-goals

  • C
  • Embedded machines
  • Header-only

We will save this for later.

Approach

Low-level C SDK

We wrap our Rust SDK with a minimal set of functions for:

  • init
  • connect, save
  • log a DataRow

The Rust side is responsible for:

  • Batching
  • TCP communication
  • Streaming logs to disk

Low-level C++ SDK

Basically a C++-friendly wrapper around the C SDK

Code-generated classes

We use re_types (#2241) to generate classes for datatypes, components, and archetypes.

These are converted to Arrow-messages using the official Arrow C++ SDK.

Integrations

Finally, we have opt-in integrations with various libraries such as:

  • OpenCV
  • Eigen

Distribution

The C SDK will consist of a single rerun.h header, and then a dynamic and/or static library of the rerun_c crate.

The C++ SDK will have a CMakelists.txt for ease of use in cmake build systems. We can maybe set up a system where cmake downloads and install the Rerun C++ SDK for users, including dependencies (Arrow).

TODO

@emilk emilk added enhancement New feature or request 🏹 arrow concerning arrow 🎄 tracking issue issue that tracks a bunch of subissues labels Jun 26, 2023
@emilk emilk mentioned this issue Jun 26, 2023
@emilk emilk self-assigned this Jun 28, 2023
@emilk emilk added the 🌊 C++ API C/C++ API specific label Jul 3, 2023
@emilk emilk mentioned this issue Jul 3, 2023
3 tasks
emilk added a commit that referenced this issue Jul 4, 2023
Part of #2516

### What
This PR introduces the seeds of the C and C++ SDK. It's all a hack right
now, and only tested on Mac, but I'd rather merge many small PRs than
build this in isolation over a long time.

A new crate `rerun_c` is introduced, which implements the C SDK (over
FFI).

The C SDK consists of a single header, `rerun.h`, with no dependencies
except on `rerun_c`.

The C++ SDK consists of a single header, `rerun.hpp`, which depends on:
* Arrow C++
* `rerun.h` (the C SDK)
* `rerun_c` (the Rust crate)

The C SDK can create recording streams and log data to them using the
arrow IPC format.

The C++ SDK adds a few helper function for generating some test data and
converting it to the Arrow IPC format.

### Testing it
* Install CMake
* Start rerun with `cargo rerun`
* Run `crates/rerun_c/example_cpp/build_and_run.sh`

You should see three points in a 3D space view. Those points come from
C++!

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2594) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2594)
- [Docs preview](https://rerun.io/preview/pr%3Aemilk%2Fc-sdk/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aemilk%2Fc-sdk/examples)

---------

Co-authored-by: Clement Rey <[email protected]>
@emilk emilk mentioned this issue Jul 6, 2023
3 tasks
emilk added a commit that referenced this issue Jul 7, 2023
Part of #2516 

### What
A few small steps towards a C++ SDK.

* Creates `rerun_cpp` top-level folder. The C SDK remains in
`crates/rerun_c`.
* The new folder has a tree of `CMakeLists.txt`.
* The source code is now split in several .hpp and .cpp
* There is now a C++ class for RecordingStream

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2624) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2624)
- [Docs preview](https://rerun.io/preview/pr%3Aemilk%2Fcpp-sdk/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aemilk%2Fcpp-sdk/examples)

---------

Co-authored-by: Clement Rey <[email protected]>
@Wumpf Wumpf self-assigned this Jul 18, 2023
@Wumpf
Copy link
Member

Wumpf commented Jul 25, 2023

Discussed today in the standup the many perils of shipping C++ binaries. Since we depend on Arrow C++ SDK right now, any source distribution would enforce C++17. We came up with various solutions (use Arrow C library, build out C SDK and forward to that, isolate Arrow code behind a C interface, etc. etc.) but concluded that this is very low priority for us right now: It seems that all known early adopters are (while reportedly not using C++17) are on compiler versions that supports C++17. So as long as our interface isn't C++17 requiring, our implementations can despite shipping as source.

Wumpf added a commit that referenced this issue Aug 2, 2023
…t APIs & introduce C++ SDK tests (#2890)

* Part of #2516
(SDK! Not codegen! :))
* Next in the cpp series after #2874

### What

Adds a test dependency to the
[Catch2](https://github.com/catchorg/Catch2/) testing framework in order
to start testing all the new RecordingStream features added here.

C++ tests can be conveniently run via
`./rerun_cpp/build_and_run_tests.sh` now!

For quick api overview start with the `rerun.h` and `recording_stream.h`
headers.

Fixes a range of compiler warnings as a consequence of improving some of
the CMake setup, more to do there!
Adds lots more documentation to RecordingStream as well.


Next steps:
* Add C++ to ci (linting, running this test suite)
* Add roundtrip tests
*  Add codegen custom code injection
    * Improve API usability in varous places, including 
* #2873
* add other tests
* serialize unions
* serialize datatypes nested in unions, structs and lists
* more testing & roundtripping

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2890) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2890)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp-api%2Fbetter-recording-stream/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp-api%2Fbetter-recording-stream/examples)
@Wumpf
Copy link
Member

Wumpf commented Aug 7, 2023

Superseded by

@Wumpf Wumpf closed this as completed Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏹 arrow concerning arrow 🌊 C++ API C/C++ API specific enhancement New feature or request 🎄 tracking issue issue that tracks a bunch of subissues
Projects
None yet
Development

No branches or pull requests

2 participants