Skip to content

Commit

Permalink
Rename the env variable and don't affect features
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterAwesome committed Mar 9, 2024
1 parent 1360a98 commit 30b7f13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 6 additions & 3 deletions mbedtls-sys/build/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +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")
|| crate::features::FEATURES.have_platform_component("c_compiler", "freestanding")
{
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
7 changes: 1 addition & 6 deletions mbedtls-sys/build/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ impl Features {
let have_custom_threading = self.have_feature("custom_threading");
let have_custom_gmtime_r = self.have_feature("custom_gmtime_r");

println!("cargo:rerun-if-env-changed=RUST_MBED_C_COMPILER_FREESTANDING");
let freestanding = std::env::var("RUST_MBED_C_COMPILER_FREESTANDING")
.map(|x| x == "1")
.unwrap_or_default();

if !self.have_feature("std") || env_have_target_cfg("env", "sgx") || env_have_target_cfg("os", "none") || freestanding {
if !self.have_feature("std") || env_have_target_cfg("env", "sgx") || env_have_target_cfg("os", "none") {
self.with_feature("c_compiler").unwrap().insert("freestanding");
}
if let Some(components) = self.with_feature("threading") {
Expand Down

0 comments on commit 30b7f13

Please sign in to comment.