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

Add recipe for librerun-sdk (C++ bindings of rerun Rust library) #25648

Merged
merged 10 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
77 changes: 77 additions & 0 deletions recipes/librerun-sdk/5374.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From 6a7d0a22477b86f12671f98026d9ac3b54a67234 Mon Sep 17 00:00:00 2001
From: Silvio Traversaro <[email protected]>
Date: Sat, 2 Mar 2024 15:44:28 +0100
Subject: [PATCH] Add RERUN_INSTALL_RERUN_C CMake option to disable
installation of rerun_c library

---
rerun_cpp/CMakeLists.txt | 21 +++++++++++++++------
rerun_cpp/Config.cmake.in | 22 ++++++++++++----------
2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/rerun_cpp/CMakeLists.txt b/rerun_cpp/CMakeLists.txt
index 1d40a2a1068..df79896c8f9 100644
--- a/rerun_cpp/CMakeLists.txt
+++ b/rerun_cpp/CMakeLists.txt
@@ -123,13 +123,22 @@ install(TARGETS rerun_sdk
INCLUDES DESTINATION include
)

-# Add all headers to the install.
-install(DIRECTORY "${RERUN_CPP_SOURCE_DIR}/" TYPE INCLUDE FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
+# Add all C++ headers to the install.
+install(DIRECTORY "${RERUN_CPP_SOURCE_DIR}/" TYPE INCLUDE FILES_MATCHING PATTERN "*.hpp")
+
+option(RERUN_INSTALL_RERUN_C "Install rerun_c file." ON)
+# if rerun_sdk is a static library it is compulsory to install rerun_c
+get_target_property(rerun_sdk_TYPE rerun_sdk TYPE)
+if(rerun_sdk_TYPE STREQUAL "STATIC_LIBRARY")
+ message(FATAL_ERROR "It is not possible to disable RERUN_INSTALL_RERUN_C option if rerun_sdk is compiled as static library.")
+endif()

-# Add rerun_c to the lib folder.
-# CMake doesn't allow installing imported targets which is why we need to add this as a file.
-get_target_property(RERUN_C_LIB_LOCATION rerun_c IMPORTED_LOCATION)
-install(FILES ${RERUN_C_LIB_LOCATION} DESTINATION lib)
+if(RERUN_INSTALL_RERUN_C)
+ # CMake doesn't allow installing imported targets which is why we need to add this as a file.
+ get_target_property(RERUN_C_LIB_LOCATION rerun_c IMPORTED_LOCATION)
+ install(DIRECTORY "${RERUN_CPP_SOURCE_DIR}/" TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
+ install(FILES ${RERUN_C_LIB_LOCATION} DESTINATION lib)
+endif()

# Similarly, we bundle the arrow library that was used during the build.
# For the moment we only support this when building with the downloaded, static libarrow.
diff --git a/rerun_cpp/Config.cmake.in b/rerun_cpp/Config.cmake.in
index 9edf8a7f457..1bb1310c7ba 100644
--- a/rerun_cpp/Config.cmake.in
+++ b/rerun_cpp/Config.cmake.in
@@ -4,16 +4,18 @@ include("${CMAKE_CURRENT_LIST_DIR}/rerun_sdkTargets.cmake")

set(RERUN_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/../..")

-# Setup `rerun_c` (imported libraries can't be exported!)
-add_library(rerun_c STATIC IMPORTED GLOBAL)
-get_filename_component(RERUN_C_LIB_NAME "@RERUN_C_LIB_LOCATION@" NAME)
-set_target_properties(rerun_c PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_C_LIB_NAME}")
-if(APPLE)
- target_link_libraries(rerun_c INTERFACE "-framework CoreFoundation" "-framework IOKit")
-elseif(UNIX) # if(LINUX) # CMake 3.25
- target_link_libraries(rerun_c INTERFACE "-lm -ldl -pthread")
-elseif(WIN32)
- target_link_libraries(rerun_c INTERFACE ws2_32.dll Bcrypt.dll Userenv.dll ntdll.dll)
+if(@RERUN_INSTALL_RERUN_C@)
+ # Setup `rerun_c` (imported libraries can't be exported!)
+ add_library(rerun_c STATIC IMPORTED GLOBAL)
+ get_filename_component(RERUN_C_LIB_NAME "@RERUN_C_LIB_LOCATION@" NAME)
+ set_target_properties(rerun_c PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_C_LIB_NAME}")
+ if(APPLE)
+ target_link_libraries(rerun_c INTERFACE "-framework CoreFoundation" "-framework IOKit")
+ elseif(UNIX) # if(LINUX) # CMake 3.25
+ target_link_libraries(rerun_c INTERFACE "-lm -ldl -pthread")
+ elseif(WIN32)
+ target_link_libraries(rerun_c INTERFACE ws2_32.dll Bcrypt.dll Userenv.dll ntdll.dll)
+ endif()
endif()

# Setup `rerun_arrow_target` (imported libraries can't be exported and package dependencies need to be re-declared)
34 changes: 34 additions & 0 deletions recipes/librerun-sdk/5375.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From f47c23fce28dc8ba70ffd4a39f27fbc4f556fdf1 Mon Sep 17 00:00:00 2001
From: Silvio Traversaro <[email protected]>
Date: Sat, 2 Mar 2024 15:52:59 +0100
Subject: [PATCH] Fix Config.cmake.in logic for find arrow in case external
shared arrow is used

---
rerun_cpp/Config.cmake.in | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/rerun_cpp/Config.cmake.in b/rerun_cpp/Config.cmake.in
index 9edf8a7f457..b158a549042 100644
--- a/rerun_cpp/Config.cmake.in
+++ b/rerun_cpp/Config.cmake.in
@@ -31,7 +31,7 @@ if(@RERUN_DOWNLOAD_AND_BUILD_ARROW@ AND NOT @RERUN_ARROW_LINK_SHARED@)
set_target_properties(arrow_targetBundledDeps PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_ARROW_DEPS_LIB_NAME}")
target_link_libraries(rerun_arrow_target INTERFACE arrow_targetBundledDeps)
else()
- if(@RERUN_ARROW_LINK_SHARED@)
+ if(@RERUN_DOWNLOAD_AND_BUILD_ARROW@ AND @RERUN_ARROW_LINK_SHARED@)
message(WARNING
"Rerun got built with an automatically downloaded version of libArrow,"
"but it was not bundled as part of the install since export of shared libArrow is not supported yet."
@@ -42,9 +42,8 @@ else()
find_package(Arrow REQUIRED)

message(STATUS "Rerun is using a system installed libArrow.")
- option(RERUN_ARROW_LINK_SHARED "Link to the Arrow shared library" @RERUN_ARROW_LINK_SHARED_DEFAULT@)

- if(RERUN_ARROW_LINK_SHARED)
+ if(@RERUN_ARROW_LINK_SHARED@)
add_library(rerun_arrow_target ALIAS Arrow::arrow_shared)
else()
add_library(rerun_arrow_target ALIAS Arrow::arrow_static)
34 changes: 34 additions & 0 deletions recipes/librerun-sdk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -ex

if [[ "${target_platform}" == osx-* ]]; then
# See https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk
CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
fi

# https://github.com/rust-lang/cargo/issues/10583#issuecomment-1129997984
export CARGO_NET_GIT_FETCH_WITH_CLI=true
export IS_IN_RERUN_WORKSPACE=no

cargo-bundle-licenses --format yaml --output THIRDPARTY.yml

# The CI environment variable means something specific to Rerun. Unset it.
unset CI

mkdir build_cxx
cd build_cxx

cmake ${CMAKE_ARGS} -GNinja .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DRERUN_ARROW_LINK_SHARED:BOOL=ON \
-DRERUN_DOWNLOAD_AND_BUILD_ARROW:BOOL=OFF \
-DRERUN_INSTALL_RERUN_C:BOOL=OFF

cmake --build . --config Release
cmake --build . --config Release --target install

if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" ]]; then
./rerun_cpp/tests/rerun_sdk_tests
fi
5 changes: 5 additions & 0 deletions recipes/librerun-sdk/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Needed for Metal, the hardware acceleration api for osx
MACOSX_SDK_VERSION: # [osx]
- "11.0" # [osx]
MACOSX_DEPLOYMENT_TARGET: # [osx]
- '10.12' # [osx]
traversaro marked this conversation as resolved.
Show resolved Hide resolved
70 changes: 70 additions & 0 deletions recipes/librerun-sdk/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{% set name = "librerun-sdk" %}
{% set version = "0.14.1" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://github.com/rerun-io/rerun/archive/refs/tags/{{ version }}.tar.gz
sha256: 7b893328bb21a143f04bb9ec0dd5154915a9bc0e9b4d86ca8f780a0fa970b82b
patches:
- 5374.patch
- 5375.patch

build:
number: 0
# Windows does not support shared libraries, let's disable it for now
skip: true # [win]
run_exports:
- {{ pin_subpackage(name, max_pin='x.x.x') }}

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- pkg-config
- ninja
- cargo-bundle-licenses
- rust
traversaro marked this conversation as resolved.
Show resolved Hide resolved
host:
- libarrow
run:
- __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.9") }} # [osx and x86_64]
# Ensure that the users always instal the same version if it
# installs both librerun-sdk (C++) and rerun-sdk (Python)
run_constrained:
- rerun-sdk {{ version }}

test:
commands:
- test -f ${PREFIX}/include/rerun.hpp # [unix]
- test -f ${PREFIX}/lib/librerun_sdk${SHLIB_EXT} # [unix]
- if not exist %LIBRARY_PREFIX%\\include\\rerun.hh exit 1 # [win]
- if not exist %LIBRARY_PREFIX%\\lib\\rerun_sdk.lib exit 1 # [win]
- if not exist %LIBRARY_PREFIX%\\bin\\rerun_sdk.dll exit 1 # [win]
- cmake-package-check rerun_sdk
requires:
- cmake-package-check
- {{ compiler('c') }}
- {{ compiler('cxx') }}

about:
home: https://www.rerun.io/
summary: Rerun is an SDK for logging computer vision and robotics data paired with a visualizer for exploring that data over time.
description: |
The `librerun-sdk` package provides the C++ API for Rerun, while `rerun-sdk` provides the Python API.
license: MIT OR Apache-2.0
license_file:
- THIRDPARTY.yml
- LICENSE-MIT
- LICENSE-APACHE

doc_url: https://www.rerun.io/docs
dev_url: https://github.com/rerun-io/rerun

extra:
recipe-maintainers:
- traversaro
- jleibs