Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no_std build #1456

Merged
merged 2 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,26 @@ matrix:
script:
- cargo build --manifest-path futures/Cargo.toml --features io-compat

# Allow build fail until #1396 is fixed.
- name: cargo build --target=thumbv6m-none-eabi
rust: nightly
env: ALLOW_FAILURES=true
install:
- rustup target add thumbv6m-none-eabi
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --manifest-path futures/Cargo.toml
--target thumbv6m-none-eabi
--no-default-features
--features nightly
--features nightly,cfg-target-has-atomic

- name: cargo build --target=thumbv7m-none-eabi
rust: nightly
install:
- rustup target add thumbv7m-none-eabi
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
- cargo build --manifest-path futures/Cargo.toml
--target thumbv7m-none-eabi
--no-default-features

- name: cargo doc
rust: nightly
Expand Down Expand Up @@ -102,10 +111,6 @@ matrix:
- git commit -m "Add API docs for $TRAVIS_TAG"
- git push origin master

allow_failures:
- rust: nightly
env: ALLOW_FAILURES=true

script:
- cargo test --all --all-features
- cargo test --all --all-features --release
Expand Down
11 changes: 11 additions & 0 deletions ci/remove-dev-dependencies/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "remove-dev-dependencies"
version = "0.1.0"
authors = ["Wim Looman <wim@nemo157.com>"]
edition = "2018"
publish = false

[workspace]

[dependencies]
toml_edit = "0.1.3"
12 changes: 12 additions & 0 deletions ci/remove-dev-dependencies/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::{env, error::Error, fs};

fn main() -> Result<(), Box<dyn Error>> {
for file in env::args().skip(1) {
let content = fs::read_to_string(&file)?;
let mut doc: toml_edit::Document = content.parse()?;
doc.as_table_mut().remove("dev-dependencies");
fs::write(file, doc.to_string())?;
}

Ok(())
}
4 changes: 2 additions & 2 deletions futures-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Combinators and utilities for working with `Future`s, `Stream`s, `Sink`s,
//! and the `AsyncRead` and `AsyncWrite` traits.

#![feature(futures_api, box_into_pin)]
#![cfg_attr(feature = "std", feature(async_await, await_macro))]
#![feature(futures_api)]
#![cfg_attr(feature = "std", feature(async_await, await_macro, box_into_pin))]
#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))]

#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
4 changes: 3 additions & 1 deletion futures-util/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ mod arc_wake;
pub use self::arc_wake::ArcWake;

mod noop_waker;
pub use self::noop_waker::{noop_waker, noop_waker_ref};
pub use self::noop_waker::noop_waker;
#[cfg(feature = "std")]
pub use self::noop_waker::noop_waker_ref;

mod spawn;
pub use self::spawn::{SpawnExt, LocalSpawnExt};
Expand Down
2 changes: 2 additions & 0 deletions futures-util/src/task/noop_waker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Utilities for creating zero-cost wakers that don't do anything.
use futures_core::task::{RawWaker, RawWakerVTable, Waker};
use core::ptr::null;
#[cfg(feature = "std")]
use core::cell::UnsafeCell;

unsafe fn noop_clone(_data: *const()) -> RawWaker {
Expand Down Expand Up @@ -52,6 +53,7 @@ pub fn noop_waker() -> Waker {
/// lw.wake();
/// ```
#[inline]
#[cfg(feature = "std")]
pub fn noop_waker_ref() -> &'static Waker {
thread_local! {
static NOOP_WAKER_INSTANCE: UnsafeCell<Waker> =
Expand Down
13 changes: 8 additions & 5 deletions futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ pub mod future {
AndThen, ErrInto, FlattenSink, IntoFuture, MapErr, MapOk, OrElse,
UnwrapOrElse,
TryJoin, TryJoin3, TryJoin4, TryJoin5,
};

#[cfg(feature = "std")]
pub use futures_util::try_future::{
try_join_all, TryJoinAll,
};
}
Expand Down Expand Up @@ -364,18 +368,17 @@ pub mod task {
Waker, RawWaker, RawWakerVTable
};

pub use futures_util::task::noop_waker;

#[cfg(feature = "std")]
pub use futures_util::task::{
WakerRef, waker_ref, ArcWake,
SpawnExt, LocalSpawnExt,
};

pub use futures_util::task::{
noop_waker, noop_waker_ref,
noop_waker_ref,
};

#[cfg_attr(
feature = "target-has-atomic",
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
pub use futures_util::task::AtomicWaker;
Expand Down