From 8f9fcaeb1578654e53893fcbec791ce12e092ff8 Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Sat, 4 Apr 2015 15:04:21 +0200 Subject: [PATCH] Move no_std from sdl2-sys to a cargo feature This way sdl2-sys will compile on the beta channel. If needed, sdl2-sys can be compiled using `cargo build --features no_std`. --- .travis.yml | 1 + sdl2-sys/Cargo.toml | 1 + sdl2-sys/src/audio.rs | 1 + sdl2-sys/src/controller.rs | 1 + sdl2-sys/src/event.rs | 1 + sdl2-sys/src/haptic.rs | 1 + sdl2-sys/src/lib.rs | 5 +++-- sdl2-sys/src/rect.rs | 4 ++++ sdl2-sys/src/timer.rs | 1 + sdl2-sys/src/video.rs | 1 + 10 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a08a530..c6f5b6c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ install: script: - cargo build -v - cargo build -v --features "use-pkgconfig" + - cd sdl2-sys && cargo build --features no_std - cargo test -v - cargo doc -v after_success: diff --git a/sdl2-sys/Cargo.toml b/sdl2-sys/Cargo.toml index a819ab30..4ea0b965 100644 --- a/sdl2-sys/Cargo.toml +++ b/sdl2-sys/Cargo.toml @@ -24,3 +24,4 @@ optional = true default = [] use-pkgconfig = ["pkg-config"] +no_std = [] diff --git a/sdl2-sys/src/audio.rs b/sdl2-sys/src/audio.rs index 8ac9f69b..eb5cb899 100644 --- a/sdl2-sys/src/audio.rs +++ b/sdl2-sys/src/audio.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "no_std")] use core::prelude::*; use libc::{c_int, c_uint, c_void, uint8_t, uint32_t}; use libc::{uint16_t, c_double, c_char}; diff --git a/sdl2-sys/src/controller.rs b/sdl2-sys/src/controller.rs index e85a7590..cf512051 100644 --- a/sdl2-sys/src/controller.rs +++ b/sdl2-sys/src/controller.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "no_std")] use core::prelude::*; use libc::{c_int, c_char, c_uchar, c_uint, c_void, int16_t, uint8_t}; use joystick::{SDL_Joystick, SDL_JoystickGUID}; diff --git a/sdl2-sys/src/event.rs b/sdl2-sys/src/event.rs index 1e5ab56f..4d92ff74 100644 --- a/sdl2-sys/src/event.rs +++ b/sdl2-sys/src/event.rs @@ -6,6 +6,7 @@ use gesture::SDL_GestureID; use keyboard::SDL_Keysym; use touch::SDL_FingerID; use touch::SDL_TouchID; +#[cfg(feature = "no_std")] use core::prelude::*; pub type SDL_bool = c_int; diff --git a/sdl2-sys/src/haptic.rs b/sdl2-sys/src/haptic.rs index 83039741..53e53d7e 100644 --- a/sdl2-sys/src/haptic.rs +++ b/sdl2-sys/src/haptic.rs @@ -1,4 +1,5 @@ use joystick::SDL_Joystick; +#[cfg(feature = "no_std")] use core::prelude::*; use libc::{c_int, c_uint, c_char, c_float, c_void, int16_t, int32_t, uint8_t, uint16_t, uint32_t}; diff --git a/sdl2-sys/src/lib.rs b/sdl2-sys/src/lib.rs index 28fc7b82..45e0ebba 100644 --- a/sdl2-sys/src/lib.rs +++ b/sdl2-sys/src/lib.rs @@ -1,8 +1,9 @@ -#![feature(no_std, core)] -#![no_std] +#![cfg_attr(feature = "no_std", feature(no_std, core))] +#![cfg_attr(feature = "no_std", no_std)] #![allow(non_camel_case_types)] extern crate libc; +#[cfg(feature = "no_std")] extern crate core; pub mod scancode; diff --git a/sdl2-sys/src/rect.rs b/sdl2-sys/src/rect.rs index 573a27b7..5e617a31 100644 --- a/sdl2-sys/src/rect.rs +++ b/sdl2-sys/src/rect.rs @@ -2,8 +2,12 @@ Rectangle Functions */ +#[cfg(feature = "no_std")] use core::prelude::*; +#[cfg(feature = "no_std")] use core::intrinsics::transmute; +#[cfg(not(feature = "no_std"))] +use std::mem::transmute; use libc::c_int; /// A structure that defines a two dimensional point. diff --git a/sdl2-sys/src/timer.rs b/sdl2-sys/src/timer.rs index b4a7791d..8dac9e5b 100644 --- a/sdl2-sys/src/timer.rs +++ b/sdl2-sys/src/timer.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "no_std")] use core::prelude::*; use libc::{uint32_t, uint64_t, c_void, c_int}; diff --git a/sdl2-sys/src/video.rs b/sdl2-sys/src/video.rs index 2ddf7a9d..3de38cbb 100644 --- a/sdl2-sys/src/video.rs +++ b/sdl2-sys/src/video.rs @@ -1,6 +1,7 @@ use rect::Rect; use surface::SDL_Surface; +#[cfg(feature = "no_std")] use core::prelude::*; use libc::{c_void, c_int, c_float, c_char, uint16_t, uint32_t};