Commit fdfc06db authored by Trim Bresilla's avatar Trim Bresilla
Browse files

rerun: add C++ SDK support, build librerun_c from source

This commit adds C++ SDK support to the rerun package by:

- Building librerun_c.a library from Rust source (crates/top/rerun_c)
  instead of using prebuilt binaries
- Installing C++ headers to the dev output
- Installing CMake configuration files for integration
- Propagating arrow-cpp as a build dependency

This enables C++ developers to use Rerun without GLIBC compatibility
issues from prebuilt binaries. The library is now compiled fresh during
each build with the system's toolchain.

Package now provides:
- out: rerun CLI binary + librerun_c.a (48MB, built from source)
- dev: C++ headers + CMake config files
parent 33cd71c5
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
  stdenv,
  rustPlatform,
  fetchFromGitHub,
  arrow-cpp,
  # nativeBuildInputs
  binaryen,
  lld,
@@ -36,6 +37,11 @@ rustPlatform.buildRustPackage (finalAttrs: {
  pname = "rerun";
  version = "0.26.2";

  outputs = [
    "out"
    "dev"
  ];

  src = fetchFromGitHub {
    owner = "rerun-io";
    repo = "rerun";
@@ -51,7 +57,10 @@ rustPlatform.buildRustPackage (finalAttrs: {

  cargoHash = "sha256-EH/R+OgLeLNrZnkIGqutTo4K9XzhW+CGwG/uQKwWGXA=";

  cargoBuildFlags = [ "--package rerun-cli" ];
  cargoBuildFlags = [
    "--package rerun-cli"
    "--package rerun_c"
  ];
  cargoTestFlags = [ "--package rerun-cli" ];
  buildNoDefaultFeatures = true;
  buildFeatures = [
@@ -128,6 +137,8 @@ rustPlatform.buildRustPackage (finalAttrs: {
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [ (lib.getLib wayland) ];

  propagatedBuildInputs = [ arrow-cpp ];

  addDlopenRunpaths = map (p: "${lib.getLib p}/lib") (
    lib.optionals stdenv.hostPlatform.isLinux [
      libxkbcommon
@@ -155,6 +166,23 @@ rustPlatform.buildRustPackage (finalAttrs: {

  postPhases = lib.optionals stdenv.hostPlatform.isLinux [ "addDlopenRunpathsPhase" ];

  postInstall = ''
    # Install C++ SDK components
    mkdir -p $dev/include
    cp -r $src/rerun_cpp/src/* $dev/include/

    # Install rerun_c library (built from Rust)
    if [ -f "target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/librerun_c.a" ]; then
      cp "target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/librerun_c.a" $out/lib/
    fi

    # Install CMake config files
    mkdir -p $dev/lib/cmake/rerun_sdk
    cp $src/rerun_cpp/CMakeLists.txt $dev/lib/cmake/rerun_sdk/
    cp $src/rerun_cpp/Config.cmake.in $dev/lib/cmake/rerun_sdk/
    cp $src/rerun_cpp/download_and_build_arrow.cmake $dev/lib/cmake/rerun_sdk/
  '';

  nativeInstallCheckInputs = [
    versionCheckHook
  ];
@@ -169,7 +197,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
  };

  meta = {
    description = "Visualize streams of multimodal data. Fast, easy to use, and simple to integrate.  Built in Rust using egui";
    description = "Visualize streams of multimodal data. Fast, easy to use, and simple to integrate. Built in Rust using egui. Includes C++ SDK";
    homepage = "https://github.com/rerun-io/rerun";
    changelog = "https://github.com/rerun-io/rerun/blob/${finalAttrs.version}/CHANGELOG.md";
    license = with lib.licenses; [