-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standard input/output support 4: C++ SDK stdout impl/examples/docs (#…
…4514) Allow the C++ SDK to stream RRD data to stdout. Checks: - [x] `just py-build && just cpp-build-examples && echo 'hello from stdin!' | ./build/debug/examples/cpp/stdio/example_stdio | rerun -` --- Part of a small PR series to add stdio streaming support to our Viewer and SDKs: - #4511 - #4512 - #4513 - #4514
- Loading branch information
Showing
11 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
add_subdirectory(clock) | ||
add_subdirectory(custom_collection_adapter) | ||
add_subdirectory(dna) | ||
add_subdirectory(shared_recording) | ||
add_subdirectory(minimal) | ||
add_subdirectory(shared_recording) | ||
add_subdirectory(spawn_viewer) | ||
add_subdirectory(stdio) | ||
|
||
add_custom_target(examples) | ||
|
||
add_dependencies(examples example_clock) | ||
add_dependencies(examples example_custom_collection_adapter) | ||
add_dependencies(examples example_dna) | ||
add_dependencies(examples example_shared_recording) | ||
add_dependencies(examples example_minimal) | ||
add_dependencies(examples example_shared_recording) | ||
add_dependencies(examples example_spawn_viewer) | ||
add_dependencies(examples example_stdio) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
cmake_minimum_required(VERSION 3.16...3.27) | ||
|
||
# If you use the example outside of the Rerun SDK you need to specify | ||
# where the rerun_c build is to be found by setting the `RERUN_CPP_URL` variable. | ||
# This can be done by passing `-DRERUN_CPP_URL=<path to rerun_sdk_cpp zip>` to cmake. | ||
if(DEFINED RERUN_REPOSITORY) | ||
add_executable(example_stdio main.cpp) | ||
rerun_strict_warning_settings(example_stdio) | ||
else() | ||
project(example_stdio LANGUAGES CXX) | ||
|
||
add_executable(example_stdio main.cpp) | ||
|
||
# Set the path to the rerun_c build. | ||
set(RERUN_CPP_URL "https://github.com/rerun-io/rerun/releases/latest/download/rerun_cpp_sdk.zip" CACHE STRING "URL to the rerun_cpp zip.") | ||
option(RERUN_FIND_PACKAGE "Whether to use find_package to find a preinstalled rerun package (instead of using FetchContent)." OFF) | ||
|
||
if(RERUN_FIND_PACKAGE) | ||
find_package(rerun_sdk REQUIRED) | ||
else() | ||
# Download the rerun_sdk | ||
include(FetchContent) | ||
FetchContent_Declare(rerun_sdk URL ${RERUN_CPP_URL}) | ||
FetchContent_MakeAvailable(rerun_sdk) | ||
endif() | ||
|
||
# Rerun requires at least C++17, but it should be compatible with newer versions. | ||
set_property(TARGET example_stdio PROPERTY CXX_STANDARD 17) | ||
endif() | ||
|
||
# Link against rerun_sdk. | ||
target_link_libraries(example_stdio PRIVATE rerun_sdk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: Standard Input/Output example | ||
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/stdio/main.py?speculative-link | ||
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/stdio/src/main.rs?speculative-link | ||
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/stdio/main.cpp?speculative-link | ||
thumbnail: https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/480w.png | ||
--- | ||
|
||
<picture> | ||
<img src="https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/full.png" alt=""> | ||
<source media="(max-width: 480px)" srcset="https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/480w.png"> | ||
<source media="(max-width: 768px)" srcset="https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/768w.png"> | ||
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/1024w.png"> | ||
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/1200w.png"> | ||
</picture> | ||
|
||
Demonstrates how to log data to standard output with the Rerun SDK, and then visualize it from standard input with the Rerun Viewer. | ||
|
||
To build it from a checkout of the repository (requires a Rust toolchain): | ||
```bash | ||
cmake . | ||
cmake --build . --target example_stdio | ||
echo 'hello from stdin!' | ./examples/cpp/stdio/example_stdio | rerun - | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <iostream> | ||
#include <string> | ||
|
||
#include <rerun.hpp> | ||
|
||
int main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_stdio"); | ||
rec.to_stdout().exit_on_failure(); | ||
|
||
std::string input; | ||
std::string line; | ||
while (std::getline(std::cin, line)) { | ||
input += line + '\n'; | ||
} | ||
|
||
rec.log("stdin", rerun::TextDocument(input)); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters