Skip to content

Commit 267d433

Browse files
authored
fix: remove the roslibrust local path (#17)
* ci: merge the examples * refactor(ros-z-msgs): remove the path of local roslibrust * fixup! refactor(ros-z-msgs): remove the path of local roslibrust
1 parent fa3179a commit 267d433

4 files changed

Lines changed: 13 additions & 43 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
5454
- name: Build examples without ROS dependencies
5555
run: |
56-
nix develop '.#noRos-ci' -c cargo build --example z_custom_message
56+
nix develop '.#noRos-ci' -c cargo build --examples
5757
5858
- name: Run tests
5959
run: |
@@ -133,9 +133,7 @@ jobs:
133133
- name: Build ROS message examples
134134
run: |
135135
nix develop '.#${{ matrix.distro }}-ci' -c cargo build -p ros-z-msgs
136-
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example twist_pub
137-
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example battery_state_sub
138-
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example laser_scan
136+
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --examples
139137
nix develop '.#${{ matrix.distro }}-ci' -c cargo build --example z_srvcli --features external_msgs
140138
141139
- name: Build protobuf demo

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,12 @@ nix develop .#noRos-ci
108108

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

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

119118
This allows `ros-z-msgs` to generate message types even in environments without
120119
ROS 2 installed. The default `common_interfaces` feature includes `std_msgs`,

flake.nix

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -282,24 +282,6 @@
282282
}) distros
283283
));
284284

285-
# Package outputs
286-
packages =
287-
let
288-
basePackage = mkRustPackage {
289-
pname = "ros-z";
290-
buildAndTestSubdir = "ros-z";
291-
description = "Native Rust ROS 2 implementation using Zenoh - Core";
292-
};
293-
294-
# Generate packages for all distros
295-
allDistroPackages = builtins.foldl' (acc: distro: acc // (mkRosPackages distro)) { } distros;
296-
in
297-
{
298-
ros-z = basePackage;
299-
default = basePackage;
300-
}
301-
// allDistroPackages;
302-
303285
formatter = pkgs.nixfmt-rfc-style;
304286
}
305287
);

ros-z-msgs/build.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,10 @@ fn discover_bundled_packages(bundled_packages: &[&str]) -> Result<Vec<PathBuf>>
215215
Ok(ros_packages)
216216
}
217217

218-
/// Find roslibrust assets directory
219-
/// This works with both git dependencies and local paths
218+
/// Find roslibrust assets directory from git dependency
220219
/// Returns the base assets directory (not ros2_common_interfaces subdirectory)
221220
fn find_roslibrust_assets() -> PathBuf {
222-
// First, try the local path (for development)
223-
let local_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../roslibrust/assets");
224-
225-
if local_path.exists() {
226-
println!(
227-
"cargo:warning=Using local roslibrust assets at {}",
228-
local_path.display()
229-
);
230-
return local_path;
231-
}
232-
233-
// For git dependencies, search in cargo's git checkout directory
221+
// Search in cargo's git checkout directory
234222
// The path will be something like: ~/.cargo/git/checkouts/roslibrust-{hash}/{commit}/assets
235223
if let Ok(home) = env::var("CARGO_HOME").or_else(|_| env::var("HOME")) {
236224
let cargo_git = PathBuf::from(home).join(".cargo/git/checkouts");
@@ -262,7 +250,10 @@ fn find_roslibrust_assets() -> PathBuf {
262250
}
263251
}
264252

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

0 commit comments

Comments
 (0)