Skip to content

Commit

Permalink
Fail if generate_docs feature is not enabled and ROS_DISTRO is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
esteve committed Nov 9, 2023
1 parent e4b251b commit 90cf785
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions rclrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ path = "src/lib.rs"
[dependencies]
# Needed for dynamically finding type support libraries
ament_rs = { version = "0.2", optional = true }
# Needed for uploading documentation to docs.rs
cfg-if = "1.0.0"

# Needed for clients
futures = "0.3"
# Needed for dynamic messages
Expand All @@ -31,6 +33,8 @@ tempfile = "3.3.0"
[build-dependencies]
# Needed for FFI
bindgen = "0.66.1"
# Needed for uploading documentation to docs.rs
cfg-if = "1.0.0"

[features]
dyn_msg = ["ament_rs", "libloading"]
Expand Down
15 changes: 10 additions & 5 deletions rclrs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ fn main() {
let ros_distro = if let Ok(value) = env::var(ROS_DISTRO) {
value
} else {
println!(
"{} environment variable not set - please source ROS 2 installation first.",
ROS_DISTRO
);
return;
let error_msg =
"ROS_DISTRO environment variable not set - please source ROS 2 installation first.";
cfg_if::cfg_if! {
if #[cfg(feature="generate_docs")] {
println!(error_msg);
return;
} else {
panic!(error_msg);
}
}
};

println!("cargo:rustc-cfg=ros_distro=\"{ros_distro}\"");
Expand Down

0 comments on commit 90cf785

Please sign in to comment.