Skip to content

Commit 8a59a76

Browse files
committed
rust: Don't stop compilation when missing env var
1 parent e962014 commit 8a59a76

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/rust/bitbox02-rust/src/version.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
// limitations under the License.
1414

1515
/// Firmware version, short format, e.g. "v9.12.0".
16-
// This is evaluated at compile time, if the env var is missing or not set, there will be a compiler error.
16+
// We don't want this to be a hard error during development so that rust tools are happy.
1717
pub static FIRMWARE_VERSION_SHORT: &str = {
18-
let version = env!("FIRMWARE_VERSION_SHORT");
19-
// Need explicit check as the env var could be set to an empty string accidentally (env!() only
20-
// panics if it is not set at all).
21-
if version.is_empty() {
22-
panic!("FIRMWARE_VERSION_SHORT is not set");
18+
let version = option_env!("FIRMWARE_VERSION_SHORT");
19+
if let Some(version) = version {
20+
version
21+
} else {
22+
""
2323
}
24-
version
2524
};

0 commit comments

Comments
 (0)