diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-07-25 15:53:00 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-07-25 15:53:00 +0200 |
| commit | 2d678d695637ed1023fd80fea482d60a288e4343 (patch) | |
| tree | e31b0d20672194e7c3c3f190835d10e46f200dd5 /embassy-sync/build_common.rs | |
| parent | 8b4bb625be86e7c199a14ceffbed7ad87b99a8db (diff) | |
Update to Rust 1.80, make check-cfg unconditional.
Diffstat (limited to 'embassy-sync/build_common.rs')
| -rw-r--r-- | embassy-sync/build_common.rs | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/embassy-sync/build_common.rs b/embassy-sync/build_common.rs index 0487eb3c5..4f24e6d37 100644 --- a/embassy-sync/build_common.rs +++ b/embassy-sync/build_common.rs | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | use std::collections::HashSet; | 9 | use std::collections::HashSet; |
| 10 | use std::env; | 10 | use std::env; |
| 11 | use std::ffi::OsString; | ||
| 12 | use std::process::Command; | ||
| 13 | 11 | ||
| 14 | /// Helper for emitting cargo instruction for enabling configs (`cargo:rustc-cfg=X`) and declaring | 12 | /// Helper for emitting cargo instruction for enabling configs (`cargo:rustc-cfg=X`) and declaring |
| 15 | /// them (`cargo:rust-check-cfg=cfg(X)`). | 13 | /// them (`cargo:rust-check-cfg=cfg(X)`). |
| @@ -17,7 +15,6 @@ use std::process::Command; | |||
| 17 | pub struct CfgSet { | 15 | pub struct CfgSet { |
| 18 | enabled: HashSet<String>, | 16 | enabled: HashSet<String>, |
| 19 | declared: HashSet<String>, | 17 | declared: HashSet<String>, |
| 20 | emit_declared: bool, | ||
| 21 | } | 18 | } |
| 22 | 19 | ||
| 23 | impl CfgSet { | 20 | impl CfgSet { |
| @@ -25,7 +22,6 @@ impl CfgSet { | |||
| 25 | Self { | 22 | Self { |
| 26 | enabled: HashSet::new(), | 23 | enabled: HashSet::new(), |
| 27 | declared: HashSet::new(), | 24 | declared: HashSet::new(), |
| 28 | emit_declared: is_rustc_nightly(), | ||
| 29 | } | 25 | } |
| 30 | } | 26 | } |
| 31 | 27 | ||
| @@ -49,7 +45,7 @@ impl CfgSet { | |||
| 49 | /// | 45 | /// |
| 50 | /// This enables rustc to check that the configs in `#[cfg(...)]` attributes are valid. | 46 | /// This enables rustc to check that the configs in `#[cfg(...)]` attributes are valid. |
| 51 | pub fn declare(&mut self, cfg: impl AsRef<str>) { | 47 | pub fn declare(&mut self, cfg: impl AsRef<str>) { |
| 52 | if self.declared.insert(cfg.as_ref().to_owned()) && self.emit_declared { | 48 | if self.declared.insert(cfg.as_ref().to_owned()) { |
| 53 | println!("cargo:rustc-check-cfg=cfg({})", cfg.as_ref()); | 49 | println!("cargo:rustc-check-cfg=cfg({})", cfg.as_ref()); |
| 54 | } | 50 | } |
| 55 | } | 51 | } |
| @@ -69,21 +65,6 @@ impl CfgSet { | |||
| 69 | } | 65 | } |
| 70 | } | 66 | } |
| 71 | 67 | ||
| 72 | fn is_rustc_nightly() -> bool { | ||
| 73 | if env::var_os("EMBASSY_FORCE_CHECK_CFG").is_some() { | ||
| 74 | return true; | ||
| 75 | } | ||
| 76 | |||
| 77 | let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); | ||
| 78 | |||
| 79 | let output = Command::new(rustc) | ||
| 80 | .arg("--version") | ||
| 81 | .output() | ||
| 82 | .expect("failed to run `rustc --version`"); | ||
| 83 | |||
| 84 | String::from_utf8_lossy(&output.stdout).contains("nightly") | ||
| 85 | } | ||
| 86 | |||
| 87 | /// Sets configs that describe the target platform. | 68 | /// Sets configs that describe the target platform. |
| 88 | pub fn set_target_cfgs(cfgs: &mut CfgSet) { | 69 | pub fn set_target_cfgs(cfgs: &mut CfgSet) { |
| 89 | let target = env::var("TARGET").unwrap(); | 70 | let target = env::var("TARGET").unwrap(); |
