Remove build.rs, use target_has_atomic
instead
`target_has_atomic` has been stable since rust 1.60
This commit is contained in:
parent
1701acbc17
commit
1c34428394
3 changed files with 19 additions and 28 deletions
|
@ -10,7 +10,6 @@ license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["rust", "json-schema", "serde"]
|
keywords = ["rust", "json-schema", "serde"]
|
||||||
categories = ["encoding"]
|
categories = ["encoding"]
|
||||||
build = "build.rs"
|
|
||||||
rust-version = "1.60"
|
rust-version = "1.60"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
use std::env;
|
|
||||||
|
|
||||||
// Based on https://github.com/serde-rs/serde/blob/master/serde/build.rs
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let target = env::var("TARGET").unwrap();
|
|
||||||
let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten";
|
|
||||||
|
|
||||||
// Whitelist of archs that support std::sync::atomic module. Ideally we
|
|
||||||
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
|
|
||||||
// Instead this is based on rustc's src/librustc_target/spec/*.rs.
|
|
||||||
let has_atomic64 = target.starts_with("x86_64")
|
|
||||||
|| target.starts_with("i686")
|
|
||||||
|| target.starts_with("aarch64")
|
|
||||||
|| target.starts_with("powerpc64")
|
|
||||||
|| target.starts_with("sparc64")
|
|
||||||
|| target.starts_with("mips64el");
|
|
||||||
let has_atomic32 = has_atomic64 || emscripten;
|
|
||||||
if has_atomic64 {
|
|
||||||
println!("cargo:rustc-cfg=std_atomic64");
|
|
||||||
}
|
|
||||||
if has_atomic32 {
|
|
||||||
println!("cargo:rustc-cfg=std_atomic");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +1,36 @@
|
||||||
use std::sync::atomic::*;
|
use std::sync::atomic::*;
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "8")]
|
||||||
forward_impl!(AtomicBool => bool);
|
forward_impl!(AtomicBool => bool);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "8")]
|
||||||
forward_impl!(AtomicI8 => i8);
|
forward_impl!(AtomicI8 => i8);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "16")]
|
||||||
forward_impl!(AtomicI16 => i16);
|
forward_impl!(AtomicI16 => i16);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "32")]
|
||||||
forward_impl!(AtomicI32 => i32);
|
forward_impl!(AtomicI32 => i32);
|
||||||
#[cfg(std_atomic64)]
|
|
||||||
|
#[cfg(target_has_atomic = "64")]
|
||||||
forward_impl!(AtomicI64 => i64);
|
forward_impl!(AtomicI64 => i64);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "ptr")]
|
||||||
forward_impl!(AtomicIsize => isize);
|
forward_impl!(AtomicIsize => isize);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "8")]
|
||||||
forward_impl!(AtomicU8 => u8);
|
forward_impl!(AtomicU8 => u8);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "16")]
|
||||||
forward_impl!(AtomicU16 => u16);
|
forward_impl!(AtomicU16 => u16);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "32")]
|
||||||
forward_impl!(AtomicU32 => u32);
|
forward_impl!(AtomicU32 => u32);
|
||||||
#[cfg(std_atomic64)]
|
|
||||||
|
#[cfg(target_has_atomic = "64")]
|
||||||
forward_impl!(AtomicU64 => u64);
|
forward_impl!(AtomicU64 => u64);
|
||||||
|
|
||||||
|
#[cfg(target_has_atomic = "ptr")]
|
||||||
forward_impl!(AtomicUsize => usize);
|
forward_impl!(AtomicUsize => usize);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue