From 3820832d0d28640a4beb8800e9e2060ae5fb2124 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 2 Apr 2025 12:43:51 +0200 Subject: [PATCH] Fix cartographer for ROS 2 With this, cartographer builds at least for Humble, Jazzy and Rolling. Closes #430 --- distros/ros2-overlay.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/distros/ros2-overlay.nix b/distros/ros2-overlay.nix index d29721ac78..9ed545629d 100644 --- a/distros/ros2-overlay.nix +++ b/distros/ros2-overlay.nix @@ -51,6 +51,24 @@ rosSelf: rosSuper: with rosSelf.lib; { ''; }); + # Cartographer is unmaintained upstream: + # https://github.com/cartographer-project/cartographer?tab=readme-ov-file#a-note-for-ros-users + cartographer = rosSuper.cartographer.overrideAttrs ({ + nativeBuildInputs ? [], + postPatch ? "", ... + }: { + nativeBuildInputs = nativeBuildInputs ++ [ self.pkg-config ]; + + # Add ABSL_ prefix to thread annotation macros. See + # https://github.com/abseil/abseil-cpp/commit/6acb60c161f1203e6eca929b87f2041da7714bfe + # Note that the mentioned ABSL_LEGACY_THREAD_ANNOTATIONS is no + # longer available so we have to patch all call sites. + postPatch = '' + sed -i -Ee 's/\<(LOCKS_EXCLUDED|EXCLUSIVE_LOCKS_REQUIRED|GUARDED_BY)\>/ABSL_\1/g' \ + $(find -name \*.h -o -name \*.cc ) + ''; + }); + cyclonedds = rosSuper.cyclonedds.overrideAttrs ({ cmakeFlags ? [], ... }: {