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

Move C++ SDK to own folder #2624

Merged
merged 11 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ BasedOnStyle: Google

# Make it slightly more similar to Rust.
# Based loosly on https://gist.github.com/YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4
AccessModifierOffset: -2
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_pr_summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
version: '>= 363.0.0'

- name: Install deps
run: pip install google-cloud-storage Jinja2 PyGithub # NOLINT
run: pip install google-cloud-storage Jinja2 PyGithub

- name: Render HTML template
run: |
Expand Down
2 changes: 1 addition & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ extend-exclude = [

[default.extend-words]
lod = "lod" # level-of-detail
teh = "teh" # part of @teh-cmc
ND = "ND" # np.NDArray
somes = "somes" # many `Some`
teh = "teh" # part of @teh-cmc

# American English:
grey = "gray"
Expand Down
3 changes: 3 additions & 0 deletions ci_docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ LABEL version="0.7"
LABEL description="Docker image used for the CI of https://github.com/rerun-io/rerun"

# Install the ubuntu package dependencies
# This mirrors scripts/setup.sh
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
apache-arrow \
build-essential \
cmake \
curl \
git \
libatk-bridge2.0 \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main(void) {
.application_id = "c-example-app",
.store_kind = RERUN_STORE_KIND_RECORDING,
};
rr_recording_stream rec_stream = rr_recording_stream_new(&store_info, "0.0.0.0:9876");
rr_recording_stream rec_stream = rr_recording_stream_new(&store_info, "127.0.0.1:9876");

printf("rec_stream: %d\n", rec_stream);

Expand Down
3 changes: 0 additions & 3 deletions crates/rerun_c/example_cpp/.gitignore

This file was deleted.

64 changes: 0 additions & 64 deletions crates/rerun_c/example_cpp/CMakeLists.txt

This file was deleted.

14 changes: 0 additions & 14 deletions crates/rerun_c/example_cpp/build_and_run.sh

This file was deleted.

35 changes: 0 additions & 35 deletions crates/rerun_c/example_cpp/main.cpp

This file was deleted.

3 changes: 1 addition & 2 deletions crates/rerun_c/run_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
set -x

(cd "$script_path/example_c" && make run)
"$script_path/example_cpp/build_and_run.sh"
(cd "$script_path/example" && make run)
1 change: 1 addition & 0 deletions rerun_cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
6 changes: 6 additions & 0 deletions rerun_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.16)

project(rerun_cpp_proj LANGUAGES CXX)

add_subdirectory(src) # The Rerun C++ SDK library
add_subdirectory(example)
17 changes: 17 additions & 0 deletions rerun_cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Rerun C++ SDK

This is not yet ready to be used.

## Requirements
Run `scripts/setup.sh`.

## Test it
rerun_cpp/example/build_and_run.sh

# To do:
* CI
* Code-gen
* Documentation
* Packaging
* Publishing
* …
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes 😆

16 changes: 16 additions & 0 deletions rerun_cpp/build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path"
set -x

mkdir -p build
pushd build
cargo build -p rerun_c # TODO(emilk): add this to CMakelists.txt instead?
cmake -DCMAKE_BUILD_TYPE=Debug ..
make # VERBOSE=1
popd

./build/example/rerun_example

26 changes: 26 additions & 0 deletions rerun_cpp/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.16)

# project(RerunExample)

# ------------------------------------------------------------------------------

# Arrow requires a C++17 compliant compiler
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()

if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

add_executable(rerun_example main.cpp)

if(MSVC)
target_compile_options(rerun_example PRIVATE /W4 /WX)
else()
target_compile_options(rerun_example PRIVATE -Wall -Wextra -Wpedantic -Wcast-align -Wcast-qual -Wformat=2 -Wmissing-include-dirs -Wnull-dereference -Woverloaded-virtual -Wpointer-arith -Wshadow -Wswitch-enum -Wvla -Wno-sign-compare -Wconversion -Wunused -Wold-style-cast -Wno-missing-braces)
endif()

include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../src) # For rerun.hpp (Rerun C++ SDK)

target_link_libraries(rerun_example PRIVATE loguru::loguru rerun_sdk)
File renamed without changes.
29 changes: 29 additions & 0 deletions rerun_cpp/example/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>

#define RERUN_WITH_ARROW 1

#include <loguru.hpp>
#include <rerun.hpp>

int main(int argc, char** argv) {
loguru::g_preamble_uptime = false;
loguru::g_preamble_thread = false;
loguru::init(argc, argv); // installs signal handlers

LOG_F(INFO, "Rerun C++ SDK version: %s", rr::version_string());

auto rr_stream = rr::RecordingStream{"c-example-app", "127.0.0.1:9876"};

float xyz[9] = {0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 5.0, 5.0, 5.0};
auto points = rr::points3(3, xyz).ValueOrDie();
auto buffer = rr::ipc_from_table(*points).ValueOrDie();

const rr::DataCell data_cells[1] = {rr::DataCell{
.component_name = "rerun.point3d",
.num_bytes = static_cast<size_t>(buffer->size()),
.bytes = buffer->data(),
}};

uint32_t num_instances = 3;
rr_stream.log_data_row("points", num_instances, 1, data_cells);
}
67 changes: 67 additions & 0 deletions rerun_cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 3.16)

# NOTE: CMake docs strongly discourages using GLOB, and instead suggests
# manually listing all the files, like it's 1972.
# However, that won't work for use since we auto-generate the source tree.
# See https://cmake.org/cmake/help/latest/command/file.html#glob
file(GLOB rerun_sdk_SRC CONFIGURE_DEPENDS
"*.hpp"
"*.cpp"
)

add_library(rerun_sdk ${rerun_sdk_SRC})

# ------------------------------------------------------------------------------

# For rerun.h (Rerun C SDK):
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../../crates/rerun_c/src)

# Make sure the compiler can find include files for rerun
# when other libraries or executables link to rerun:
target_include_directories(rerun_sdk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# ------------------------------------------------------------------------------
# Loguru logging library (https://github.com/emilk/loguru):
set(CMAKE_DL_LIBS "dl") # Required by Loguru for backtraces

# Loguru, see https://github.com/emilk/loguru/blob/master/loguru_cmake_example/CMakeLists.txt
include(FetchContent)
FetchContent_Declare(LoguruGitRepo
GIT_REPOSITORY "https://github.com/emilk/loguru" # can be a filesystem path
GIT_TAG "master"
)

# set any loguru compile-time flags before calling MakeAvailable()
set(LOGURU_STACKTRACES 1)
FetchContent_MakeAvailable(LoguruGitRepo) # defines target 'loguru::loguru'

target_link_libraries(rerun_sdk PRIVATE loguru::loguru)

# ------------------------------------------------------------------------------
if(APPLE)
target_link_libraries(rerun_sdk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug/librerun_c.a)
target_link_libraries(rerun_sdk PRIVATE "-framework CoreFoundation" "-framework IOKit")
endif()

if(LINUX)
target_link_libraries(rerun_sdk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug/librerun_c.a)
target_link_libraries(rerun_sdk PRIVATE "-lm")
endif()

# -----------------------------------------------------------------------------
# Arrow:
option(ARROW_LINK_SHARED "Link to the Arrow shared library" ON)

find_package(Arrow REQUIRED)

# Arrow requires a C++17 compliant compiler
set(CMAKE_CXX_STANDARD_REQUIRED ON)

message(STATUS "Arrow version: ${ARROW_VERSION}")
message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")

if(ARROW_LINK_SHARED)
target_link_libraries(rerun_sdk PRIVATE Arrow::arrow_shared)
else()
target_link_libraries(rerun_sdk PRIVATE Arrow::arrow_static)
endif()
Loading
Loading