Skip to content

Commit 33940e2

Browse files
author
Jonas Schievink
committed
Prevent building for subtly incompatible targets
1 parent 9097565 commit 33940e2

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

nrf51-hal/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ use std::io::Write;
44
use std::path::PathBuf;
55

66
fn main() {
7+
let target = env::var("TARGET").unwrap();
8+
if !target.starts_with("thumbv6") {
9+
panic!(
10+
"nrf51-hal only supports thumbv6 targets (attempting to build for `{}`)",
11+
target
12+
);
13+
}
14+
715
if let Some((flash, mem)) = memory_sizes() {
816
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
917

nrf52810-hal/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ use std::io::Write;
44
use std::path::PathBuf;
55

66
fn main() {
7+
let target = env::var("TARGET").unwrap();
8+
if target.ends_with("eabihf") {
9+
panic!("attempting to build nrf52810-hal for target `{}`, but the nRF52810 does not have an FPU", target);
10+
}
11+
712
// Put the linker script somewhere the linker can find it
813
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
914
File::create(out.join("memory.x"))

scripts/build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cargo build --manifest-path nrf52840-hal/Cargo.toml
2121
# Build all the example projects.
2222

2323
echo Building examples/ccm-demo...
24-
cargo build --manifest-path examples/ccm-demo/Cargo.toml --features=52810
24+
cargo build --manifest-path examples/ccm-demo/Cargo.toml --features=52810 --target thumbv7em-none-eabi
2525
cargo build --manifest-path examples/ccm-demo/Cargo.toml --features=52832
2626
cargo build --manifest-path examples/ccm-demo/Cargo.toml --features=52833
2727
cargo build --manifest-path examples/ccm-demo/Cargo.toml --features=52840
@@ -30,11 +30,11 @@ echo Building examples/comp-demo...
3030
cargo build --manifest-path examples/comp-demo/Cargo.toml
3131

3232
echo Building examples/ecb-demo...
33-
cargo build --manifest-path examples/ecb-demo/Cargo.toml --features=52810
33+
cargo build --manifest-path examples/ecb-demo/Cargo.toml --features=52810 --target thumbv7em-none-eabi
3434
cargo build --manifest-path examples/ecb-demo/Cargo.toml --features=52832
3535
cargo build --manifest-path examples/ecb-demo/Cargo.toml --features=52833
3636
cargo build --manifest-path examples/ecb-demo/Cargo.toml --features=52840
37-
cargo build --manifest-path examples/ecb-demo/Cargo.toml --features=51
37+
cargo build --manifest-path examples/ecb-demo/Cargo.toml --features=51 --target thumbv6m-none-eabi
3838

3939
echo Building examples/gpiote-demo...
4040
cargo build --manifest-path examples/gpiote-demo/Cargo.toml
@@ -50,8 +50,8 @@ echo Building examples/lpcomp-demo...
5050
cargo build --manifest-path examples/lpcomp-demo/Cargo.toml
5151

5252
echo Building examples/ppi-demo...
53-
cargo build --manifest-path examples/ppi-demo/Cargo.toml --features=51
54-
cargo build --manifest-path examples/ppi-demo/Cargo.toml --features=52810
53+
cargo build --manifest-path examples/ppi-demo/Cargo.toml --features=51 --target thumbv6m-none-eabi
54+
cargo build --manifest-path examples/ppi-demo/Cargo.toml --features=52810 --target thumbv7em-none-eabi
5555
cargo build --manifest-path examples/ppi-demo/Cargo.toml --features=52832
5656
cargo build --manifest-path examples/ppi-demo/Cargo.toml --features=52833
5757
cargo build --manifest-path examples/ppi-demo/Cargo.toml --features=52840

0 commit comments

Comments
 (0)