Skip to content

Commit

Permalink
rust: Make cargo warn when missing env variable
Browse files Browse the repository at this point in the history
Adding a build script impacts the metadata of the crate which means that
it also impacts all the mangled function names and eventually has a
minor impact on the final binary. All rust symbols end with a hash of
the crate metadata.
  • Loading branch information
NickeZ committed Sep 2, 2024
1 parent 8a59a76 commit 91683a1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/rust/bitbox02-rust/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024 Shift Crypto AG
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Emit a warning if FIRMWARE_VERSION_SHORT isn't set. We don't want this to be a hard error during
// development so that rust tools are happy.
fn main() {
let version = option_env!("FIRMWARE_VERSION_SHORT");
if let Some(version) = version {
if version.is_empty() {
println!("cargo::warning=FIRMWARE_VERSION_SHORT is empty");
}
} else {
println!("cargo::warning=FIRMWARE_VERSION_SHORT is not set");
}
}

0 comments on commit 91683a1

Please sign in to comment.