Skip to content
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
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Build examples without ROS dependencies
run: |
nix develop '.#noRos-ci' -c cargo build --example z_custom_message
nix develop '.#noRos-ci' -c cargo build --examples

- name: Run tests
run: |
Expand Down Expand Up @@ -133,9 +133,7 @@ jobs:
- name: Build ROS message examples
run: |
nix develop '.#${{ matrix.distro }}-ci' -c cargo build -p ros-z-msgs
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example twist_pub
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example battery_state_sub
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example laser_scan
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --examples
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example z_srvcli --features external_msgs

- name: Build protobuf demo
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ nix develop .#noRos-ci

**Note on `ros-z-msgs`:** This package can build without ROS installed! When
ROS is not available, it automatically falls back to using bundled message
definitions from the roslibrust repository. The build system searches for ROS
packages in this order:
definitions from the roslibrust git dependency. The build system searches for
ROS packages in this order:

1. System ROS installation (via `AMENT_PREFIX_PATH` or `CMAKE_PREFIX_PATH`)
2. Common ROS installation paths (`/opt/ros/{rolling,jazzy,iron,humble}`)
3. Local roslibrust checkout (`../../roslibrust/assets/`)
4. Roslibrust git dependency (`~/.cargo/git/checkouts/roslibrust-*/assets/`)
3. Roslibrust git dependency (`~/.cargo/git/checkouts/roslibrust-*/assets/`)

This allows `ros-z-msgs` to generate message types even in environments without
ROS 2 installed. The default `common_interfaces` feature includes `std_msgs`,
Expand Down
18 changes: 0 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -282,24 +282,6 @@
}) distros
));

# Package outputs
packages =
let
basePackage = mkRustPackage {
pname = "ros-z";
buildAndTestSubdir = "ros-z";
description = "Native Rust ROS 2 implementation using Zenoh - Core";
};

# Generate packages for all distros
allDistroPackages = builtins.foldl' (acc: distro: acc // (mkRosPackages distro)) { } distros;
in
{
ros-z = basePackage;
default = basePackage;
}
// allDistroPackages;

formatter = pkgs.nixfmt-rfc-style;
}
);
Expand Down
25 changes: 8 additions & 17 deletions ros-z-msgs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,10 @@ fn discover_bundled_packages(bundled_packages: &[&str]) -> Result<Vec<PathBuf>>
Ok(ros_packages)
}

/// Find roslibrust assets directory
/// This works with both git dependencies and local paths
/// Find roslibrust assets directory from git dependency
/// Returns the base assets directory (not ros2_common_interfaces subdirectory)
fn find_roslibrust_assets() -> PathBuf {
// First, try the local path (for development)
let local_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../roslibrust/assets");

if local_path.exists() {
println!(
"cargo:warning=Using local roslibrust assets at {}",
local_path.display()
);
return local_path;
}

// For git dependencies, search in cargo's git checkout directory
// Search in cargo's git checkout directory
// The path will be something like: ~/.cargo/git/checkouts/roslibrust-{hash}/{commit}/assets
if let Ok(home) = env::var("CARGO_HOME").or_else(|_| env::var("HOME")) {
let cargo_git = PathBuf::from(home).join(".cargo/git/checkouts");
Expand Down Expand Up @@ -262,7 +250,10 @@ fn find_roslibrust_assets() -> PathBuf {
}
}

// Fallback: return the local path anyway, it will fail gracefully if it doesn't exist
println!("cargo:warning=Could not find roslibrust assets, packages may not be available");
local_path
// Fallback: panic with helpful error message
panic!(
"Could not find roslibrust assets directory!\n\
Make sure roslibrust is specified as a git dependency in Cargo.toml.\n\
The build system searches: ~/.cargo/git/checkouts/roslibrust-*/*/assets/"
);
}
Loading