Skip to content

Commit

Permalink
Allow of way to toggle freestanding platform features (#356)
Browse files Browse the repository at this point in the history
* Allow of way to toggle freestanding platform features

`RUST_MBED_C_COMPILER_FREESTANDING=1` allows to skip cmake checks where
the target must produce valid binaries

* Rename the env variable and don't affect features
  • Loading branch information
MasterAwesome authored Mar 11, 2024
1 parent 4ff64a0 commit 2f08d21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mbedtls-sys/build/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ impl super::BuildConfig {
cmk.define("CMAKE_C_COMPILER_FORCED", "TRUE");
}

println!("cargo:rerun-if-env-changed=RUST_MBED_C_COMPILER_BAREMETAL");
let c_compiler_baremetal = std::env::var("RUST_MBED_C_COMPILER_BAREMETAL")
.map(|val| val == "1")
.unwrap_or_default();

let target = std::env::var("TARGET").expect("TARGET environment variable should be set in build scripts");
// thumbv6m-none-eabi, thumbv7em-none-eabi, thumbv7em-none-eabihf,
// thumbv7m-none-eabi probably use arm-none-eabi-gcc which can cause the
// cmake compiler test to fail.
if target.starts_with("thumbv") && target.contains("none-eabi") {
if target.starts_with("thumbv") && target.contains("none-eabi") || c_compiler_baremetal {
// When building on Linux, -rdynamic flag is added automatically. Changing the
// CMAKE_SYSTEM_NAME to Generic avoids this.
cmk.define("CMAKE_SYSTEM_NAME", "Generic");
Expand Down

0 comments on commit 2f08d21

Please sign in to comment.