Skip to content

Commit

Permalink
[Dev] Add rerun example
Browse files Browse the repository at this point in the history
  • Loading branch information
lshmouse committed Sep 30, 2024
1 parent 1e49482 commit 7369e55
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bazel/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ load("//third_party/rules_ros2:workspace.bzl", rules_ros2 = "repo")
load("//third_party/mcap:workspace.bzl", mcap = "repo")
load("//third_party/onnxruntime:workspace.bzl", onnxruntime = "repo")
load("//third_party/foxglove_schemas:workspace.bzl", foxglove_schemas = "repo")
load("//third_party/rerun:workspace.bzl", rerun = "repo")

def init_language_repos():
toolchains_llvm()
Expand Down Expand Up @@ -99,6 +100,7 @@ def init_third_parties():
mcap()
foxglove_schemas()
onnxruntime()
rerun()

# Define all external repositories required by
def repositories():
Expand Down
15 changes: 15 additions & 0 deletions experimental/rerun_example/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
package(default_visibility = ["//visibility:public"])

cc_binary(
name = "rerun_example",
srcs = [
"rerun_example.cpp",
],
linkopts = ["-ldl"],
tags = ["no-tidy"],
deps = [
"@com_github_google_glog//:glog",
"@rerun",
],
)
8 changes: 8 additions & 0 deletions experimental/rerun_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Rerun.io

### Cpp SDK
https://ref.rerun.io/docs/cpp/stable/index.html

### References
- https://github.com/kyle-figure/bazel-minimal-rerun
- https://github.com/rerun-io/rerun
25 changes: 25 additions & 0 deletions experimental/rerun_example/rerun_example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <rerun.hpp>
#include <rerun/demo_utils.hpp>

#include "glog/logging.h"

using rerun::demo::grid3d;

int main() {
LOG(INFO) << "Start a rerun example";
auto rec = rerun::RecordingStream("rerun_example_cpp");

rerun::spawn().exit_on_failure();

// Create some data using the `grid` utility function.
std::vector<rerun::Position3D> points =
grid3d<rerun::Position3D, float>(-10.f, 10.f, 10);
std::vector<rerun::Color> colors = grid3d<rerun::Color, uint8_t>(0, 255, 10);

// Log the "my_points" entity with our data, using the `Points3D` archetype.
rec.log("my_points",
rerun::Points3D(points).with_colors(colors).with_radii({0.5f}));

rec.save("example.rrd").exit_on_failure();
return 0;
}
1 change: 1 addition & 0 deletions third_party/arrow/arrow.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Description:
# Apache Arrow library
# See: https://github.com/tensorflow/io/blob/master/WORKSPACE

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 1 addition & 1 deletion third_party/arrow/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def repo():
http_archive(
name = "arrow",
build_file = "//third_party/arrow:arrow.BUILD",
build_file = "//third_party:arrow.BUILD",
sha256 = "57e13c62f27b710e1de54fd30faed612aefa22aa41fa2c0c3bacd204dd18a8f3",
strip_prefix = "arrow-apache-arrow-7.0.0",
urls = [
Expand Down
1 change: 1 addition & 0 deletions third_party/rerun/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package(default_visibility = ["//visibility:public"])
1 change: 1 addition & 0 deletions third_party/rerun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copied from https://github.com/kyle-figure/bazel-minimal-rerun/tree/main
35 changes: 35 additions & 0 deletions third_party/rerun/rerun.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
load("@rules_cc//cc:defs.bzl", "cc_import")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

package(default_visibility = ["//visibility:public"])

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

cc_import(
name = "rerun_core",
static_library = "@rerun//:lib/librerun_c__linux_x64.a",
)

cc_library(
name = "rerun",
srcs = glob([
"src/rerun/*.cpp",
"src/rerun/**/*.cpp",
]),
hdrs = glob([
"src/rerun.hpp",
"src/rerun/c/*.h",
"src/rerun/*.hpp",
"src/rerun/**/*.hpp",
]),
includes = [
"src",
],
deps = [
":rerun_core",
"@arrow",
],
)
13 changes: 13 additions & 0 deletions third_party/rerun/workspace.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def clean_dep(dep):
return str(Label(dep))

def repo():
http_archive(
name = "rerun",
build_file = "//third_party/rerun:rerun.BUILD",
sha256 = "5f38113a647c72255b902fc3e00ca090c8011821550c94554c8c3845d2eac2a3",
strip_prefix = "rerun_cpp_sdk",
url = "https://github.com/rerun-io/rerun/releases/download/0.13.0/rerun_cpp_sdk.zip",
)

0 comments on commit 7369e55

Please sign in to comment.