Skip to content

Commit 91683a1

Browse files
committed
rust: Make cargo warn when missing env variable
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.
1 parent 8a59a76 commit 91683a1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/rust/bitbox02-rust/build.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2024 Shift Crypto AG
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Emit a warning if FIRMWARE_VERSION_SHORT isn't set. We don't want this to be a hard error during
16+
// development so that rust tools are happy.
17+
fn main() {
18+
let version = option_env!("FIRMWARE_VERSION_SHORT");
19+
if let Some(version) = version {
20+
if version.is_empty() {
21+
println!("cargo::warning=FIRMWARE_VERSION_SHORT is empty");
22+
}
23+
} else {
24+
println!("cargo::warning=FIRMWARE_VERSION_SHORT is not set");
25+
}
26+
}

0 commit comments

Comments
 (0)