Skip to content

Commit 553a767

Browse files
authored
dont hardcode build mode into BuildInfo (#11386)
`BuildInfo` used to hardcode the builld mode (i.e. debug vs. release) to `cfg(debug_assertions)`, which ofc doesn't work when the `BuildInfo` is coming from the wire (e.g. the `RerunCloud.version` gRPC endpoint). Before: ```sh $ pixi run redap version client: redap_cli 0.3.0-alpha.1 (default tracy) [rustc 1.88.0 (6b00bc388 2025-06-23), LLVM 20.1.5] x86_64-unknown-linux-gnu (debug) server: redap_frontend 0.3.0-alpha.1 [rustc 1.88.0 (6b00bc388 2025-06-23), LLVM 20.1.5] x86_64-unknown-linux-gnu (debug) # <-- this server is actually a release build ``` After: ```sh $ pixi run redap version client: redap_cli 0.3.0-alpha.1 (default tracy) [rustc 1.88.0 (6b00bc388 2025-06-23), LLVM 20.1.5] x86_64-unknown-linux-gnu (debug) server: redap_frontend 0.3.0-alpha.1 [rustc 1.88.0 (6b00bc388 2025-06-23), LLVM 20.1.5] x86_64-unknown-linux-gnu ```
1 parent 5c21337 commit 553a767

File tree

8 files changed

+22
-4
lines changed

8 files changed

+22
-4
lines changed

crates/build/re_build_info/src/build_info.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pub struct BuildInfo {
5050
///
5151
/// Empty if unknown.
5252
pub datetime: Cow<'static, str>,
53+
54+
/// True if this is a debug build.
55+
pub is_debug_build: bool,
5356
}
5457

5558
impl BuildInfo {
@@ -88,6 +91,7 @@ impl std::fmt::Display for BuildInfo {
8891
is_in_rerun_workspace: _,
8992
target_triple,
9093
datetime,
94+
is_debug_build,
9195
} = self;
9296

9397
let rustc_version = (!rustc_version.is_empty()).then(|| format!("rustc {rustc_version}"));
@@ -123,7 +127,7 @@ impl std::fmt::Display for BuildInfo {
123127
write!(f, ", built {datetime}")?;
124128
}
125129

126-
if cfg!(debug_assertions) {
130+
if *is_debug_build {
127131
write!(f, " (debug)")?;
128132
}
129133

@@ -177,6 +181,7 @@ fn crate_version_from_build_info_string() {
177181
is_in_rerun_workspace: true,
178182
target_triple: "x86_64-unknown-linux-gnu".into(),
179183
datetime: "".into(),
184+
is_debug_build: true,
180185
};
181186

182187
let build_info_str = build_info.to_string();

crates/build/re_build_info/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ macro_rules! build_info {
2626
is_in_rerun_workspace: env!("RE_BUILD_IS_IN_RERUN_WORKSPACE") == "yes",
2727
target_triple: env!("RE_BUILD_TARGET_TRIPLE").into(),
2828
datetime: env!("RE_BUILD_DATETIME").into(),
29+
is_debug_build: cfg!(debug_assertions),
2930
}
3031
};
3132
}

crates/store/re_protos/proto/rerun/v1alpha1/common.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ message BuildInfo {
256256
//
257257
// Empty if unknown.
258258
optional string build_time = 9;
259+
260+
/// True if this is a debug build.
261+
optional bool is_debug_build = 10;
259262
}
260263

261264
// Mirrors `re_build_info::CrateVersion`.

crates/store/re_protos/src/v1alpha1/rerun.common.v1alpha1.ext.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ impl From<re_build_info::BuildInfo> for crate::common::v1alpha1::BuildInfo {
678678
git_branch: Some(build_info.git_branch.to_string()),
679679
target_triple: Some(build_info.target_triple.to_string()),
680680
build_time: Some(build_info.datetime.to_string()),
681+
is_debug_build: Some(build_info.is_debug_build),
681682
}
682683
}
683684
}
@@ -695,6 +696,7 @@ impl From<crate::common::v1alpha1::BuildInfo> for re_build_info::BuildInfo {
695696
is_in_rerun_workspace: false,
696697
target_triple: build_info.target_triple().to_owned().into(),
697698
datetime: build_info.build_time().to_owned().into(),
699+
is_debug_build: build_info.is_debug_build(),
698700
}
699701
}
700702
}

crates/store/re_protos/src/v1alpha1/rerun.common.v1alpha1.rs

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/utils/re_analytics/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ impl Properties for re_build_info::BuildInfo {
428428
is_in_rerun_workspace,
429429
target_triple,
430430
datetime,
431+
is_debug_build,
431432
} = self;
432433

433434
event.insert("features", features.to_string());
@@ -437,7 +438,7 @@ impl Properties for re_build_info::BuildInfo {
437438
event.insert("llvm_version", llvm_version.to_string());
438439
event.insert("target", target_triple.to_string());
439440
event.insert("build_date", datetime.to_string());
440-
event.insert("debug", cfg!(debug_assertions)); // debug-build?
441+
event.insert("debug", is_debug_build);
441442
event.insert("rerun_workspace", is_in_rerun_workspace);
442443
}
443444
}

crates/viewer/re_viewer/src/ui/rerun_menu.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ impl App {
166166
is_in_rerun_workspace: _,
167167
target_triple,
168168
datetime,
169+
is_debug_build,
169170
} = self.build_info();
170171

171172
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
@@ -177,8 +178,10 @@ impl App {
177178
format!("({short_git_hash})")
178179
};
179180

181+
let debug_label = if *is_debug_build { " (debug)" } else { "" };
182+
180183
let mut label = format!(
181-
"{crate_name} {version} {git_hash_suffix}\n\
184+
"{crate_name} {version} {git_hash_suffix}{debug_label}\n\
182185
{target_triple}"
183186
);
184187

crates/viewer/re_viewer/src/ui/top_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn show_warnings(frame: &eframe::Frame, ui: &mut egui::Ui, app_env: &crate::AppE
172172
.small()
173173
.color(ui.visuals().warn_fg_color),
174174
)
175-
.on_hover_text("egui was compiled with debug assertions enabled.");
175+
.on_hover_text("Rerun was compiled with debug assertions enabled.");
176176
}
177177

178178
if !app_env.is_test() {

0 commit comments

Comments
 (0)