From 0ffba9f96b39dca74287015ee2bd0d1c1cacb8b3 Mon Sep 17 00:00:00 2001 From: gnzlbg <gonzalobg88@gmail.com> Date: Wed, 13 Feb 2019 10:27:47 +0100 Subject: [PATCH] Test that targets without a libstd component build on CI using xargo --- ci/build.sh | 58 +++++++++++++-- src/dox.rs | 211 ---------------------------------------------------- src/lib.rs | 102 +++++++++++-------------- 3 files changed, 95 insertions(+), 276 deletions(-) delete mode 100644 src/dox.rs diff --git a/ci/build.sh b/ci/build.sh index 69805fcb..09a05be1 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -11,7 +11,8 @@ OS=${TRAVIS_OS_NAME} echo "Testing Rust ${RUST} on ${OS}" test_target() { - TARGET="${1}" + CARGO="${1}" + TARGET="${2}" opt= if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then @@ -22,7 +23,7 @@ test_target() { opt="--release" fi - NO_STD= + NO_STD="${3}" case ${TARGET} in thumbv*) NO_STD=1 @@ -32,25 +33,62 @@ test_target() { rustup target add "${TARGET}" --toolchain "${RUST}" || true # Test that libc builds without any default features (no libstd) - cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" + "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" # Test that libc builds with default features (e.g. libstd) # if the target supports libstd if [ "$NO_STD" != "1" ]; then - cargo "+${RUST}" build -vv $opt --target "${TARGET}" + "$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}" fi # Test that libc builds with the `extra_traits` feature - cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \ + "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \ --features extra_traits # Also test that it builds with `extra_traits` and default features: if [ "$NO_STD" != "1" ]; then - cargo "+${RUST}" build -vv $opt --target "${TARGET}" \ + "$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}" \ --features extra_traits fi } +rustup component add rust-src || true +cargo install xargo || true + + +RUST_LINUX_NO_CORE_TARGETS="\ +x86_64-unknown-dragonfly \ +aarch64-pc-windows-msvc \ +aarch64-unknown-cloudabi \ +armv7-unknown-cloudabi-eabihf \ +i586-pc-windows-msvc \ +i686-pc-windows-gnu \ +i686-pc-windows-msvc \ +i686-unknown-cloudabi \ +i686-unknown-haiku \ +i686-unknown-netbsd \ +mips-unknown-linux-uclib \ +mipsel-unknown-unknown-linux-uclib \ +nvptx64-nvidia-cuda \ +powerpc-unknown-linux-gnuspe \ +riscv32imac-unknown-none-elf \ +riscv32imc-unknown-none-elf \ +sparc-unknown-linux-gnu \ +sparc64-unknown-netbsd \ +thumbv8m.main-none-eabi \ +x86_64-pc-windows-gnu \ +x86_64-pc-windows-msvc +x86_64-unknown-bitrig \ +x86_64-unknown-haiku \ +x86_64-unknown-openbsd +" + +for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do + if [ "${RUST}" = "nightly" ]; then + RUST_LIBC_NO_CORE_BUILD=1 test_target xargo "$TARGET" 1 + fi +done + RUST_LINUX_TARGETS="\ aarch64-linux-android \ aarch64-unknown-linux-gnu \ @@ -103,6 +141,12 @@ x86_64-unknown-cloudabi \ RUST_NIGHTLY_LINUX_TARGETS="\ aarch64-fuchsia \ +armv5te-unknown-linux-gnueabi \ +armv5te-unknown-linux-musleabi \ +armebv7r-none-eabi \ +armebv7r-none-eabihf \ +armv7r-none-eabi \ +armv7r-none-eabihf \ thumbv6m-none-eabi \ thumbv7em-none-eabi \ thumbv7em-none-eabihf \ @@ -161,5 +205,5 @@ case "${OS}" in esac for TARGET in $TARGETS; do - test_target "$TARGET" + test_target cargo "$TARGET" done diff --git a/src/dox.rs b/src/dox.rs deleted file mode 100644 index d9899bb2..00000000 --- a/src/dox.rs +++ /dev/null @@ -1,211 +0,0 @@ -pub enum Option<T> { - Some(T), - None, -} -impl<T: Copy> Copy for Option<T> {} -impl<T: Clone> Clone for Option<T> { - fn clone(&self) -> Option<T> { - loop {} - } -} - -impl<T> Copy for *mut T {} -impl<T> Clone for *mut T { - fn clone(&self) -> *mut T { - loop {} - } -} - -impl<T> Copy for *const T {} -impl<T> Clone for *const T { - fn clone(&self) -> *const T { - loop {} - } -} - -pub trait Clone { - fn clone(&self) -> Self; -} - -#[lang = "copy"] -pub trait Copy {} - -#[lang = "freeze"] -pub trait Freeze {} - -#[lang = "sync"] -pub trait Sync {} -impl<T> Sync for T {} - -#[lang = "sized"] -pub trait Sized {} - -#[lang = "receiver"] -pub trait Receiver {} -impl<T: ?Sized> Receiver for &T {} -impl<T: ?Sized> Receiver for &mut T {} - -macro_rules! each_int { - ($mac:ident) => { - $mac!(u8); - $mac!(u16); - $mac!(u32); - $mac!(u64); - $mac!(usize); - each_signed_int!($mac); - }; -} - -macro_rules! each_signed_int { - ($mac:ident) => { - $mac!(i8); - $mac!(i16); - $mac!(i32); - $mac!(i64); - $mac!(isize); - }; -} - -#[lang = "div"] -pub trait Div<RHS = Self> { - type Output; - fn div(self, rhs: RHS) -> Self::Output; -} - -#[lang = "shl"] -pub trait Shl<RHS = Self> { - type Output; - fn shl(self, rhs: RHS) -> Self::Output; -} - -#[lang = "mul"] -pub trait Mul<RHS = Self> { - type Output; - fn mul(self, rhs: RHS) -> Self::Output; -} - -#[lang = "sub"] -pub trait Sub<RHS = Self> { - type Output; - fn sub(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitand"] -pub trait BitAnd<RHS = Self> { - type Output; - fn bitand(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitand_assign"] -pub trait BitAndAssign<RHS = Self> { - fn bitand_assign(&mut self, rhs: RHS); -} - -#[lang = "bitor"] -pub trait BitOr<RHS = Self> { - type Output; - fn bitor(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitor_assign"] -pub trait BitOrAssign<RHS = Self> { - fn bitor_assign(&mut self, rhs: RHS); -} - -#[lang = "bitxor"] -pub trait BitXor<RHS = Self> { - type Output; - fn bitxor(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitxor_assign"] -pub trait BitXorAssign<RHS = Self> { - fn bitxor_assign(&mut self, rhs: RHS); -} - -#[lang = "neg"] -pub trait Neg { - type Output; - fn neg(self) -> Self::Output; -} - -#[lang = "not"] -pub trait Not { - type Output; - fn not(self) -> Self::Output; -} - -#[lang = "add"] -pub trait Add<RHS = Self> { - type Output; - fn add(self, r: RHS) -> Self::Output; -} - -macro_rules! impl_traits { - ($($i:ident)*) => ($( - impl Div<$i> for $i { - type Output = $i; - fn div(self, rhs: $i) -> $i { self / rhs } - } - impl Shl<$i> for $i { - type Output = $i; - fn shl(self, rhs: $i) -> $i { self << rhs } - } - impl Mul for $i { - type Output = $i; - fn mul(self, rhs: $i) -> $i { self * rhs } - } - - impl Sub for $i { - type Output = $i; - fn sub(self, rhs: $i) -> $i { self - rhs } - } - impl BitAnd for $i { - type Output = $i; - fn bitand(self, rhs: $i) -> $i { self & rhs } - } - impl BitAndAssign for $i { - fn bitand_assign(&mut self, rhs: $i) { *self &= rhs; } - } - impl BitOr for $i { - type Output = $i; - fn bitor(self, rhs: $i) -> $i { self | rhs } - } - impl BitOrAssign for $i { - fn bitor_assign(&mut self, rhs: $i) { *self |= rhs; } - } - impl BitXor for $i { - type Output = $i; - fn bitxor(self, rhs: $i) -> $i { self ^ rhs } - } - impl BitXorAssign for $i { - fn bitxor_assign(&mut self, rhs: $i) { *self ^= rhs; } - } - impl Neg for $i { - type Output = $i; - fn neg(self) -> $i { -self } - } - impl Not for $i { - type Output = $i; - fn not(self) -> $i { !self } - } - impl Add<$i> for $i { - type Output = $i; - fn add(self, other: $i) -> $i { self + other } - } - impl Copy for $i {} - impl Clone for $i { - fn clone(&self) -> $i { loop {} } - } - )*) -} -each_int!(impl_traits); - -pub mod mem { - pub fn size_of_val<T>(_: &T) -> usize { - 4 - } - pub const fn size_of<T>() -> usize { - 4 - } -} diff --git a/src/lib.rs b/src/lib.rs index 8a7750ac..b1afc08a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,13 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. //! libc - Raw FFI bindings to platforms' system libraries - #![crate_name = "libc"] #![crate_type = "rlib"] #![cfg_attr(not(feature = "rustc-dep-of-std"), deny(warnings))] #![allow(bad_style, overflowing_literals, improper_ctypes, unknown_lints)] -#![cfg_attr(cross_platform_docs, feature(no_core, lang_items, const_fn))] -#![cfg_attr(cross_platform_docs, no_core)] // Attributes needed when building as part of the standard library #![cfg_attr( feature = "rustc-dep-of-std", @@ -28,7 +25,7 @@ not(any( feature = "use_std", feature = "rustc-dep-of-std", - cross_platform_docs + cross_platform_docs, )), no_std )] @@ -50,60 +47,49 @@ cfg_if! { } cfg_if! { - if #[cfg(not(cross_platform_docs))] { - cfg_if! { - if #[cfg(libc_priv_mod_use)] { - #[cfg(libc_core_cvoid)] - #[allow(unused_imports)] - use core::ffi; - #[allow(unused_imports)] - use core::fmt; - #[allow(unused_imports)] - use core::hash; - #[allow(unused_imports)] - use core::num; - #[allow(unused_imports)] - use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::marker::Copy; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::option::Option; - } else { - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::fmt; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::hash; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::num; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::marker::Copy; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::option::Option; - } - } - } -} - -cfg_if! { - if #[cfg(cross_platform_docs)] { - mod dox; - pub use self::dox::*; + if #[cfg(libc_priv_mod_use)] { + #[cfg(libc_core_cvoid)] + #[allow(unused_imports)] + use core::ffi; + #[allow(unused_imports)] + use core::fmt; + #[allow(unused_imports)] + use core::hash; + #[allow(unused_imports)] + use core::num; + #[allow(unused_imports)] + use core::mem; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::clone::Clone; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::marker::Copy; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::option::Option; + } else { + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::fmt; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::hash; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::num; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::mem; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::clone::Clone; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::marker::Copy; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::option::Option; } } -- GitLab